-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Double Evaluation Fix #2595
Double Evaluation Fix #2595
Changes from 6 commits
ba8fca1
ff79ea2
8729689
984f381
c36bfb3
bb44739
f066173
caf92b2
62094fd
21b9a95
15afc90
00e2059
e3ee36f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,19 @@ Copyright (C) Microsoft Corporation. All rights reserved. | |
|
||
<Import Project="$(CustomBeforeMicrosoftCommonCrossTargetingTargets)" Condition="'$(CustomBeforeMicrosoftCommonCrossTargetingTargets)' != '' and Exists('$(CustomBeforeMicrosoftCommonCrossTargetingTargets)')"/> | ||
|
||
<Target Name="GetTargetFrameworks" | ||
Returns="@(_ThisProjectBuildMetadata)"> | ||
<ItemGroup> | ||
<_ThisProjectBuildMetadata Include="$(MSBuildProjectFullPath)"> | ||
<TargetFrameworks Condition="'$(TargetFrameworks)' != ''">$(TargetFrameworks)</TargetFrameworks> | ||
<TargetFrameworks Condition="'$(TargetFrameworks)' == ''">$(TargetFramework)</TargetFrameworks> | ||
<HasSingleTargetFramework>true</HasSingleTargetFramework> | ||
<HasSingleTargetFramework Condition="'$(IsCrossTargetingBuild)' == 'true'">false</HasSingleTargetFramework> | ||
<IsRidAgnostic>true</IsRidAgnostic> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this hard-coded? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to get the SDK tests running with this change. cc @dsplaisted |
||
</_ThisProjectBuildMetadata> | ||
</ItemGroup> | ||
</Target> | ||
|
||
<Target Name="_ComputeTargetFrameworkItems" Returns="@(InnerOutput)"> | ||
<ItemGroup> | ||
<_TargetFramework Include="$(TargetFrameworks)" /> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1512,21 +1512,7 @@ Copyright (C) Microsoft Corporation. All rights reserved. | |
|
||
</Target> | ||
|
||
<!-- | ||
==================================================================================== | ||
_GetProjectReferenceTargetFrameworkProperties | ||
|
||
Builds the GetTargetFrameworkProperties target of all existent project references, | ||
passing $(TargetFrameworkMoniker) as $(ReferringTargetFramework) and sets the | ||
SetTargetFramework metadata of the project reference to the value that is returned. | ||
|
||
This allows a cross-targeting project to select how it should be configured to | ||
build against the most appropriate target for the referring target framework. | ||
|
||
====================================================================================== | ||
--> | ||
<Target Name="_GetProjectReferenceTargetFrameworkProperties" | ||
Outputs="%(_MSBuildProjectReferenceExistent.Identity)"> | ||
<Target Name="_ComputeProjectReferenceTargetFrameworkMatches" BeforeTargets="_GetProjectReferenceTargetFrameworkProperties"> | ||
<!-- | ||
Honor SkipGetTargetFrameworkProperties=true metadata on project references | ||
to mean that the project reference is known not to target multiple frameworks | ||
|
@@ -1558,6 +1544,61 @@ Copyright (C) Microsoft Corporation. All rights reserved. | |
</_MSBuildProjectReferenceExistent> | ||
</ItemGroup> | ||
|
||
<!-- Get reference target framework lists --> | ||
<MSBuild | ||
Projects="@(_MSBuildProjectReferenceExistent)" | ||
Targets="GetTargetFrameworks" | ||
BuildInParallel="$(BuildInParallel)" | ||
Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform)" | ||
ContinueOnError="!$(BuildingProject)" | ||
RemoveProperties="%(_MSBuildProjectReferenceExistent.GlobalPropertiesToRemove);TargetFramework;RuntimeIdentifier" | ||
Condition="'%(_MSBuildProjectReferenceExistent.SkipGetTargetFrameworkProperties)' != 'true'" | ||
SkipNonexistentTargets="true"> | ||
<Output TaskParameter="TargetOutputs" ItemName="_ProjectReferenceTargetFrameworkPossibilities" /> | ||
</MSBuild> | ||
|
||
<!-- For each reference, get closest match --> | ||
<AssignReferencePropertiesTask AnnotatedProjectReferences="@(_ProjectReferenceTargetFrameworkPossibilities)" | ||
CurrentProjectTargetFramework="$(TargetFrameworkMoniker)" | ||
Condition="'@(_ProjectReferenceTargetFrameworkPossibilities->Count())' != '0'"> | ||
<Output ItemName="AnnotatedProjects" TaskParameter="AssignedProjects" /> | ||
</AssignReferencePropertiesTask> | ||
|
||
<ItemGroup> | ||
<_MSBuildProjectReferenceExistent Remove="@(_MSBuildProjectReferenceExistent)" /> | ||
<_MSBuildProjectReferenceExistent Include="@(AnnotatedProjects)" /> | ||
</ItemGroup> | ||
|
||
<!-- Assign metadata to ProjectReferences, including skipping old-style TF checks. --> | ||
</Target> | ||
|
||
<Target Name="GetTargetFrameworks" | ||
Returns="@(_ThisProjectBuildMetadata)"> | ||
<ItemGroup> | ||
<_ThisProjectBuildMetadata Include="$(MSBuildProjectFullPath)"> | ||
<TargetFrameworks Condition="'$(TargetFrameworks)' != ''">$(TargetFrameworks)</TargetFrameworks> | ||
<TargetFrameworks Condition="'$(TargetFrameworks)' == ''">$(TargetFramework)</TargetFrameworks> | ||
<HasSingleTargetFramework>true</HasSingleTargetFramework> | ||
<HasSingleTargetFramework Condition="'$(IsCrossTargetingBuild)' == 'true'">false</HasSingleTargetFramework> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is always going to be false when we land in the non-cross-targeting version of GetTargetFrameworks. |
||
<IsRidAgnostic>true</IsRidAgnostic> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto |
||
</_ThisProjectBuildMetadata> | ||
</ItemGroup> | ||
</Target> | ||
|
||
<!-- | ||
==================================================================================== | ||
_GetProjectReferenceTargetFrameworkProperties | ||
|
||
Builds the GetTargetFrameworkProperties target of all existent project references, | ||
passing $(TargetFrameworkMoniker) as $(ReferringTargetFramework) and sets the | ||
SetTargetFramework metadata of the project reference to the value that is returned. | ||
|
||
This allows a cross-targeting project to select how it should be configured to | ||
build against the most appropriate target for the referring target framework. | ||
|
||
====================================================================================== | ||
--> | ||
<Target Name="_GetProjectReferenceTargetFrameworkProperties"> | ||
<!-- | ||
Select the moniker to send to each project reference if not already set. NugetTargetMoniker (NTM) is preferred by default over | ||
TargetFrameworkMoniker (TFM) because it is required to disambiguate the UWP case where TFM is fixed at .NETCore,Version=v5.0 and | ||
|
@@ -1570,38 +1611,54 @@ Copyright (C) Microsoft Corporation. All rights reserved. | |
</PropertyGroup> | ||
|
||
<MSBuild | ||
Projects="%(_MSBuildProjectReferenceExistent.Identity)" | ||
Projects="@(_MSBuildProjectReferenceExistent)" | ||
Targets="GetTargetFrameworkProperties" | ||
BuildInParallel="$(BuildInParallel)" | ||
Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform); ReferringTargetFramework=$(ReferringTargetFrameworkForProjectReferences)" | ||
ContinueOnError="!$(BuildingProject)" | ||
RemoveProperties="%(_MSBuildProjectReferenceExistent.GlobalPropertiesToRemove);TargetFramework;RuntimeIdentifier" | ||
Condition="'%(_MSBuildProjectReferenceExistent.SkipGetTargetFrameworkProperties)' != 'true'"> | ||
|
||
<Output TaskParameter="TargetOutputs" PropertyName="_ProjectReferenceTargetFrameworkProperties" /> | ||
<Output TaskParameter="TargetOutputs" ItemName="_ProjectReferenceTargetFrameworkProperties" /> | ||
</MSBuild> | ||
|
||
<ItemGroup> | ||
<_MSBuildProjectReferenceExistent Condition="'%(_MSBuildProjectReferenceExistent.Identity)' == '%(Identity)' and '$(_ProjectReferenceTargetFrameworkProperties)' != ''"> | ||
<SetTargetFramework>$(_ProjectReferenceTargetFrameworkProperties)</SetTargetFramework> | ||
<!-- Backward compat: extract metadata for properties to set from a semicolon-delimited return value --> | ||
<_ProjectReferenceTargetFrameworkProperties | ||
Condition="'@(_ProjectReferenceTargetFrameworkProperties->Count())' > '1' and '%(_ProjectReferenceTargetFrameworkProperties.OriginalItemSpec)' != ''"> | ||
<DelimitedStringReturn>@(_ProjectReferenceTargetFrameworkProperties)</DelimitedStringReturn> | ||
</_ProjectReferenceTargetFrameworkProperties> | ||
<_ProjectReferenceTargetFrameworkProperties | ||
Include="%(_ProjectReferenceTargetFrameworkProperties.OriginalItemSpec)" | ||
Condition="'%(_ProjectReferenceTargetFrameworkProperties.DelimitedStringReturn)' != ''"> | ||
<OriginalItemSpec>%(_ProjectReferenceTargetFrameworkProperties.OriginalItemSpec)</OriginalItemSpec> | ||
<DesiredTargetFrameworkProperties>$([System.String]::Copy('%(_ProjectReferenceTargetFrameworkProperties.DelimitedStringReturn)').Replace('ProjectHasSingleTargetFramework=true','').Replace('ProjectHasSingleTargetFramework=false','').Replace('ProjectIsRidAgnostic=true','').TrimEnd(';'))</DesiredTargetFrameworkProperties> | ||
<HasSingleTargetFramework>$([System.String]::Copy('%(_ProjectReferenceTargetFrameworkProperties.DelimitedStringReturn)').Contains('ProjectHasSingleTargetFramework=true'))</HasSingleTargetFramework> | ||
<IsRidAgnostic>$([System.String]::Copy('%(_ProjectReferenceTargetFrameworkProperties.DelimitedStringReturn)').Contains('ProjectIsRidAgnostic=true'))</IsRidAgnostic> | ||
</_ProjectReferenceTargetFrameworkProperties> | ||
<_ProjectReferenceTargetFrameworkProperties | ||
Remove="@(_ProjectReferenceTargetFrameworkProperties)" | ||
Condition="'%(_ProjectReferenceTargetFrameworkProperties.DelimitedStringReturn)' != ''" /> | ||
|
||
<!-- Build an item that has Identity matching _MSBuildProjectReferenceExistent and metadata for properties to set. --> | ||
<_ProjectReferencesWithTargetFrameworkProperties | ||
Include="@(_ProjectReferenceTargetFrameworkProperties->'%(OriginalItemSpec)')" /> | ||
|
||
<!-- Set the project's returned TargetFramework --> | ||
<_MSBuildProjectReferenceExistent Condition="'@(_ProjectReferencesWithTargetFrameworkProperties)' == '%(Identity)' and '@(_ProjectReferencesWithTargetFrameworkProperties->'%(HasSingleTargetFramework)')' != 'true'"> | ||
<SetTargetFramework>@(_ProjectReferencesWithTargetFrameworkProperties->'%(DesiredTargetFrameworkProperties)')</SetTargetFramework> | ||
</_MSBuildProjectReferenceExistent> | ||
|
||
<UndefineProperties Condition="$(_ProjectReferenceTargetFrameworkProperties.Contains(`ProjectHasSingleTargetFramework=true`))">%(_MSBuildProjectReferenceExistent.UndefineProperties);TargetFramework;ProjectHasSingleTargetFramework</UndefineProperties> | ||
<!-- Unconditionally remove the property that was set as a marker to indicate that for this call we should remove TargetFramework --> | ||
<UndefineProperties Condition="!$(_ProjectReferenceTargetFrameworkProperties.Contains(`ProjectHasSingleTargetFramework=true`))">%(_MSBuildProjectReferenceExistent.UndefineProperties);ProjectHasSingleTargetFramework</UndefineProperties> | ||
<!-- If the project has only one TF, don't specify it. It will go directly to the inner build anyway and we don't want to redundantly specify a global property, which can cause a race. --> | ||
<_MSBuildProjectReferenceExistent Condition="'@(_ProjectReferencesWithTargetFrameworkProperties)' == '%(Identity)' and '@(_ProjectReferencesWithTargetFrameworkProperties->'%(HasSingleTargetFramework)')' == 'true'"> | ||
<UndefineProperties>@(_MSBuildProjectReferenceExistent->'%(UndefineProperties)');TargetFramework</UndefineProperties> | ||
</_MSBuildProjectReferenceExistent> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<_MSBuildProjectReferenceExistent Condition="'%(_MSBuildProjectReferenceExistent.Identity)' == '%(Identity)' and '$(_ProjectReferenceTargetFrameworkProperties)' != ''"> | ||
<UndefineProperties Condition="$(_ProjectReferenceTargetFrameworkProperties.Contains(`ProjectIsRidAgnostic=true`))">%(_MSBuildProjectReferenceExistent.UndefineProperties);RuntimeIdentifier;ProjectIsRidAgnostic</UndefineProperties> | ||
<!-- Unconditionally remove the property that was set as a marker to indicate that for this call we should remove RuntimeIdentifier --> | ||
<UndefineProperties Condition="!$(_ProjectReferenceTargetFrameworkProperties.Contains(`ProjectIsRidAgnostic=true`))">%(_MSBuildProjectReferenceExistent.UndefineProperties);ProjectIsRidAgnostic</UndefineProperties> | ||
<!-- If the project has only one RID, assume it's compatible with the current project and don't pass this one along. --> | ||
<_MSBuildProjectReferenceExistent Condition="'@(_ProjectReferencesWithTargetFrameworkProperties)' == '%(Identity)' and '@(_ProjectReferencesWithTargetFrameworkProperties->'%(IsRidAgnostic)')' == 'true'"> | ||
<UndefineProperties>@(_MSBuildProjectReferenceExistent->'%(UndefineProperties)');RuntimeIdentifier</UndefineProperties> | ||
</_MSBuildProjectReferenceExistent> | ||
</ItemGroup> | ||
|
||
<PropertyGroup> | ||
<_ProjectReferenceTargetFrameworkProperties /> | ||
</PropertyGroup> | ||
</Target> | ||
|
||
<!-- | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the changes to this file up-to-date after the changes to the protocol and interface with NuGet that were made in this PR?