| 1 |
<?xml version="1.0" encoding="utf-8"?> |
| 2 |
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
| 3 |
<UsingTask TaskName="FindBestConfigurations" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll"/> |
| 4 |
<PropertyGroup> |
| 5 |
<ImportedBuildVerticalTargets>true</ImportedBuildVerticalTargets> |
| 6 |
<_traversalBuildConfigurations>$(BuildConfiguration)</_traversalBuildConfigurations> |
| 7 |
<_traversalBuildConfigurations Condition="'$(AdditionalBuildConfigurations)' != ''">$(_traversalBuildConfigurations);$(AdditionalBuildConfigurations)</_traversalBuildConfigurations> |
| 8 |
</PropertyGroup> |
| 9 |
|
| 10 |
<!-- Import configuration data model --> |
| 11 |
<Import Project="$(ProjectDir)tools-local/properties.props" /> |
| 12 |
|
| 13 |
<!-- Runs during traversal when BuildAllConfigurations is set to expand each project |
| 14 |
to a seperate instance for each of its BuildConfigurations --> |
| 15 |
<Target Name="ExpandAllBuildConfigurations" |
| 16 |
Condition="'$(BuildAllConfigurations)' == 'true'"> |
| 17 |
<MSBuild Targets="GetBuildConfigurations" |
| 18 |
Projects="@(Project)" |
| 19 |
Condition="'$(BuildAllConfigurations)' == 'true'"> |
| 20 |
<Output TaskParameter="TargetOutputs" |
| 21 |
ItemName="_projectBuildConfigurations" /> |
| 22 |
</MSBuild> |
| 23 |
|
| 24 |
<ItemGroup> |
| 25 |
<!-- assign configuration as a seperate step to prevent batching during the transform which can reorder the list. |
| 26 |
order or projects matters here since this applies to traversal projects which build projects serially. --> |
| 27 |
<_projectBuildConfigurations> |
| 28 |
<AdditionalProperties>Configuration=%(Identity);%(_projectBuildConfigurations.AdditionalProperties)</AdditionalProperties> |
| 29 |
</_projectBuildConfigurations> |
| 30 |
|
| 31 |
<!-- we need to ignore placeholder build configurations that start with _ --> |
| 32 |
<_projectBuildConfigurations Remove="@(_projectBuildConfigurations)" Condition="$([System.String]::Copy('%(Identity)').StartsWith('_'))" /> |
| 33 |
|
| 34 |
<!-- transform back to project --> |
| 35 |
<_projectWithConfiguration Include="@(_projectBuildConfigurations->'%(OriginalItemSpec)')" /> |
| 36 |
</ItemGroup> |
| 37 |
|
| 38 |
<ItemGroup> |
| 39 |
<Project Remove="@(Project)" /> |
| 40 |
<Project Include="@(_projectWithConfiguration)" /> |
| 41 |
</ItemGroup> |
| 42 |
</Target> |
| 43 |
|
| 44 |
<Target Name="ExpandAllBuildConfigurationsForPkgProj" |
| 45 |
BeforeTargets="ExpandProjectReferences" |
| 46 |
Condition="'$(MSBuildProjectExtension)' == '.pkgproj'"> |
| 47 |
<MSBuild Targets="GetPackageConfigurations" |
| 48 |
Projects="@(_NonPkgProjProjectReference)"> |
| 49 |
<Output TaskParameter="TargetOutputs" |
| 50 |
ItemName="_NonPkgProjProjectReferenceBuildConfigurations" /> |
| 51 |
</MSBuild> |
| 52 |
|
| 53 |
<ItemGroup> |
| 54 |
<!-- assign configuration as a seperate step to prevent batching during the transform which can reorder the list. |
| 55 |
order or projects matters here since this applies to traversal projects which build projects serially. --> |
| 56 |
<_NonPkgProjProjectReferenceBuildConfigurations> |
| 57 |
<AdditionalProperties>Configuration=%(Identity);%(_NonPkgProjProjectReferenceBuildConfigurations.AdditionalProperties)</AdditionalProperties> |
| 58 |
</_NonPkgProjProjectReferenceBuildConfigurations> |
| 59 |
|
| 60 |
<!-- we need to ignore placeholder build configurations that start with _ --> |
| 61 |
<_NonPkgProjProjectReferenceBuildConfigurations Remove="@(_NonPkgProjProjectReferenceBuildConfigurations)" Condition="$([System.String]::Copy('%(Identity)').StartsWith('_'))" /> |
| 62 |
|
| 63 |
<!-- transform back to project --> |
| 64 |
<_NonPkgProjProjectReferenceWitnConfiguration Include="@(_NonPkgProjProjectReferenceBuildConfigurations->'%(OriginalItemSpec)')" /> |
| 65 |
</ItemGroup> |
| 66 |
|
| 67 |
<ItemGroup> |
| 68 |
<_NonPkgProjProjectReference Remove="@(_NonPkgProjProjectReference)" /> |
| 69 |
<_NonPkgProjProjectReference Include="@(_NonPkgProjProjectReferenceWitnConfiguration)" /> |
| 70 |
</ItemGroup> |
| 71 |
</Target> |
| 72 |
|
| 73 |
<!-- Runs during traversal to select which projects and configurations of those projects to build |
| 74 |
Batches over the projects because we need to treat BuildConfigurations as a Property |
| 75 |
as well as copy the Project based on results of FindBestConfigurations. --> |
| 76 |
<Target Name="FilterBuildConfiguration" |
| 77 |
Condition="'$(BuildAllConfigurations)' != 'true'" |
| 78 |
Inputs="%(Project.Identity)" |
| 79 |
Outputs="unused"> |
| 80 |
|
| 81 |
<MSBuild Targets="GetBuildConfigurations" |
| 82 |
Projects="@(Project)"> |
| 83 |
<Output TaskParameter="TargetOutputs" |
| 84 |
PropertyName="_projectBuildConfigurations" /> |
| 85 |
</MSBuild> |
| 86 |
|
| 87 |
<FindBestConfigurations Properties="@(Property)" |
| 88 |
PropertyValues="@(PropertyValue)" |
| 89 |
SupportedConfigurations="$(_projectBuildConfigurations)" |
| 90 |
Configurations="$(_traversalBuildConfigurations)"> |
| 91 |
<Output TaskParameter="BestConfigurations" ItemName="_projectBestConfigurations" /> |
| 92 |
</FindBestConfigurations> |
| 93 |
|
| 94 |
<ItemGroup> |
| 95 |
<!-- Apply configuration, this does a catesian product between @(Project) and @(_projectBestConfigurations) --> |
| 96 |
<_projectWithConfiguration Include="@(Project)" Condition="'@(_projectBestConfigurations)' != ''"> |
| 97 |
<AdditionalProperties>Configuration=%(_projectBestConfigurations.Identity);%(_projectWithConfiguration.AdditionalProperties)</AdditionalProperties> |
| 98 |
</_projectWithConfiguration> |
| 99 |
<Project Remove="@(Project)"/> |
| 100 |
<Project Include="@(_projectWithConfiguration)"/> |
| 101 |
</ItemGroup> |
| 102 |
</Target> |
| 103 |
|
| 104 |
<Target Name="FilterProjects" |
| 105 |
Condition="'$(FilterProjectsByBuildConfiguration)' != 'false'" |
| 106 |
DependsOnTargets="ExpandAllBuildConfigurations;FilterBuildConfiguration" /> |
| 107 |
|
| 108 |
<!-- Runs in a leaf project (eg: csproj) to determine all configurations --> |
| 109 |
<Target Name="GetBuildConfigurations" |
| 110 |
Returns="$(_AllBuildConfigurations)"> |
| 111 |
<PropertyGroup> |
| 112 |
<_AllBuildConfigurations>$(BuildConfigurations)</_AllBuildConfigurations> |
| 113 |
<_AllBuildConfigurations Condition="'$(BuildConfigurations)' == ''">$(_traversalBuildConfigurations)</_AllBuildConfigurations> |
| 114 |
</PropertyGroup> |
| 115 |
|
| 116 |
<!-- Filter out configurations for things not in netcoreapp when building only netcoreapp --> |
| 117 |
<PropertyGroup Condition="'$(BuildNETCoreAppOnly)' == 'true' and ('$(MSBuildProjectExtension)' == '.csproj' or '$(MSBuildProjectExtension)' == '.ilproj')"> |
| 118 |
<PartOfNETCoreAppBuild Condition="'$(PartOfNETCoreAppBuild)' == ''">$(IsNETCoreApp)</PartOfNETCoreAppBuild> |
| 119 |
|
| 120 |
<_AllBuildConfigurations Condition="'$(PartOfNETCoreAppBuild)' != 'true'"></_AllBuildConfigurations> |
| 121 |
</PropertyGroup> |
| 122 |
|
| 123 |
</Target> |
| 124 |
|
| 125 |
<!-- Runs in a leaf project (eg: csproj) to determine configurations to package --> |
| 126 |
<Target Name="GetPackageConfigurations" |
| 127 |
Returns="$(PackageConfigurations)"> |
| 128 |
<ItemGroup Condition="'$(PackageConfigurations)' == ''"> |
| 129 |
<_buildConfigurations Include="$(BuildConfigurations)" /> |
| 130 |
<_excludeBuildConfigurations Include="mono" /> |
| 131 |
<_packageConfigurations Include="@(_buildConfigurations)" Exclude="@(_excludeBuildConfigurations)" /> |
| 132 |
</ItemGroup> |
| 133 |
|
| 134 |
<PropertyGroup Condition="'$(PackageConfigurations)' == ''"> |
| 135 |
<PackageConfigurations>@(_packageConfigurations)</PackageConfigurations> |
| 136 |
</PropertyGroup> |
| 137 |
</Target> |
| 138 |
|
| 139 |
<!-- Runs in a leaf project (csproj) to determine best configuration for ProjectReferences --> |
| 140 |
<Target Name="AnnotateProjectReference" |
| 141 |
BeforeTargets="AssignProjectConfiguration" |
| 142 |
Condition="'@(ProjectReference)' != ''" |
| 143 |
Inputs="%(ProjectReference.Identity)" |
| 144 |
Outputs="unused"> |
| 145 |
|
| 146 |
<MSBuild Targets="GetBuildConfigurations" |
| 147 |
Projects="@(ProjectReference)"> |
| 148 |
<Output TaskParameter="TargetOutputs" PropertyName="_projectReferenceBuildConfigurations" /> |
| 149 |
</MSBuild> |
| 150 |
|
| 151 |
<PropertyGroup> |
| 152 |
<!-- |
| 153 |
When building in VS or using the solution file Configuration for some projects is set to Debug/Release |
| 154 |
in such cases we should treat it as an empty configuration and set it to be $BuildConfiguration for the |
| 155 |
purposes of annotating project references. |
| 156 |
--> |
| 157 |
<Configuration Condition="'$(Configuration)' == 'Debug' or '$(Configuration)' == 'Release'">$(BuildConfiguration)</Configuration> |
| 158 |
</PropertyGroup> |
| 159 |
|
| 160 |
<!-- Find the best configuration for the current Project's Configuration --> |
| 161 |
<FindBestConfigurations Properties="@(Property)" |
| 162 |
PropertyValues="@(PropertyValue)" |
| 163 |
SupportedConfigurations="$(_ProjectReferenceBuildConfigurations)" |
| 164 |
Configurations="$(Configuration)"> |
| 165 |
<Output TaskParameter="BestConfigurations" PropertyName="_projectReferenceConfiguration" /> |
| 166 |
</FindBestConfigurations> |
| 167 |
|
| 168 |
<Error Condition="'$(_projectReferenceConfiguration)' == ''" Text="Could not find a configuration for ProjectReference '@(ProjectReference)' from configurations '$(_projectReferenceBuildConfigurations)' when building '$(MSBuildProjectName)' for configuration '$(Configuration)' ." /> |
| 169 |
|
| 170 |
<ItemGroup> |
| 171 |
<ProjectReference> |
| 172 |
<AdditionalProperties>Configuration=$(_projectReferenceConfiguration);%(ProjectReference.AdditionalProperties)</AdditionalProperties> |
| 173 |
</ProjectReference> |
| 174 |
|
| 175 |
<!-- Project references for non-test assemblies should never be copied to the output. --> |
| 176 |
<ProjectReference Condition="'$(IsTestProject)' != 'true'"> |
| 177 |
<Private>false</Private> |
| 178 |
</ProjectReference> |
| 179 |
</ItemGroup> |
| 180 |
</Target> |
| 181 |
|
| 182 |
<Target Name="_getAllBuildConfigurations"> |
| 183 |
<ItemGroup> |
| 184 |
<_buildConfigurations Include="$(BuildConfigurations)" /> |
| 185 |
<!-- For BuildAllConfigurations we need to ignore any placeholder build configuration that starts with _ --> |
| 186 |
<_buildConfigurations Remove="@(_buildConfigurations)" Condition="$([System.String]::Copy('%(Identity)').StartsWith('_'))" /> |
| 187 |
<_buildConfigurations Condition="'@(_buildConfigurations)' == ''" Include="$(_traversalBuildConfigurations)" /> |
| 188 |
</ItemGroup> |
| 189 |
</Target> |
| 190 |
|
| 191 |
<Target Name="BuildAllConfigurations" DependsOnTargets="_getAllBuildConfigurations"> |
| 192 |
<MSBuild Projects="$(MSBuildProjectFullPath)" |
| 193 |
Properties="Configuration=%(_buildConfigurations.Identity);BuildAllConfigurations=true" /> |
| 194 |
</Target> |
| 195 |
<Target Name="BuildAll" DependsOnTargets="BuildAllConfigurations" /> |
| 196 |
|
| 197 |
<Target Name="RebuildAllConfigurations" DependsOnTargets="_getAllBuildConfigurations"> |
| 198 |
<MSBuild Projects="$(MSBuildProjectFullPath)" |
| 199 |
Targets="Rebuild" |
| 200 |
Properties="Configuration=%(_buildConfigurations.Identity);BuildAllConfigurations=true" /> |
| 201 |
</Target> |
| 202 |
<Target Name="RebuildAll" DependsOnTargets="RebuildAllConfigurations" /> |
| 203 |
|
| 204 |
<Target Name="CleanAllConfigurations" DependsOnTargets="_getAllBuildConfigurations"> |
| 205 |
<MSBuild Projects="$(MSBuildProjectFullPath)" |
| 206 |
Targets="Clean" |
| 207 |
Properties="Configuration=%(_buildConfigurations.Identity);BuildAllConfigurations=true" /> |
| 208 |
</Target> |
| 209 |
<Target Name="CleanAll" DependsOnTargets="CleanAllConfigurations" /> |
| 210 |
|
| 211 |
</Project> |