Q:

How to use x64 aspnet_compiler during publish

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.

A:

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)" />

A:

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>

