是什么导致MSBuild的行为因计算机而异? [英] What might cause MSBuild to behave differently from machine-to-machine?

查看:70
本文介绍了是什么导致MSBuild的行为因计算机而异?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C#程序(不是ASP.NET或与Web相关的程序),其平台目标是.NET v3.5的AnyCPU,该程序引用了32位第三方.dll.不幸的是,我在CI管道中也有几台艺术品"构建机器可以构建此程序.我正在尝试添加另一个,但是我不知道是什么允许它构建.

I have a C# program (not ASP.NET or even web-related) with platform AnyCPU targeting .NET v3.5 that references a 32-bit third-party .dll. Unfortunately, I also have several "work of art" build machines in our CI pipeline that build this program. I'm trying to add another one but I can't figure out what allows it to build.

每当我尝试在这台新机器上构建时,我都会得到

Whenever I try to build on this new machine, I get

LC:错误LC0000:无法加载文件或程序集" ASSEMBLY"或一个 它的依赖关系.试图用以下命令加载程序 格式错误.'

LC : error LC0000: 'Could not load file or assembly 'ASSEMBLY' or one of its dependencies. An attempt was made to load a program with an incorrect format.'

到目前为止,我唯一的线索是有人安装了一些不需要的程序(Visual Studio 2010,几个C ++运行时,Windows SDK等),但是这些程序不会破坏我的构建,我也不想轻易卸载这些东西.

So far my only lead is that someone's installed several unneeded programs (visual studio 2010, several C++ runtimes, Windows SDK, etc) but those shouldn't break my build and I don't want to uninstall things willy nilly.

这是可以在我的旧构建机器上运行但在我的新构建机器上失败的命令:

Here is the command which works on my old build machine and fails on my new one:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe /property:Configuration=release;Platform=AnyCPU;TargetFrameworkVersion=v3.5 Utilities\UtilityGUI\UtilityGUI.csproj

如果将Platform属性更改为x86,则可在两台计算机上使用.将其更改为x64会在两台计算机上将其破坏.

If I change the Platform property to x86 it works on both machines. Changing it to x64 breaks it on both machines.

可能是什么原因造成的?我检查了计算机上的msbuild.exe.config,并比较了SOFTWARE/Microsoft/VisualStudioSOFTWARE/Microsoft/MSBuild下的注册表.我不想更改代码,因为它可以在我的其他机器和尚未进行合并但无法在此机器上构建的分支上运行.

What could be causing this? I checked msbuild.exe.config on the machines and compared the registry under SOFTWARE/Microsoft/VisualStudio as well as SOFTWARE/Microsoft/MSBuild. I don't want to change code as it works on my other machines and branches that haven't had a merge yet couldn't build on this machine.

推荐答案

问题出在您的32位引用上.您不能将32位程序集加载到64位进程中.为什么不能专门针对x86?

The problem is with your 32-bit reference. You can't load a 32-bit assembly into a 64-bit process. Is there a reason why you can't target x86 exclusively?

关于为什么要在一台计算机上而不是另一台计算机上进行构建的原因,可能是一台计算机上的AnyCPU配置文件设置为首选32位,或者可能是成功构建的计算机实际上是32位机器,并且出于必要而将x86作为目标.无论哪种方式,在引用32位dll时都将无法生成x64构建.

As for why it's building on one machine and not the other, it may be that the AnyCPU profile on one machine is set to prefer 32-bit, or it may be that the machine that's successfully building is actually a 32-bit machine and is targeting x86 out of necessity. Either way, you won't be able to produce x64 builds when referencing a 32-bit dll.

这篇关于是什么导致MSBuild的行为因计算机而异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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