MSBuild的建立与项目引用正确的项目而不是从解决方案 [英] MSBuild builds projects with project references correctly but not from solution

查看:420
本文介绍了MSBuild的建立与项目引用正确的项目而不是从解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我建立一个A.sln,其中包括2个项目B.csproj和C.csproj有它抛出引用错误在内部的MSBuild项目引用。但是,当我的MSBuild建设B.csproj和C.csproj分开它不会引发错误。而且也是建设A.sln在VS IDE还没有使用.NET 2.0框架抛出errors.I'm。请在用于构建SLN和projs脚本如下:

When i build a A.sln which includes 2 projects B.csproj and C.csproj which has internal project references it throws reference errors in MSBuild. But when i build B.csproj and C.csproj seperately in MSBuild it don't throw errors. And also building A.sln in VS IDE also don't throw errors.I'm using .NET 2.0 framework. Please find below the scripts used to build the sln and projs.

MSBuild "<path>/A.sln" /p:Configuration=Release /p:StartupObject="" /p:WarningLevel=4 /p:Optimize=true /t:rebuild /l:Filelogger,Microsoft.Build.Engine;logfile=F:\A.sln.log /verbosity:normal

MSBuild "<path>/B.csproj" /p:Configuration=Release /p:StartupObject="" /p:WarningLevel=4 /p:Optimize=true /t:rebuild /l:Filelogger,Microsoft.Build.Engine;logfile=F:\B.csproj.log /verbosity:normal 

MSBuild "<path>/C.csproj" /p:Configuration=Release /p:StartupObject="" /p:WarningLevel=4 /p:Optimize=true /t:rebuild /l:Filelogger,Microsoft.Build.Engine;logfile=F:\C.csproj.log /verbosity:normal

编辑:

所有抛出的错误是由code失踪refernces(均为项目引用)。我得到的只有三种类型的错误,就像如下。

All the errors thrown are from code for missing refernces(all are project references). I get only three type of errors like given below.

错误CS0012:类型X是指   在未引用的程序集。   您必须添加一个引用组件   'Y,版本= 2.0.0.0,文化=中立,   公钥= aad4cbe5d7c27078'。

error CS0012: The type 'X' is defined in an assembly that is not referenced. You must add a reference to assembly 'Y, Version=2.0.0.0, Culture=neutral, PublicKeyToken=aad4cbe5d7c27078'.

错误CS0234:类型或命名空间   命名X,在不存在   命名空间'Y'(是缺少程序   集引用?)

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

错误CS0246:类型或命名空间   命名'X'找不到(你   缺少using指令或程序   集引用?)

error CS0246: The type or namespace name 'X' could not be found (are you missing a using directive or an assembly reference?)

我清除了所有previously建从构建路径的dll从IDE和建设的MSBuild之前。但是IDE只是工作正常,并没有显示在Refrences部分项目的参考失踪指标。

I cleared all previously built dlls from build paths before building from both IDE and MSBuild. But IDE just works fine and don't show a reference missing indicator in "Refrences" section for the project.

没有在IDE中手动添加引用路径。

No reference paths added manually in IDE.

另一个更新:

我刚刚注意到,当我打开从溶液中两个项目,引用指向正确的IDE。但是,当我在IDE中打开该项目分开,缺少引用我提到发生的历史的MSBuild的小兵。非常奇怪的。

I just noticed that when i open both the projects from the solution, references are correctly pointing in IDE. But when i open the projects seperately in IDE, the missing references i mentioned occuring in MSBuild creeps up. Very wierd.

总结一下,

在MSBuild的Buiilding .proj - 好

Buiilding .proj in MSBuild - Good

在IDE Buiilding .proj - 错误

Buiilding .proj in IDE - Error

在MSBuild的Buiilding的.sln - 错误

Buiilding .sln in MSBuild - Error

在IDE Buiilding的.sln - 好

Buiilding .sln in IDE - Good

看起来很奇怪我。帮助很多很多AP preciated。

Looks very wierd for me. Help much much appreciated.

推荐答案

的MSBuild和VS都使用项目引用和项目依赖于选择的解决方案构建顺序。除此之外,它的未定义 - 以及两者之间通常是不同的。检查这两个都是正确的。项目依赖关系在解决方案的属性进行设置。 如果还是不行,仔细检查的GUID在你的项目中的项目引用匹配那些在溶液中。有时,重建该解决方案可以解决这些问题。

MSBuild and VS both use project references and project dependencies to choose the solution build order. Beyond that, it's undefined - and typically different between the two. Check both of these are correct. Project dependencies are set in the properties of your solution. If that doesn't work, double check the GUIDs in the project references in your projects match the ones in the solution. Sometimes recreating the solution can fix them.

这篇关于MSBuild的建立与项目引用正确的项目而不是从解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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