Skip to content

Commit

Permalink
Switch from IsRidAgnostic metadata to AcceptsRuntimeIdentifier property
Browse files Browse the repository at this point in the history
Also always treat SelfContained the same as RuntimeIdentifier as far as whether the properties should be allowed to flow across project references
  • Loading branch information
dsplaisted committed Nov 18, 2021
1 parent a5734c4 commit a169ace
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
4 changes: 1 addition & 3 deletions src/Tasks/Microsoft.Common.CrossTargeting.targets
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ Copyright (C) Microsoft Corporation. All rights reserved.
<TargetPlatformMonikers>@(_TargetFrameworkInfo->'%(TargetPlatformMonikers)')</TargetPlatformMonikers>
<AdditionalPropertiesFromProject>$(_AdditionalPropertiesFromProject)</AdditionalPropertiesFromProject>
<HasSingleTargetFramework>false</HasSingleTargetFramework>
<!-- indicate to caller that project is RID agnostic so that a global property RuntimeIdentifier value can be removed -->
<IsRidAgnostic>false</IsRidAgnostic>
<IsRidAgnostic Condition=" '$(RuntimeIdentifier)' == '' and '$(RuntimeIdentifiers)' == '' ">true</IsRidAgnostic>
<AcceptsRuntimeIdentifier>@(_TargetFrameworkInfo->'%(AcceptsRuntimeIdentifier)')</AcceptsRuntimeIdentifier>
<!-- Extract necessary information for SetPlatform negotiation -->
<!-- This target does not run for cpp projects. -->
<IsVcxOrNativeProj>false</IsVcxOrNativeProj>
Expand Down
32 changes: 18 additions & 14 deletions src/Tasks/Microsoft.Common.CurrentVersion.targets
Original file line number Diff line number Diff line change
Expand Up @@ -1844,17 +1844,12 @@ Copyright (C) Microsoft Corporation. All rights reserved.
<UndefineProperties>%(AnnotatedProjects.UndefineProperties);TargetFramework</UndefineProperties>
</AnnotatedProjects>

<!-- If the project is RID agnostic, undefine the RuntimeIdentifier property to avoid another evaluation. -->
<AnnotatedProjects Condition="'@(AnnotatedProjects)' == '%(Identity)' and '%(AnnotatedProjects.IsRidAgnostic)' == 'true'">
<UndefineProperties>%(AnnotatedProjects.UndefineProperties);RuntimeIdentifier</UndefineProperties>

<!-- Also undefine SelfContained property if it was defined on the command line. Otherwise a command such as
"dotnet build -r win-x64 -/-self-contained" would fail to build referenced projects, as they would have
SelfContained defined but no RuntimeIdentifier.
We only undefine this if the specific command-line option was used, in order to avoid breaking projects
that were passing /p:SelfContained=true on the command-line and relying on it flowing acress projects
(they were then setting the RuntimeIdentifier if SelfContained was true in their props files) -->
<UndefineProperties Condition="'$(_CommandLineDefinedSelfContained)' == 'true'">%(AnnotatedProjects.UndefineProperties);SelfContained</UndefineProperties>
<!-- Add RuntimeIdentifier and SelfContained to the list of global properties that should not flow to the referenced project,
unless the project is expecting those properties to flow.
We include SelfContained together with RuntimeIdentifier, because otherwise a referenced project could try to build with
SelfContained set to true but no RuntimeIdentifier set, which causes an error (for Exe projects). -->
<AnnotatedProjects Condition="'@(AnnotatedProjects)' == '%(Identity)' and '%(AnnotatedProjects.AcceptsRuntimeIdentifier)' != 'true'">
<UndefineProperties>%(AnnotatedProjects.UndefineProperties);RuntimeIdentifier;SelfContained</UndefineProperties>
</AnnotatedProjects>

<!--
Expand Down Expand Up @@ -1887,9 +1882,7 @@ Copyright (C) Microsoft Corporation. All rights reserved.
<TargetPlatformMonikers>@(_TargetFrameworkInfo->'%(TargetPlatformMonikers)')</TargetPlatformMonikers>
<AdditionalPropertiesFromProject>$(_AdditionalPropertiesFromProject)</AdditionalPropertiesFromProject>
<HasSingleTargetFramework>true</HasSingleTargetFramework>
<!-- indicate to caller that project is RID agnostic so that a global property RuntimeIdentifier value can be removed -->
<IsRidAgnostic>false</IsRidAgnostic>
<IsRidAgnostic Condition=" '$(RuntimeIdentifier)' == '' and '$(RuntimeIdentifiers)' == '' ">true</IsRidAgnostic>
<AcceptsRuntimeIdentifier>@(_TargetFrameworkInfo->'%(AcceptsRuntimeIdentifier)')</AcceptsRuntimeIdentifier>
<!-- Extract necessary information for SetPlatform negotiation -->
<IsVcxOrNativeProj Condition="'$(MSBuildProjectExtension)' == '.vcxproj' or '$(MSBuildProjectExtension)' == '.nativeproj'">true</IsVcxOrNativeProj>
<Platforms>$(Platforms)</Platforms>
Expand Down Expand Up @@ -1929,6 +1922,17 @@ Copyright (C) Microsoft Corporation. All rights reserved.
<TargetPlatformMonikers>$(TargetPlatformMoniker)</TargetPlatformMonikers>
<TargetPlatformMonikers Condition="'$(TargetPlatformMoniker)' == ''">None</TargetPlatformMonikers>
<AdditionalPropertiesFromProject>$(_AdditionalTargetFrameworkInfoProperties)</AdditionalPropertiesFromProject>

<!-- Determine whether a global RuntimeIdentifier property should flow to this project across project references.
We will let the property flow if any of the following are true:
- The AcceptsRuntimeIdentifier property is set to true (or really, any non-empty value except "false")
- The RuntimeIdentifier is set
- The RuntimeIdentifiers property is set
Otherwise, we will include RuntimeIdentifier (and SelfContained) in the list of global properties to remove across project references-->
<AcceptsRuntimeIdentifier>$(AcceptsRuntimeIdentifier)</AcceptsRuntimeIdentifier>
<AcceptsRuntimeIdentifier Condition=" '$(AcceptsRuntimeIdentifier)' == ''">true</AcceptsRuntimeIdentifier>
<AcceptsRuntimeIdentifier Condition=" '$(AcceptsRuntimeIdentifier)' == '' and '$(RuntimeIdentifier)' == '' and '$(RuntimeIdentifiers)' == '' ">false</AcceptsRuntimeIdentifier>

</_TargetFrameworkInfo>
</ItemGroup>

Expand Down

0 comments on commit a169ace

Please sign in to comment.