Skip to content

Commit 7636893

Browse files
rainersigwaldAndyGerlicher
authored andcommitted
Respect projects that say they only have one TFM (#1667)
Partially fixes dotnet/sdk#739. The first iteration of cross-targeting support code unconditionally queried each ProjectReference for the best TFM to build against, and then explicitly specified that TFM when building the reference. This caused a race condition when building a set of projects that had a single-TFM project and another project that had a reference to it. The entry point (probably .sln) build would build the referenced project with no TF specified, and then the referencing project would build it with an explicit TF specified. These two builds appeared different to the MSBuild engine (because they had different sets of global properties) and so were both executed, resulting in a race condition. The fix is in two parts: * Allow a project to report back through GetTargetFrameworkProperties that it only has one TF to build. * When a project reports that it has only one TF to build, issue its build request without specifying any TF. This commit is the latter.
1 parent b63c803 commit 7636893

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/XMakeTasks/Microsoft.Common.CurrentVersion.targets

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,6 +1569,10 @@ Copyright (C) Microsoft Corporation. All rights reserved.
15691569
<ItemGroup>
15701570
<_MSBuildProjectReferenceExistent Condition="'%(_MSBuildProjectReferenceExistent.Identity)' == '%(Identity)' and '$(_ProjectReferenceTargetFrameworkProperties)' != ''">
15711571
<SetTargetFramework>$(_ProjectReferenceTargetFrameworkProperties)</SetTargetFramework>
1572+
1573+
<UndefineProperties Condition="$(_ProjectReferenceTargetFrameworkProperties.Contains(`ProjectHasSingleTargetFramework=true`))">%(_MSBuildProjectReferenceExistent.UndefineProperties);TargetFramework;ProjectHasSingleTargetFramework</UndefineProperties>
1574+
<!-- Unconditionally remove the property that was set as a marker to indicate that for this call we should remove TargetFramework -->
1575+
<UndefineProperties Condition="!$(_ProjectReferenceTargetFrameworkProperties.Contains(`ProjectHasSingleTargetFramework=true`))">%(_MSBuildProjectReferenceExistent.UndefineProperties);ProjectHasSingleTargetFramework</UndefineProperties>
15721576
</_MSBuildProjectReferenceExistent>
15731577
</ItemGroup>
15741578

0 commit comments

Comments
 (0)