MSbuild task fails because “Any CPU” solution is built out of order

后端 未结 4 836
臣服心动
臣服心动 2021-01-14 08:31

I have two solutions to build in Teambuild, one is the application itself, the other one is the WiX installer. I want to build the application using \"Any CPU\" build config

相关标签:
4条回答
  • 2021-01-14 08:45

    I've just posted a simliar question, because it seems like the same issue but without any relation to AnyCPU. Was this ever resolved?

    Why does Tfs2010 build my Wix project before anything else?

    0 讨论(0)
  • 2021-01-14 08:50

    The issue here is that Any CPU is treated slightly differently, by convention, than other configurations - it is left out of output directory hierarchies, for example. In the Team Build targets file, then, there is a target called ComputeConfigurationList:

    <ItemGroup>
      <!-- ConfigurationList for any Platform but Any CPU -->
      <ConfigurationList Condition=" '%(ConfigurationToBuild.PlatformToBuild)' != 'Any CPU' " Include="$(MSBuildProjectFile)">
        <Properties>Configuration=%(ConfigurationToBuild.FlavorToBuild);Platform=%(ConfigurationToBuild.PlatformToBuild);TeamBuildOutDir=$(BinariesRoot)\%(ConfigurationToBuild.PlatformToBuild)\%(ConfigurationToBuild.FlavorToBuild)\;TeamBuildPublishDir=$(BinariesRoot)\%(ConfigurationToBuild.PlatformToBuild)\%(ConfigurationToBuild.FlavorToBuild)\</Properties>
      </ConfigurationList>
      <!-- ConfigurationList for Any CPU Platform -->
      <ConfigurationList Condition=" '%(ConfigurationToBuild.PlatformToBuild)' == 'Any CPU' " Include="$(MSBuildProjectFile)">
        <Properties>Configuration=%(ConfigurationToBuild.FlavorToBuild);Platform=%(ConfigurationToBuild.PlatformToBuild);TeamBuildOutDir=$(BinariesRoot)\%(ConfigurationToBuild.FlavorToBuild)\;TeamBuildPublishDir=$(BinariesRoot)\%(ConfigurationToBuild.FlavorToBuild)\</Properties>
      </ConfigurationList>
    </ItemGroup>
    

    This target processes the incoming ConfigurationToBuild item group in two batches - Any CPU and everything else. The resulting ConfigurationList item group is thus sorted differently than the original ConfigurationToBuild item group, with all the Any CPU configurations coming after all the non Any CPU configurations.

    The workaround, if the order of your configurations is important, is to define a new solution configuration for all of your solutions - see the blog post referenced above for instructions on this. For example, you could define a configuration called TFS that is based on Any CPU for your Any CPU solutions, on Win32 for those solutions, etc. Then in your TfsBuild.proj file you would only include this one configuration in your ConfigurationToBuild item group. This will have the nice side effect of getting rid of the various "invalid configuration" warnings you are probably getting right now when TFS Build tries to build your Win32 configurations for Any CPU and vice versa.

    0 讨论(0)
  • 2021-01-14 08:52

    Project Build Order may be set for projects belonging to the same solution. In this case, for unrelated reasons the projects need to belong to 2 different solutions.

    I've discovered here that a C# project in a "Mixed Platforms" solution will build as "Any CPU", so the solution is to always use "Mixed Platforms" in the Teambuild project file.

    0 讨论(0)
  • 2021-01-14 09:07

    Ok, I'm not sure if it's the same with Teambuild but What about setting the build order of the projects via "Project -> Project Build Order"?

    0 讨论(0)
提交回复
热议问题