如何在发布期间使用x64 aspnet_compiler

时间:2014-01-25 10:04:48

标签: asp.net-mvc visual-studio-2012 msbuild 64-bit publish

我有使用RazorGenerator.MVC and RazorGenerator.MsBuild的MVC 5应用程序。因此,我的 MvcBuildViews 设置为false,因为不再需要它。该应用程序是Visual Studio 2012中的.NET 4.5。

当我使用网络发布工具发布我的应用程序时(右键单击MVC项目 - >发布),我正在使用选项在发布期间进行预编译。

当我使用任何CPU或x32平台时,一切都运行良好。但是,当我尝试发布x64应用程序时,我遇到了aspnet_compiler的问题。

总是尝试使用:* C:\ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ aspnet_compiler.exe *一个而不是64个版本,因此我的应用程序无法使用x64平台发布。

我找到的唯一可以改变路径的地方是 MvcBuildViews 目标,但是因为它总是对我来说是假的,它永远不会达到这个目标而且不能使用AspNetCompiler ToolPath。

我想知道从哪里(哪个目标文件或任务文件)包含该路径?我搜索了所有我认为无法找到的目标。

2 个答案:

答案 0 :(得分:7)

对于Visual Studio 2013,可以在此处找到解决方案:Configure Visual Studio 2013 to allow ASPNETCOMPILER to precompile using the x64 compiler(感谢Nitin

快捷方式:

将Project / PropertyGroup xml标记中的以下xml添加到发布配置文件(位于项目的Properties \ PublishProfiles目录中)。

<AspnetCompilerPath>C:\Windows\Microsoft.NET\Framework64\v4.0.30319</AspnetCompilerPath>

答案 1 :(得分:4)

在您喜欢的文本编辑器中打开项目的csproj文件。

找到:

<MvcBuildViews>true</MvcBuildViews>

在下面添加以下内容:

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

找到:

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

修改AspNetCompiler行如下:

<AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" ToolPath="$(AspNetToolPath)" />