Skip to content

Commit

Permalink
Use IsRidAgnostic instead of AcceptsRuntimeIdentifier
Browse files Browse the repository at this point in the history
  • Loading branch information
dsplaisted committed Aug 12, 2022
1 parent e2297ee commit c81cb50
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ protected override void ExecuteCore()

bool selfContainedIsGlobalProperty = BuildEngine6.GetGlobalProperties().ContainsKey("SelfContained");

bool projectAcceptsRuntimeIdentifier = false;
if (projectAdditionalProperties.TryGetValue("AcceptsRuntimeIdentifier", out string acceptsRID) &&
bool.TryParse(acceptsRID, out bool acceptsRIDParseResult))
bool projectIsRidAgnostic = true;
if (projectAdditionalProperties.TryGetValue("IsRidAgnostic", out string isRidAgnostic) &&
bool.TryParse(isRidAgnostic, out bool isRidAgnosticParseResult))
{
projectAcceptsRuntimeIdentifier = acceptsRIDParseResult;
projectIsRidAgnostic = isRidAgnosticParseResult;
}

if (selfContainedIsGlobalProperty && projectAcceptsRuntimeIdentifier)
if (selfContainedIsGlobalProperty && !projectIsRidAgnostic)
{
// If AcceptsRuntimeIdentifier is true for the project, and SelfContained was set as a global property,
// If a project is NOT RID agnostic, and SelfContained was set as a global property,
// then the SelfContained value will flow across the project reference when we go to build it, despite the
// fact that we ignored it when doing the GetTargetFrameworks negotiation.
referencedProjectIsSelfContained = SelfContained;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,13 @@ Copyright (c) .NET Foundation. All rights reserved.
<PredefinedCulturesOnly Condition="'$(PredefinedCulturesOnly)' == '' and '$(InvariantGlobalization)' == 'true'">true</PredefinedCulturesOnly>
</PropertyGroup>

<!-- Set the AcceptsRuntimeIdentifier property if this project should accept global RuntimeIdentifier and SelfContained
<!-- Set the IsRidAgnostic property if this project should NOT accept global RuntimeIdentifier and SelfContained
property values from referencing projects. -->
<PropertyGroup Condition="'$(AcceptsRuntimeIdentifier)' == '' And '$(IsTestProject)' != 'true'">
<AcceptsRuntimeIdentifier Condition="'$(_IsExecutable)' == 'true' Or
'$(RuntimeIdentifier)' != '' Or
'$(RuntimeIdentifiers)' != ''">true</AcceptsRuntimeIdentifier>
<PropertyGroup Condition="'$(IsRidAgnostic)' == ''">
<IsRidAgnostic Condition="('$(_IsExecutable)' == 'true' And '$(IsTestProject)' != 'true') Or
'$(RuntimeIdentifier)' != '' Or
'$(RuntimeIdentifiers)' != ''">false</IsRidAgnostic>
<IsRidAgnostic Condition="'$(IsRidAgnostic)' == ''">true</IsRidAgnostic>
</PropertyGroup>

<!-- Opt into .NET Core resource-serialization strategy by default when targeting frameworks
Expand Down Expand Up @@ -1077,6 +1078,7 @@ Copyright (c) .NET Foundation. All rights reserved.
<ItemGroup>
<AdditionalTargetFrameworkInfoProperty Include="SelfContained"/>
<AdditionalTargetFrameworkInfoProperty Include="_IsExecutable"/>
<AdditionalTargetFrameworkInfoProperty Include="IsRidAgnostic"/>
<AdditionalTargetFrameworkInfoProperty Include="ShouldBeValidatedAsExecutableReference"/>
</ItemGroup>

Expand Down

0 comments on commit c81cb50

Please sign in to comment.