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

前端 未结 2 1717
挽巷
挽巷 2021-02-10 03:44

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.

相关标签:
2条回答
  • 2021-02-10 04:06

    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

    0 讨论(0)
  • 2021-02-10 04:24

    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)" />
    
    0 讨论(0)
提交回复
热议问题