似乎ProjectReference对项目文件列表进行排序 [英] Seems that ProjectReference sorts a list of project files

查看:73
本文介绍了似乎ProjectReference对项目文件列表进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出4个相互依赖的项目:

Given 4 projects that depend on each other like this:

D - > C - > B - > A

D -> C -> B -> A

使用

<ProjectReference />

如果我想使用这个msbuild xml文件构建所有这四个项目:

And If I want to build all four of those projects using this msbuild xml file:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
	<ItemGroup>
		<Libs Include="ClassLibrary*/*.csproj" />
	</ItemGroup>
	<Target Name="Build" >
		<MSBuild Projects="@(Libs)" StopOnFirstFailure="true" />
	</Target>
</Project>

我注意到MSBuild会自动从项目组中对项目列表进行排序,并按照正确的顺序构建它们! (我知道,因为我尝试了4个项目)很好!从什么情况开始呢?

I notice that MSBuild will sort the list of projects, from the itemgroup, automatically and build them in the correct order! (I know because I tried it with 4 projects) Nice! Since when was this the case?

或者我很幸运,因为它按照正确的顺序订购了它?

Or am I just lucky in that it ordered it in the correct order?

推荐答案

Chris P Johnson,

Hi Chris P Johnson,

感谢您在此发帖。

>>> 或者我很幸运,因为它按照正确的顺序订购了它?

>>>Or am I just lucky in that it ordered it in the correct order?

显然不是。这是因为你b $ b 依赖是使用< ProjectReference />实现的。在项目文件中

有两种表达项目到项目依赖关系的方法。

- 项目引用项目(添加引用 - >项目选项卡)[此机制也处理收集引用的输出文件]。对于.csproj,它会在项目文件中保留为
< ProjectReference> 项。

- 明确指定的依赖项(解决方案属性 - >项目依赖关系)[使用这种机制,你通常也会自己为引用的输出添加一个文件引用]。这将写入" projectdependencies " .sln中的
部分。

There are two kinds of ways to express project-to-project dependencies.
-- project to project references (Add Reference->Project tab) [this mechanism also handles gathering the referenced output file as well]. For .csproj, this is persisted as a <ProjectReference> item in the project file.
-- explicitly specified dependencies (Solution properties->Project Dependencies) [with this mechanism you would usually also add a File Reference to the referenced output yourself]. This writes the "projectdependencies" section in the .sln.

命令行上的MSBuild将使用两者来计算正确的构建顺序。如果两者都不存在,则其构建顺序未定义。在VS内部,如果两者都不存在,则构建顺序也是未定义的。

MSBuild on the command line will use both in order to figure the correct build order. If neither are present, its build order is undefined. Inside VS, if neither are present, the build order is also undefined.

因此,当你使用< ProjectReference />实现依赖时在项目文件中
MSBuild将根据< ProjectReference />排序项目列表,将自动生成并按正确的顺序构建它们!

So when you have the dependences are implemented using <ProjectReference /> in the project files, MSBuild will sort the list of projects according to the <ProjectReference />,will automatically and build them in the correct order!

希望这可以帮到你。

Hope this can help you.


这篇关于似乎ProjectReference对项目文件列表进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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