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

2

7

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!

Salahi answered 12/4, 2014 at 15:52 Comment(0)
P
14

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

Prurient answered 15/4, 2014 at 19:0 Comment(1)
Ditto. As of 2014-05-01, the Connect issue was listed as "Won't Fix." I don't know why not; it cost me a bunch of time to chase down the problem, and the fix seems to be a simple change for the next version... :-\Moluccas
J
6

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)" />
Juncture answered 2/3, 2017 at 12:54 Comment(3)
Still an issue in VS 2017Vigesimal
How to do this for non-proj file project. Case in focus: website project that doesn't hove proj file and doesn't produce single dll. Is there a way to set this in web.config?Discover
If there is no compilation why would you need this?Juncture

© 2022 - 2024 — McMap. All rights reserved.