Skip to content
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

Port traversal targets for cross-targeting to xplat branch #1025

Merged
merged 2 commits into from
Sep 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions setup/files.swr
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ folder InstallDir:\MSBuild\15.0\Bin
file source=$(X86BinPath)System.Threading.Tasks.Dataflow.dll vs.file.ngen=yes
file source=$(X86BinPath)System.Collections.Immutable.dll vs.file.ngen=yes
file source=$(X86BinPath)Microsoft.Common.CurrentVersion.targets
file source=$(X86BinPath)Microsoft.Common.CrossTargeting.targets
file source=$(X86BinPath)Microsoft.Common.overridetasks
file source=$(X86BinPath)Microsoft.Common.targets
file source=$(X86BinPath)Microsoft.Common.tasks
Expand Down Expand Up @@ -135,6 +136,7 @@ folder InstallDir:\MSBuild\15.0\Bin\amd64
file source=$(X86BinPath)System.Threading.Tasks.Dataflow.dll vs.file.ngen=yes
file source=$(X86BinPath)System.Collections.Immutable.dll vs.file.ngen=yes
file source=$(X86BinPath)Microsoft.Common.CurrentVersion.targets
file source=$(X86BinPath)Microsoft.Common.CrossTargeting.targets
file source=$(X86BinPath)Microsoft.Common.overridetasks
file source=$(X86BinPath)Microsoft.Common.targets
file source=$(X86BinPath)Microsoft.Common.tasks
Expand Down
7 changes: 7 additions & 0 deletions src/XMakeTasks/Microsoft.Build.Tasks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,10 @@
<Content Include="Microsoft.Common.CurrentVersion.targets">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Microsoft.Common.CrossTargeting.targets">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<SubType>Designer</SubType>
</Content>
<Content Include="Microsoft.Common.targets">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down Expand Up @@ -821,6 +825,9 @@
<DataFile Include="Microsoft.Common.CurrentVersion.targets">
<SubType>Designer</SubType>
</DataFile>
<DataFile Include="Microsoft.Common.CrossTargeting.targets">
<SubType>Designer</SubType>
</DataFile>
<DataFile Include="Microsoft.NETFramework.targets" />
<DataFile Include="Microsoft.NETFramework.CurrentVersion.targets" />
<DataFile Include="Microsoft.NETFramework.props">
Expand Down
14 changes: 14 additions & 0 deletions src/XMakeTasks/Microsoft.CSharp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ Copyright (C) Microsoft Corporation. All rights reserved.

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
We are doing a cross-targeting build if there is no list of target frameworks specified
nor is there a current target framework being built individually. In that case, this import is
redirected to Microsoft.Common.CrossTargeting.targets.
-->
<PropertyGroup Condition="'$(TargetFrameworks)' != '' and '$(TargetFramework)' == ''">
<IsCrossTargetingBuild>true</IsCrossTargetingBuild>
</PropertyGroup>

<!--
In VS 2010 SP1 and VS 2012, both supported for asset compatibility, the MSBuild installed
as part of them did not enforce using the local ToolsVersion (4.0) in all cases, but instead
just used whatever ToolsVersion was in the project file if it existed on the machine, and
Expand All @@ -40,6 +49,11 @@ Copyright (C) Microsoft Corporation. All rights reserved.
<CscToolPath Condition="'$(CscToolPath)' == '' and '$(BuildingInsideVisualStudio)' != 'true'">$(MsBuildFrameworkToolsPath)</CscToolPath>
</PropertyGroup>
</When>
<When Condition="'$(IsCrossTargetingBuild)' == 'true'">
<PropertyGroup>
<CSharpTargetsPath>$(MSBuildToolsPath)\Microsoft.Common.CrossTargeting.targets</CSharpTargetsPath>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<CSharpTargetsPath>$(MSBuildToolsPath)\Microsoft.CSharp.CurrentVersion.targets</CSharpTargetsPath>
Expand Down
16 changes: 16 additions & 0 deletions src/XMakeTasks/Microsoft.Common.CrossTargeting.targets
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>
110 changes: 93 additions & 17 deletions src/XMakeTasks/Microsoft.Common.CurrentVersion.targets
Original file line number Diff line number Diff line change
Expand Up @@ -884,12 +884,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)">
Expand All @@ -909,12 +909,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)">
Expand All @@ -934,12 +934,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)">
Expand Down Expand Up @@ -1487,6 +1487,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

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
Expand Down Expand Up @@ -1514,7 +1589,7 @@ Copyright (C) Microsoft Corporation. All rights reserved.

<Target
Name="ResolveProjectReferences"
DependsOnTargets="AssignProjectConfiguration;_SplitProjectReferencesByFileExistence"
DependsOnTargets="PrepareProjectReferences"
Returns="@(_ResolvedNativeProjectReferencePaths);@(_ResolvedProjectReferencePaths)">

<!--
Expand All @@ -1529,7 +1604,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)">
Expand All @@ -1556,7 +1631,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)">
Expand All @@ -1573,7 +1648,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)">
Expand All @@ -1590,7 +1665,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)">
Expand Down Expand Up @@ -2115,10 +2190,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)"
Expand Down Expand Up @@ -4010,7 +4085,8 @@ Copyright (C) Microsoft Corporation. All rights reserved.
<PropertyGroup>
<GetCopyToOutputDirectoryItemsDependsOn>
AssignTargetPaths;
_SplitProjectReferencesByFileExistence
_SplitProjectReferencesByFileExistence;
_GetProjectReferenceTargetFrameworkProperties
</GetCopyToOutputDirectoryItemsDependsOn>
</PropertyGroup>
<Target
Expand All @@ -4034,7 +4110,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)">
Expand Down Expand Up @@ -4552,7 +4628,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
Expand All @@ -4562,7 +4638,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)"
Expand Down
Loading