Visual Studio生成成功,MSBuild失败 [英] Visual Studio build successful, MSBuild fails

查看:211
本文介绍了Visual Studio生成成功,MSBuild失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用MSBUILD从命令行清理并重建具有多个项目的解决方案文件.由于某种原因,我的构建失败(大约10%的已构建项目失败),并且我遇到了多个错误,它们看起来都像这样:

I am trying to clean and rebuild a solution file with multiple projects from the command line using MSBUILD. For some reason my build fails (about 10% of the built projects fail) and I get multiple errors which all look like:

错误CS0234:类型或名称空间名称'foo'在名称空间'bar'中不存在(您是否缺少程序集引用?)

error CS0234: The type or namespace name 'foo' does not exist in the namespace 'bar' (are you missing an assembly reference?)

现在,如果我使用完全相同的配置从Visual Studio 2010中清除并重建相同的解决方案文件,则它将成功构建且没有错误.

Now if I clean and rebuild the same solution file from Visual Studio 2010 with the exact same configurations it will build successfully with no errors.

Visual Studio的MSBuild的设置或配置是否存在需要更改的,我不知道的差异?

Is there a difference in the setup or configuration of MSBuild from Visual Studio that needs to be changed that I am not aware of?

推荐答案

我只需要解决此问题,事实证明,msbuild喜欢将已构建的二进制文件移至binaries \ release目录中,并引用这些文件而不是项目本身当它构建事物时.构建后,它将文件复制到该目录.这就解释了为什么它可以在Visual Studio中而不是在msbuild中工作(我目前正在使用TFS 1010).

I just had to deal with this issue and it turns out that msbuild likes to move built binaries into the binaries\release directory and reference those instead of the projects themselves when it builds things. After building it copies the files to this directory. This explains why it works in visual studio and not msbuild (I'm currently using TFS 1010).

在我的情况下,我有一个旧的dll二进制版本,该文件在一个本应生成正确文件的项目之后被引用.旧的(二进制)正在覆盖新的(从源构建),因为引用二进制的解决方案是在构建的稍后版本中构建的.

In my case I had an old binary version of a dll being referenced by a project that was being built after the one that should have generated the correct file. The old one (binary) was overwriting the new one (built from source) as the solution referencing the binary one was being built later in the build.

这篇关于Visual Studio生成成功,MSBuild失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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