linux-packaging-mono/external/corefx/buildvertical.targets
Xamarin Public Jenkins (auto-signing) 6bdd276d05 Imported Upstream version 5.0.0.42
Former-commit-id: fd56571888259555122d8a0f58c68838229cea2b
2017-04-10 11:41:01 +00:00

118 lines
5.7 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="FindBestConfigurations" AssemblyFile="$(CoreFxToolsTaskDir)CoreFx.Tools.dll"/>
<PropertyGroup>
<ImportedBuildVerticalTargets>true</ImportedBuildVerticalTargets>
<_traversalBuildConfigurations>$(BuildConfiguration)</_traversalBuildConfigurations>
<_traversalBuildConfigurations Condition="'$(AdditionalBuildConfigurations)' != ''">$(_traversalBuildConfigurations);$(AdditionalBuildConfigurations)</_traversalBuildConfigurations>
</PropertyGroup>
<!-- Import configuration data model -->
<Import Project="$(MSBuildThisFileDirectory)src/Tools/GenerateProps/properties.props" />
<!-- Runs during traversal when BuildAllConfigurations is set to expand each project
to a seperate instance for each of its BuildConfigurations -->
<Target Name="ExpandAllBuildConfigurations"
Condition="'$(BuildAllConfigurations)' == 'true'">
<MSBuild Targets="GetBuildConfigurations"
Projects="@(Project)"
Condition="'$(BuildAllConfigurations)' == 'true'">
<Output TaskParameter="TargetOutputs"
ItemName="_projectBuildConfigurations" />
</MSBuild>
<ItemGroup>
<!-- transform back to project -->
<_ProjectWithConfiguration Include="@(_projectBuildConfigurations->'%(OriginalItemSpec)')">
<AdditionalProperties>Configuration=%(Identity);%(_ProjectBestConfigurations.AdditionalProperties)</AdditionalProperties>
</_ProjectWithConfiguration>
</ItemGroup>
<ItemGroup>
<Project Remove="@(Project)" />
<Project Include="@(_ProjectWithConfiguration)" />
</ItemGroup>
</Target>
<!-- Runs during traversal to select which projects and configurations of those projects to build
Batches over the projects because we need to treat BuildConfigurations as a Property
as well as copy the Project based on results of FindBestConfigurations. -->
<Target Name="FilterBuildConfiguration"
Condition="'$(BuildAllConfigurations)' != 'true'"
Inputs="%(Project.Identity)"
Outputs="unused">
<MSBuild Targets="GetBuildConfigurations"
Projects="@(Project)">
<Output TaskParameter="TargetOutputs"
PropertyName="_projectBuildConfigurations" />
</MSBuild>
<FindBestConfigurations Properties="@(Property)"
PropertyValues="@(PropertyValue)"
SupportedConfigurations="$(_projectBuildConfigurations)"
Configurations="$(_traversalBuildConfigurations)">
<Output TaskParameter="BestConfigurations" ItemName="_projectBestConfigurations" />
</FindBestConfigurations>
<ItemGroup>
<!-- Apply configuration, this does a catesian product between @(Project) and @(_projectBestConfigurations) -->
<_projectWithConfiguration Include="@(Project)" Condition="'@(_projectBestConfigurations)' != ''">
<AdditionalProperties>Configuration=%(_projectBestConfigurations.Identity);%(_projectWithConfiguration.AdditionalProperties)</AdditionalProperties>
</_projectWithConfiguration>
<Project Remove="@(Project)"/>
<Project Include="@(_projectWithConfiguration)"/>
</ItemGroup>
</Target>
<Target Name="FilterProjects"
DependsOnTargets="ExpandAllBuildConfigurations;FilterBuildConfiguration" />
<!-- Runs in a leaf project (eg: csproj) to determine all configurations -->
<Target Name="GetBuildConfigurations"
Returns="$(_AllBuildConfigurations)">
<PropertyGroup>
<_AllBuildConfigurations>$(BuildConfigurations)</_AllBuildConfigurations>
<_AllBuildConfigurations Condition="'$(BuildConfigurations)' == ''">$(_traversalBuildConfigurations)</_AllBuildConfigurations>
</PropertyGroup>
</Target>
<!-- Runs in a leaf project (csproj) to determine best configuration for ProjectReferences -->
<Target Name="AnnotateProjectReference"
BeforeTargets="BeforeResolveReferences"
Condition="'@(ProjectReference)' != ''"
Inputs="%(ProjectReference.Identity)"
Outputs="unused">
<MSBuild Targets="GetBuildConfigurations"
Projects="@(ProjectReference)">
<Output TaskParameter="TargetOutputs" PropertyName="_projectReferenceBuildConfigurations" />
</MSBuild>
<!-- Find the best configuration for the current Project's Configuration -->
<FindBestConfigurations Properties="@(Property)"
PropertyValues="@(PropertyValue)"
SupportedConfigurations="$(_ProjectReferenceBuildConfigurations)"
Configurations="$(Configuration)">
<Output TaskParameter="BestConfigurations" PropertyName="_projectReferenceConfiguration" />
</FindBestConfigurations>
<Error Condition="'$(_projectReferenceConfiguration)' == ''" Text="Could not find a configuration for ProjectReference '@(ProjectReference)' from configurations '$(_projectReferenceBuildConfigurations)' when building '$(MSBuildProjectName)' for configuration '$(Configuration)' ." />
<ItemGroup>
<ProjectReference>
<AdditionalProperties>Configuration=$(_projectReferenceConfiguration);%(ProjectReference.AdditionalProperties)</AdditionalProperties>
</ProjectReference>
</ItemGroup>
</Target>
<Target Name="BuildAllConfigurations">
<ItemGroup>
<_buildConfigurations Include="$(BuildConfigurations)" />
<_buildConfigurations Condition="'@(_buildConfigurations)' == ''" Include="$(_traversalBuildConfigurations)" />
</ItemGroup>
<MSBuild Projects="$(MSBuildProjectFullPath)"
Properties="Configuration=%(_buildConfigurations.Identity);BuildAllConfigurations=true" />
</Target>
</Project>