Configure Visual Studio 2013 to allow ASPNETCOMPILER to precompile using the x64 compiler

扶醉桌前 提交于 2019-12-04 13:03:04

问题


How can I use the "Precompile during publishing" flag on a VS2013 x64 project? No matter what I do, it fails to publish because it insists on using the x86 ASPNETCOMPILER.

I think I used to have this working in VS2012, but after upgrading to VS2013 it is no longer working.

I recall the fix involving changing a text file related to MSBuild but I honestly don't know very much about it so it's a little hazy.

Any help is greatly appreciated. Thanks!


回答1:


This seems to be a bug in Visual Studio 2013.

Microsoft Connect - Precompile error when using X64 platform

The workaround listed there works and is to 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>

I was getting this build error before applying the above workaround: "Could not load file or assembly '****' or one of its dependencies. An attempt was made to load a program with an incorrect format." - ASPNETCOMPILER




回答2:


Still an issue in Visual Studio 2015 Update 3...

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


来源:https://stackoverflow.com/questions/23032653/configure-visual-studio-2013-to-allow-aspnetcompiler-to-precompile-using-the-x64

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!