【问题标题】:How to use x64 aspnet_compiler during publish如何在发布期间使用 x64 aspnet_compiler
【发布时间】:2014-01-25 10:04:47
【问题描述】:

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

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

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

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

我发现我可以更改路径的唯一位置是在 MvcBuildViews 目标下,但因为它对我来说总是错误的,所以它永远不会达到这个目标,并且无法使用 AspNetCompiler ToolPath。

我想知道从哪里(哪个目标文件或任务文件)包含该路径?我已经搜索了所有我认为的目标,但找不到从哪里拍摄的。

【问题讨论】:

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


【解决方案1】:

在您喜欢的文本编辑器中打开项目的 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)" />

【讨论】:

    【解决方案2】:

    对于 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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-04
      • 1970-01-01
      • 2020-02-27
      • 1970-01-01
      相关资源
      最近更新 更多