3

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

Tony
  • 425
  • 2
  • 4
  • 13

3 Answers3

2
<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.

Community
  • 1
  • 1
Andrew Orsich
  • 52,935
  • 16
  • 139
  • 134
  • Yes I did see this, and it was about compiling views, not compiling the entire application. It also was from 2008, MVC 2 was not around at that time. – Tony Jan 05 '11 at 21:07
1

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.

Dan Atkinson
  • 11,391
  • 14
  • 81
  • 114
  • If this works for me then I will accept it, but if id doesn't then I can't accept it. – Tony Jan 05 '11 at 20:48
  • That's why you provide feedback to the user, so that they can help you find an appropriate answer. It's not much of a community if you don't do that. – Dan Atkinson Jan 05 '11 at 20:49
  • You tried `SolutionDir`? It shouldn't be the same error as you're not going outside the application bounds. You'll need to add on your web application directory afterwards. Eg: `$(SolutionDir)\MyMvcApplication`. – Dan Atkinson Jan 05 '11 at 21:19
1

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.

Tony
  • 425
  • 2
  • 4
  • 13