-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Traversal targets for cross-targeting #1018
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
644ce2c
Add initial traversal targets
nguerrera 867523f
Establish protocol for P2P references to cross-targeted projects
nguerrera a3ed352
Remove condition which breaks rebuild
nguerrera 7930d2e
Rename property to match target
nguerrera a52aa1f
Rename Traversal to CrossTargeting
nguerrera File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!-- | ||
*********************************************************************************************** | ||
Microsoft.Common.CrossTargeting.targets | ||
|
||
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have | ||
created a backup copy. Incorrect changes to this file will make it | ||
impossible to load or build your projects from the command-line or the IDE. | ||
|
||
Copyright (C) Microsoft Corporation. All rights reserved. | ||
*********************************************************************************************** | ||
--> | ||
|
||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(CoreCrossTargetingTargetsPath)" | ||
Condition="'$(CoreCrossTargetingTargetsPath)' != '' and Exists('$(CoreCrossTargetingTargetsPath)')" /> | ||
</Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -886,12 +886,12 @@ Copyright (C) Microsoft Corporation. All rights reserved. | |
|
||
<Target Name="BuildGenerateSources" DependsOnTargets="BuildGenerateSourcesTraverse;$(BuildGenerateSourcesAction)" /> | ||
|
||
<Target Name="BuildGenerateSourcesTraverse" DependsOnTargets="AssignProjectConfiguration;_SplitProjectReferencesByFileExistence"> | ||
<Target Name="BuildGenerateSourcesTraverse" DependsOnTargets="PrepareProjectReferences"> | ||
<MSBuild | ||
Projects="@(_MSBuildProjectReferenceExistent)" | ||
Targets="BuildGenerateSources" | ||
BuildInParallel="$(BuildInParallel)" | ||
Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform)" | ||
Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform); %(_MSBuildProjectReferenceExistent.SetTargetFramework);" | ||
Condition="'$(BuildPassReferences)' == 'true' and '@(ProjectReferenceWithConfiguration)' != '' and '@(_MSBuildProjectReferenceExistent)' != '' and '%(_MSBuildProjectReferenceExistent.BuildReference)' == 'true'" | ||
ContinueOnError="!$(BuildingProject)" | ||
RemoveProperties="%(_MSBuildProjectReferenceExistent.GlobalPropertiesToRemove)"> | ||
|
@@ -911,12 +911,12 @@ Copyright (C) Microsoft Corporation. All rights reserved. | |
|
||
<Target Name="BuildCompile" DependsOnTargets="BuildCompileTraverse;$(BuildCompileAction)" /> | ||
|
||
<Target Name="BuildCompileTraverse" DependsOnTargets="AssignProjectConfiguration;_SplitProjectReferencesByFileExistence"> | ||
<Target Name="BuildCompileTraverse" DependsOnTargets="PrepareProjectReferences"> | ||
<MSBuild | ||
Projects="@(_MSBuildProjectReferenceExistent)" | ||
Targets="BuildCompile" | ||
BuildInParallel="$(BuildInParallel)" | ||
Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform)" | ||
Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform); %(_MSBuildProjectReferenceExistent.SetTargetFramework)" | ||
Condition="'$(BuildPassReferences)' == 'true' and '@(ProjectReferenceWithConfiguration)' != '' and '@(_MSBuildProjectReferenceExistent)' != '' and '%(_MSBuildProjectReferenceExistent.BuildReference)' == 'true'" | ||
ContinueOnError="!$(BuildingProject)" | ||
RemoveProperties="%(_MSBuildProjectReferenceExistent.GlobalPropertiesToRemove)"> | ||
|
@@ -936,12 +936,12 @@ Copyright (C) Microsoft Corporation. All rights reserved. | |
|
||
<Target Name="BuildLink" DependsOnTargets="BuildLinkTraverse;$(BuildLinkAction)" /> | ||
|
||
<Target Name="BuildLinkTraverse" DependsOnTargets="AssignProjectConfiguration;_SplitProjectReferencesByFileExistence" > | ||
<Target Name="BuildLinkTraverse" DependsOnTargets="PrepareProjectReferences" > | ||
<MSBuild | ||
Projects="@(_MSBuildProjectReferenceExistent)" | ||
Targets="BuildLink" | ||
BuildInParallel="$(BuildInParallel)" | ||
Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform)" | ||
Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform); %(_MSBuildProjectReferenceExistent.SetTargetFramework)" | ||
Condition="'$(BuildPassReferences)' == 'true' and '@(ProjectReferenceWithConfiguration)' != '' and '@(_MSBuildProjectReferenceExistent)' != '' and '%(_MSBuildProjectReferenceExistent.BuildReference)' == 'true'" | ||
ContinueOnError="!$(BuildingProject)" | ||
RemoveProperties="%(_MSBuildProjectReferenceExistent.GlobalPropertiesToRemove)"> | ||
|
@@ -1489,6 +1489,81 @@ 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)"> | ||
<MSBuild | ||
Projects="%(_MSBuildProjectReferenceExistent.Identity)" | ||
Targets="GetTargetFrameworkProperties" | ||
BuildInParallel="$(BuildInParallel)" | ||
Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform); ReferringTargetFramework=$(TargetFrameworkMoniker)" | ||
ContinueOnError="!$(BuildingProject)" | ||
RemoveProperties="%(_MSBuildProjectReferenceExistent.GlobalPropertiesToRemove)"> | ||
|
||
<Output TaskParameter="TargetOutputs" PropertyName="_ProjectReferenceTargetFrameworkProperties" /> | ||
</MSBuild> | ||
|
||
<ItemGroup> | ||
<_MSBuildProjectReferenceExistent Condition="'%(_MSBuildProjectReferenceExistent.Identity)' == '%(Identity)'"> | ||
<SetTargetFramework>$(_ProjectReferenceTargetFrameworkProperties)</SetTargetFramework> | ||
</_MSBuildProjectReferenceExistent> | ||
</ItemGroup> | ||
|
||
<PropertyGroup> | ||
<_ProjectReferenceTargetFrameworkProperties /> | ||
</PropertyGroup> | ||
</Target> | ||
|
||
<!-- | ||
============================================================ | ||
GetTargetFrameworkProperties | ||
|
||
Overrridden by cross-targeting projects to return the set of | ||
properties (in the form "key1=value1;...keyN=valueN") needed | ||
to build it with the best target for the referring project's | ||
target framework. | ||
|
||
The referring project's $(TargetFrameworkMoniker) is passed | ||
in as $(ReferringTargetFramework) | ||
--> | ||
<Target Name="GetTargetFrameworkProperties" /> | ||
|
||
<!-- | ||
============================================================ | ||
PrepareProjectReferences | ||
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. This is a nice improvement 👍 |
||
|
||
Prepares project references for consumption by other targets. | ||
|
||
[IN] | ||
@(ProjectReference) - The list of project references. | ||
|
||
[OUT] | ||
@(ProjectReferenceWithConfiguration) - Project references with apporpriate metadata | ||
@(_MSBuildProjectReferenceExistent) - Subset of @(ProjectReferenceWithConfiguration) that exist | ||
with added SetTargetFramework metadata for cross-targeting | ||
@(_MSBuildProjectReferenceNonExistent) - Subset of @(ProjectReferenceWithConfiguration) that do not exist | ||
============================================================ | ||
--> | ||
<PropertyGroup> | ||
<PrepareProjectReferencesDependsOn> | ||
AssignProjectConfiguration; | ||
_SplitProjectReferencesByFileExistence; | ||
_GetProjectReferenceTargetFrameworkProperties | ||
</PrepareProjectReferencesDependsOn> | ||
</PropertyGroup> | ||
<Target Name="PrepareProjectReferences" DependsOnTargets="$(PrepareProjectReferencesDependsOn)" /> | ||
|
||
<!-- | ||
============================================================ | ||
ResolveProjectReferences | ||
|
@@ -1516,7 +1591,7 @@ Copyright (C) Microsoft Corporation. All rights reserved. | |
|
||
<Target | ||
Name="ResolveProjectReferences" | ||
DependsOnTargets="AssignProjectConfiguration;_SplitProjectReferencesByFileExistence" | ||
DependsOnTargets="PrepareProjectReferences" | ||
Returns="@(_ResolvedNativeProjectReferencePaths);@(_ResolvedProjectReferencePaths)"> | ||
|
||
<!-- | ||
|
@@ -1531,7 +1606,7 @@ Copyright (C) Microsoft Corporation. All rights reserved. | |
Projects="@(_MSBuildProjectReferenceExistent)" | ||
Targets="GetTargetPath" | ||
BuildInParallel="$(BuildInParallel)" | ||
Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform)" | ||
Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform); %(_MSBuildProjectReferenceExistent.SetTargetFramework)" | ||
Condition="'%(_MSBuildProjectReferenceExistent.BuildReference)' == 'true' and '@(ProjectReferenceWithConfiguration)' != '' and ('$(BuildingInsideVisualStudio)' == 'true' or '$(BuildProjectReferences)' != 'true') and '$(VisualStudioVersion)' != '10.0' and '@(_MSBuildProjectReferenceExistent)' != ''" | ||
ContinueOnError="!$(BuildingProject)" | ||
RemoveProperties="%(_MSBuildProjectReferenceExistent.GlobalPropertiesToRemove)"> | ||
|
@@ -1558,7 +1633,7 @@ Copyright (C) Microsoft Corporation. All rights reserved. | |
Projects="@(_MSBuildProjectReferenceExistent)" | ||
Targets="%(_MSBuildProjectReferenceExistent.Targets);GetTargetPath" | ||
BuildInParallel="$(BuildInParallel)" | ||
Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform)" | ||
Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform); %(_MSBuildProjectReferenceExistent.SetTargetFramework)" | ||
Condition="'%(_MSBuildProjectReferenceExistent.BuildReference)' == 'true' and '@(ProjectReferenceWithConfiguration)' != '' and ('$(BuildingInsideVisualStudio)' == 'true' or '$(BuildProjectReferences)' != 'true') and '$(VisualStudioVersion)' == '10.0' and '@(_MSBuildProjectReferenceExistent)' != ''" | ||
ContinueOnError="!$(BuildingProject)" | ||
RemoveProperties="%(_MSBuildProjectReferenceExistent.GlobalPropertiesToRemove)"> | ||
|
@@ -1575,7 +1650,7 @@ Copyright (C) Microsoft Corporation. All rights reserved. | |
Projects="@(_MSBuildProjectReferenceExistent)" | ||
Targets="%(_MSBuildProjectReferenceExistent.Targets)" | ||
BuildInParallel="$(BuildInParallel)" | ||
Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform)" | ||
Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform); %(_MSBuildProjectReferenceExistent.SetTargetFramework)" | ||
Condition="'%(_MSBuildProjectReferenceExistent.BuildReference)' == 'true' and '@(ProjectReferenceWithConfiguration)' != '' and '$(BuildingInsideVisualStudio)' != 'true' and '$(BuildProjectReferences)' == 'true' and '@(_MSBuildProjectReferenceExistent)' != ''" | ||
ContinueOnError="$(ContinueOnError)" | ||
RemoveProperties="%(_MSBuildProjectReferenceExistent.GlobalPropertiesToRemove)"> | ||
|
@@ -1592,7 +1667,7 @@ Copyright (C) Microsoft Corporation. All rights reserved. | |
Projects="@(_MSBuildProjectReferenceExistent)" | ||
Targets="GetNativeManifest" | ||
BuildInParallel="$(BuildInParallel)" | ||
Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform)" | ||
Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform); %(_MSBuildProjectReferenceExistent.SetTargetFramework)" | ||
Condition="'%(_MSBuildProjectReferenceExistent.BuildReference)' == 'true' and '@(ProjectReferenceWithConfiguration)' != '' and '$(BuildingProject)' == 'true' and '@(_MSBuildProjectReferenceExistent)' != ''" | ||
ContinueOnError="$(ContinueOnError)" | ||
RemoveProperties="%(_MSBuildProjectReferenceExistent.GlobalPropertiesToRemove)"> | ||
|
@@ -2117,10 +2192,10 @@ Copyright (C) Microsoft Corporation. All rights reserved. | |
</ItemGroup> | ||
</Target> | ||
|
||
<Target Name="GetReferenceTargetPlatformMonikers" DependsOnTargets="AssignProjectConfiguration;_SplitProjectReferencesByFileExistence"> | ||
<Target Name="GetReferenceTargetPlatformMonikers" DependsOnTargets="PrepareProjectReferences"> | ||
<MSBuild | ||
Projects="@(_MSBuildProjectReferenceExistent)" | ||
Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform)" | ||
Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform); %(_MSBuildProjectReferenceExistent.SetTargetFramework)" | ||
Targets="GetTargetPathWithTargetPlatformMoniker" | ||
BuildInParallel="$(BuildInParallel)" | ||
ContinueOnError="!$(BuildingProject)" | ||
|
@@ -4012,7 +4087,8 @@ Copyright (C) Microsoft Corporation. All rights reserved. | |
<PropertyGroup> | ||
<GetCopyToOutputDirectoryItemsDependsOn> | ||
AssignTargetPaths; | ||
_SplitProjectReferencesByFileExistence | ||
_SplitProjectReferencesByFileExistence; | ||
_GetProjectReferenceTargetFrameworkProperties | ||
</GetCopyToOutputDirectoryItemsDependsOn> | ||
</PropertyGroup> | ||
<Target | ||
|
@@ -4036,7 +4112,7 @@ Copyright (C) Microsoft Corporation. All rights reserved. | |
Projects="@(_MSBuildProjectReferenceExistent)" | ||
Targets="GetCopyToOutputDirectoryItems" | ||
BuildInParallel="$(BuildInParallel)" | ||
Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform)" | ||
Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform); %(_MSBuildProjectReferenceExistent.SetTargetFramework)" | ||
Condition="'@(_MSBuildProjectReferenceExistent)' != '' and '$(_GetChildProjectCopyToOutputDirectoryItems)' == 'true' and '%(_MSBuildProjectReferenceExistent.Private)' != 'false' and '$(UseCommonOutputDirectory)' != 'true'" | ||
ContinueOnError="$(ContinueOnError)" | ||
RemoveProperties="%(_MSBuildProjectReferenceExistent.GlobalPropertiesToRemove)"> | ||
|
@@ -4554,7 +4630,7 @@ Copyright (C) Microsoft Corporation. All rights reserved. | |
--> | ||
<Target | ||
Name="CleanReferencedProjects" | ||
DependsOnTargets="AssignProjectConfiguration; _SplitProjectReferencesByFileExistence"> | ||
DependsOnTargets="PrepareProjectReferences"> | ||
|
||
<!-- | ||
When building the project directly from the command-line, clean those referenced projects | ||
|
@@ -4564,7 +4640,7 @@ Copyright (C) Microsoft Corporation. All rights reserved. | |
<MSBuild | ||
Projects="@(_MSBuildProjectReferenceExistent)" | ||
Targets="Clean" | ||
Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform)" | ||
Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform); %(_MSBuildProjectReferenceExistent.SetTargetFramework)" | ||
BuildInParallel="$(BuildInParallel)" | ||
Condition="'$(BuildingInsideVisualStudio)' != 'true' and '$(BuildProjectReferences)' == 'true' and '@(_MSBuildProjectReferenceExistent)' != ''" | ||
ContinueOnError="$(ContinueOnError)" | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is the
Outputs
here necessary? I don't see it used in this commit's diff.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.
Or is it here to batch the target so the loose
%(Identity)
metadata below works?In reply to: 78624878 [](ancestors = 78624878)
Uh oh!
There was an error while loading. Please reload this page.
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.
Yes. This whole thing feels messy to me, but I couldn't find a better way to express it. I imagined there would be a nice way to say "invoke this task for each item and put an output value from the task in to metadata for the item", but I couldn't find one. Am I just missing the idiomatic way to do this?
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.
I'm not seeing a great option, either. Still poking at a thing or two . . .
In reply to: 78629179 [](ancestors = 78629179)
Uh oh!
There was an error while loading. Please reload this page.
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.
Ok, I have an approach that allows building the refs in parallel. But I'm not sure it's actually better--it requires adding redundant metadata to
_MSBuildProjectReferenceExistent
(to allow for shared-metadata batching on the path of the project):Salient features:
MSBuildSourceProjectFile
metadata to_MSBuildProjectReferenceExistent
MSBuildSourceProjectFile
)I'm not sure which use of obscure hard-to-reason-about batching features is better. This way is probably slightly more performant (because of parallelism in the remote builds). @cdmihai @AndyGerlicher @jeffkl --thoughts?
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.
I can't deep-link to the right table item, but it's under
TargetOutputs
here: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.
Got it. I was imagining it was some magic flow, but it's just what's set on TargetOutputs. :)
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.
I'm having trouble getting things to work with this change. :( Given the time constraint (we want this in today so that the new (hopefully-not-but-potentially-breaking) targets are in Preview 5. Would you be ok iterating on the final pattern here as an immediate follow-up change?
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.
Let's go with the implementation that works we can adjust later.
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.
Yeah, that's fine.