MSBuild 构建顺序

发布于 2024-09-04 14:25:05 字数 740 浏览 13 评论 0原文

看看微软的这篇文章,我有关于 SolutionToBuild 部分的问题。

<ItemGroup>
    <SolutionToBuild Include="$(SolutionRoot)\path\MySolution.sln />
    <SolutionToBuild Include="$(SolutionRoot)\Scribble\scribble.sln" />
    <SolutionToBuild Include="$(SolutionRoot)\HelloWorld\HelloWorld.sln" />
    <SolutionToBuild Include="$(SolutionRoot)\TestProject1\TestProject1.sln" />
</ItemGroup>

它说构建的顺序是由上面的顺序决定的。因此,例如,MySolution 将在 scribble 之前构建。

但是,如果 scribble 依赖 MySolution,这安全吗?例如,MySolution 输出一个或多个供 scribble 使用的 dll。如果 MySolution 和 scribble 同时更改,构建是否会等待 MySolution 完全编译后再移至下一个项目?

Looking at this article from MS, I have a question about the SolutionToBuild section.

<ItemGroup>
    <SolutionToBuild Include="$(SolutionRoot)\path\MySolution.sln />
    <SolutionToBuild Include="$(SolutionRoot)\Scribble\scribble.sln" />
    <SolutionToBuild Include="$(SolutionRoot)\HelloWorld\HelloWorld.sln" />
    <SolutionToBuild Include="$(SolutionRoot)\TestProject1\TestProject1.sln" />
</ItemGroup>

It says that the sequence of the build is determined by the order above. So, for example, MySolution would be built before scribble.

However, is this safe if scribble is dependant on MySolution? For example, MySolution outputs one or more dlls that are used by scribble. If MySolution and scribble are changed simultaneously, will the build wait for MySolution to be completely compiled before moving to the next project?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

初雪 2024-09-11 14:25:05

您可以尝试使用项目 SolutionToBuild 的其他元数据。有些使用递归,瞧!

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
    <SolutionToBuild Include="$(SolutionRoot)\Scribble\levelone.sln">
        <DependsOnSolutions>$(SolutionRoot)\Scribble\leveltwo.sln</DependsOnSolutions>
    </SolutionToBuild>        
    <SolutionToBuild Include="$(SolutionRoot)\Scribble\leveltwo.sln">
        <DependsOnSolutions>$(SolutionRoot)\Scribble\levelthree.sln;$(SolutionRoot)\TestProject1\TestProject1.sln</DependsOnSolutions>
    </SolutionToBuild>
    <SolutionToBuild Include="$(SolutionRoot)\Scribble\levelthree.sln" />
    <SolutionToBuild Include="$(SolutionRoot)\TestProject1\TestProject1.sln" />
</ItemGroup>

<Target Name="Build">
    <MSBuild Projects="$(MSBuildProjectFile)"
             Targets="BuildSolution"                 
             Properties="SolutionFullPath=%(SolutionToBuild.Identity)"/>
</Target>

<Target Name="BuildSolution">   
    <CreateItem Condition="'%(SolutionToBuild.Identity)'=='$(SolutionFullPath)'"
        Include="%(SolutionToBuild.DependsOnSolutions)">
        <Output TaskParameter="Include"
                ItemName="DependentSolutions" />
    </CreateItem>

    <Message Text="Building solution $(SolutionFullPath)..." />        
    <Message Text="Solution $(SolutionFullPath) depends on %(DependentSolutions.Identity)..." 
             Condition="'@(DependentSolutions)'!=''"/>
    <Message Text="Building dependent solutions..."
             Condition="'@(DependentSolutions)'!=''"/>

    <MSBuild Projects="$(MSBuildProjectFile)"
             Targets="BuildSolution"
             Properties="SolutionFullPath=%(DependentSolutions.Identity)"
             Condition="'@(DependentSolutions)'!=''"/>

    <!-- <MSBuild Projects="$(SolutionFullPath)" /> -->
    <Message Text="Building solution $(SolutionFullPath)... OK" />
</Target>
</Project>

You can try to use additional metadata for item SolutionToBuild. Some work with recursion and voilà!

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
    <SolutionToBuild Include="$(SolutionRoot)\Scribble\levelone.sln">
        <DependsOnSolutions>$(SolutionRoot)\Scribble\leveltwo.sln</DependsOnSolutions>
    </SolutionToBuild>        
    <SolutionToBuild Include="$(SolutionRoot)\Scribble\leveltwo.sln">
        <DependsOnSolutions>$(SolutionRoot)\Scribble\levelthree.sln;$(SolutionRoot)\TestProject1\TestProject1.sln</DependsOnSolutions>
    </SolutionToBuild>
    <SolutionToBuild Include="$(SolutionRoot)\Scribble\levelthree.sln" />
    <SolutionToBuild Include="$(SolutionRoot)\TestProject1\TestProject1.sln" />
</ItemGroup>

<Target Name="Build">
    <MSBuild Projects="$(MSBuildProjectFile)"
             Targets="BuildSolution"                 
             Properties="SolutionFullPath=%(SolutionToBuild.Identity)"/>
</Target>

<Target Name="BuildSolution">   
    <CreateItem Condition="'%(SolutionToBuild.Identity)'=='$(SolutionFullPath)'"
        Include="%(SolutionToBuild.DependsOnSolutions)">
        <Output TaskParameter="Include"
                ItemName="DependentSolutions" />
    </CreateItem>

    <Message Text="Building solution $(SolutionFullPath)..." />        
    <Message Text="Solution $(SolutionFullPath) depends on %(DependentSolutions.Identity)..." 
             Condition="'@(DependentSolutions)'!=''"/>
    <Message Text="Building dependent solutions..."
             Condition="'@(DependentSolutions)'!=''"/>

    <MSBuild Projects="$(MSBuildProjectFile)"
             Targets="BuildSolution"
             Properties="SolutionFullPath=%(DependentSolutions.Identity)"
             Condition="'@(DependentSolutions)'!=''"/>

    <!-- <MSBuild Projects="$(SolutionFullPath)" /> -->
    <Message Text="Building solution $(SolutionFullPath)... OK" />
</Target>
</Project>
罪#恶を代价 2024-09-11 14:25:05

您如何管理解决方案依赖性?您不是引用项目吗?我也对你们的一些解决方案的“同时”变化感到困惑。请澄清这些变化的性质。

到目前为止,您的问题的答案是:

  1. 不。它们可能会被一个接一个地编译,但它是否符合依赖关系?
  2. 是的。如果顺序是强制性的,则构建器将“等待”直到构建每个解决方案(成功或错误),然后再移动到下一个。

How do you manage solution dependency? Aren't you referencing projects instead? I'm also puzzled about the 'simultaneous' changes on some of your solutions. Please clarify the nature of these changes.

So far, the answers to your questions are:

  1. No. They may be compiled one after the other, but does it qualify for dependency?
  2. Yes. If the sequence is mandatory, the builder will 'wait' until each solution is built (either with success or error) before moving to the next.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文