What is the correct way to precompile an ASP.Net MVC 2 application?

我们两清 提交于 2019-12-23 19:27:03

问题


What is the correct way to precompile an ASP.Net MVC 2 application from Visual Studio 2010?

I am using asp.net 3.5, and trying to use the post build event.

I am using this;

C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler -v / -p "$(ProjectDir)"

but it gives me an invalid path error on the ProjectDir.

UPDATE: I changed "$(ProjectDir)" to $(ProjectDir)\ and it now gives me this error;

"It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS. "

Thanks


回答1:


<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <MvcBuildViews>true</MvcBuildViews>
  </PropertyGroup>

For more details check this answer.




回答2:


Start with the absolute path and work from there. What you tried would normally work, although I use the $(SolutionDir) property, and go from there, as I run this against many different projects.

Here is a list that you may find useful.

Also, I agree with Bugai13. You should upvote/accept answers.




回答3:


I had a few different issues going on and fixed them.

  1. I used this in my Post Build;

    C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler -p "$(ProjectDir)." -v / D:\Work\VSP\deploy

  2. Then I was getting strange errors when it tried to compile my aspx pages. It turns out that I had a "hold" folder in my project to hold original copies of some of my pages. The compiler was trying to compile them even thorugh I didnt need them. After removing those files everything worked fine.



来源:https://stackoverflow.com/questions/4608579/what-is-the-correct-way-to-precompile-an-asp-net-mvc-2-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!