Skip to content

Commit 6fb9765

Browse files
authored
Fix IsRidAgnostic fallback logic (#8002)
Fixes #7995 Context #6924 changed how IsRidAgnostic works. Normally, the .NET SDK should set the IsRidAgnostic property (added in dotnet/sdk#21986). But when using an older version of the .NET SDK, there is fallback logic in the GetTargetFrameworksWithPlatformForSingleTargetFramework target to replicate the previous logic. However, this fallback logic was incorrect, as it was setting item metadata, but reading from the property to determine whether to set it to the default value. So if the property wasn't set, the IsRidAgnostic metadata would always be false. Testing Manual testing
1 parent fcc4789 commit 6fb9765

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/Tasks/Microsoft.Common.CurrentVersion.targets

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1964,14 +1964,16 @@ Copyright (C) Microsoft Corporation. All rights reserved.
19641964
<TargetPlatformMonikers Condition="'$(TargetPlatformMoniker)' == ''">None</TargetPlatformMonikers>
19651965
<AdditionalPropertiesFromProject>$(_AdditionalTargetFrameworkInfoProperties)</AdditionalPropertiesFromProject>
19661966

1967-
<!-- Determine whether a project is "RID agnostic" for each TargetFramework. "RID agnostic" means that global properties such as SelfContained and RuntimeIdentifier should
1968-
not flow across project references.
1969-
1970-
Generally this value will come from the IsRidAgnostic property set by the .NET SDK. If that's not set, then the fallback logic here will be that the project
1971-
is RID agnostic if it doesn't have RuntimeIdentifier or RuntimeIdentifiers properties set. -->
1967+
<!-- Determine whether a project is "RID agnostic" for each TargetFramework. "RID agnostic" means that global properties such as
1968+
SelfContained and RuntimeIdentifier should not flow across project references. The IsRidAgnostic metadata value is consumed in the
1969+
_GetProjectReferenceTargetFrameworkProperties target, where those properties are added to a project's UndefineProperties if
1970+
IsRidAgnostic is set.
1971+
1972+
Generally we set the IsRidAgnostic metadata based on the IsRidAgnostic property set by the .NET SDK. If that's not set, then the
1973+
fallback logic here will be that the project is RID agnostic if it doesn't have RuntimeIdentifier or RuntimeIdentifiers properties set. -->
19721974
<IsRidAgnostic>$(IsRidAgnostic)</IsRidAgnostic>
1973-
<IsRidAgnostic Condition=" '$(IsRidAgnostic)' == '' and '$(RuntimeIdentifier)' == '' and '$(RuntimeIdentifiers)' == '' ">true</IsRidAgnostic>
1974-
<IsRidAgnostic Condition=" '$(IsRidAgnostic)' == ''">false</IsRidAgnostic>
1975+
<IsRidAgnostic Condition=" '%(IsRidAgnostic)' == '' and '$(RuntimeIdentifier)' == '' and '$(RuntimeIdentifiers)' == '' ">true</IsRidAgnostic>
1976+
<IsRidAgnostic Condition=" '%(IsRidAgnostic)' == ''">false</IsRidAgnostic>
19751977

19761978
</_TargetFrameworkInfo>
19771979
</ItemGroup>

0 commit comments

Comments
 (0)