的Visual Studio 2013调用32位aspnet_compiler,而不是64位单 [英] Visual Studio 2013 calls 32 bit aspnet_compiler instead of 64 bit one

查看:274
本文介绍了的Visual Studio 2013调用32位aspnet_compiler,而不是64位单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的解决方案包含了一些.NET项目,其中之一是一个ASP.NET MVC项目,我想发布。所有配置设置正确,X32和x64,他们不设置为值为anycpu。

问题:

如果我尝试发布项目为32位,一切都很好,但在尝试在64位模式发布失败,出现错误:

 无法加载文件或程序项目A或它的一个依赖。
试图加载程序格式不正确。

我已经试过,发现:

自2013 VS,是的MSBuild VS的一部分,像以前不是.NET框架。如果我只是建立64模式下,32位的MSBuild 解决方案C​​:\\ Program Files文件(x86)的\\的MSBuild \\ 12.0 \\斌\\ MSBuild.exe第一次运行过程中出现并推出64位的MSBuild C:\\ Program Files文件(x86)的\\的MSBuild \\ 12.0 \\斌\\ AMD64 \\ MSBuild.exe所以,普通身材不发表作品就好了。

但是,如果我选择发布,的MSBuild首先运行,32位,然后它会启动32位aspnet_compiler C:\\ WINDOWS \\微软。 NET \\ Framework64 \\ v4.0.30319 \\ aspnet_compiler.exe 并没有64位的,这将导致我上面提到的错误。

我发现到现在为止唯一的解决方法是更换

 C:\\ WINDOWS \\ Microsoft.NET \\框架\\ v4.0.30319 \\ aspnet_compiler.exe

在64位有一个

 C:\\ WINDOWS \\ Microsoft.NET \\ Framework64 \\ v4.0.30319 \\ aspnet_compiler.exe

问:

有没有我的问题没有更好的(法律)的解决方案?这看起来像一个VS错误


解决方案

这行添加到您的目标构建配置一个的PropertyGroup 节点内的.csproj文件(或者使用 ProperyGroup 不具有一个目标瞄准所有的释放模式)。

<$p$p><$c$c><AspnetCompilerPath>$(windir)\\Microsoft.NET\\Framework64\\v4.0.30319</AspnetCompilerPath>

64位版本,然后由编译器所使用。对我来说,我的节点添加此行是如下:

 &LT;的PropertyGroup条件='$(配置)| $(平台)'=='发布| 64'&GT;
   &LT; AspnetCompilerPath&GT; $(WINDIR)\\ Microsoft.NET \\ Framework64 \\ v4.0.30319&LT; / AspnetCompilerPath&GT;
&LT; /&的PropertyGroup GT;

My solution contains some .net projects and one of them is a ASP.NET MVC project, which I'm trying to publish. All configurations are set correctly, x32 and x64, non of them is set to AnyCPU.

Problem:

If I try to publish the project as 32bit, everything is fine, but trying to publish in 64 bit mode fails with an error:

Could not load file or assembly "ProjectA" or one of its dependencies. 
An attempt was made to load a program with an incorrect format.

What I've tried and noticed:

Since VS 2013, MSbuild is a part of VS and not of .NET Framework as before. If I simply build the solution in x64 mode, the 32 bit msbuild "C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe" is runnig first and it launches the 64bit msbuild "C:\Program Files (x86)\MSBuild\12.0\Bin\amd64\MSBuild.exe" So normal build without publish works just fine.

But, if I choose publish, the 32bit MSbuild is running first and then it launches the 32 bit aspnet_compiler c:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_compiler.exe and NOT the 64 bit one, which causes an error which I mentioned above.

The only workaround I've found until now is to replace the

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe"

with a 64 bit one

"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_compiler.exe"

Question:

Is there any better (legal) solution for my problem? This looks like a bug in VS

解决方案

Add this line to the .csproj file within a PropertyGroup node for the build configuration you are targeting (or use the ProperyGroup that doesn't have a target to target all release modes).

<AspnetCompilerPath>$(windir)\Microsoft.NET\Framework64\v4.0.30319</AspnetCompilerPath>

The 64-bit version is then used by the compiler. For me, the node I added this line to was as below:

<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
   <AspnetCompilerPath>$(windir)\Microsoft.NET\Framework64\v4.0.30319</AspnetCompilerPath>
</PropertyGroup>

这篇关于的Visual Studio 2013调用32位aspnet_compiler,而不是64位单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆