3

I have MVC 5 application which is using RazorGenerator.MVC and RazorGenerator.MsBuild. Because of that my MvcBuildViews is set to false, because it is no longer required. The application is .NET 4.5 one in Visual Studio 2012.

When I'm publishing my application with web publish tool (right click on MVC project -> Publish), I'm using option to pre-compile during publishing.

Everything is working very well when I'm using Any CPU or x32 Platform. However when I'm trying to publish x64 application I have an issue with aspnet_compiler.

It is always trying to use: *C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe* one instead of 64 version so my application cannot be published with x64 platform.

The only place I found I can change path is under MvcBuildViews target, but becuase it is always false for me it will never hit this target and AspNetCompiler ToolPath cannot be used.

I'd like to know from where (which targets file or tasks file) contains that path? I've searched all targets I believe and couldn't find from where is taken.

Marcin
  • 3,232
  • 4
  • 31
  • 48
  • Can you try to change the ToolPath of AspNetCompiler http://forums.asp.net/t/1551418.aspx#3823988? and see if it works? – ramiramilu Jan 25 '14 at 11:29
  • Like I was written I'm not using at all _mvcviewsbuild_ target. I even don't have this part in my csproj file. And I tried this route, but publisher never hit that target. – Marcin Jan 25 '14 at 12:19
  • possible duplicate of [Configure Visual Studio 2013 to allow ASPNETCOMPILER to precompile using the x64 compiler](http://stackoverflow.com/questions/23032653/configure-visual-studio-2013-to-allow-aspnetcompiler-to-precompile-using-the-x64) – Nitin Agarwal May 02 '14 at 04:58

2 Answers2

10

Open the csproj file of the project in your favourite text editor.

Locate:

<MvcBuildViews>true</MvcBuildViews>

Add the following below it:

<AspNetToolPath Condition=" '$(Platform)' == 'x64'">$(windir)\Microsoft.NET\Framework64\v4.0.30319</AspNetToolPath>

Locate:

<Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'" >
  <AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />
</Target>

Amend the AspNetCompiler line as follows:

<AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" ToolPath="$(AspNetToolPath)" />
Michael Armitage
  • 1,502
  • 19
  • 17
8

For Visual Studio 2013, the solution can be found here: Configure Visual Studio 2013 to allow ASPNETCOMPILER to precompile using the x64 compiler (thanks to Nitin)

Shortcut:

Add the following xml in the Project/PropertyGroup xml tag to the publish profile (located in the Properties\PublishProfiles directory of your project).

<AspnetCompilerPath>C:\Windows\Microsoft.NET\Framework64\v4.0.30319</AspnetCompilerPath>
Community
  • 1
  • 1
Alan McBee
  • 4,202
  • 3
  • 33
  • 38