-
Notifications
You must be signed in to change notification settings - Fork 4.8k
/
Directory.Build.targets
200 lines (169 loc) · 12.2 KB
/
Directory.Build.targets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<Project InitialTargets="AddSkipGetTargetFrameworkToProjectReferences">
<PropertyGroup>
<CoreCLROSGroup Condition="'$(CoreCLROSGroup)' == ''">$(_bc_OSGroup)</CoreCLROSGroup>
<MonoOSGroup Condition="'$(MonoCLROSGroup)' == ''">$(_bc_OSGroup)</MonoOSGroup>
</PropertyGroup>
<Import Project="..\..\Directory.Build.targets" />
<PropertyGroup>
<!-- Reset these properties back to blank, since they are defaulted by Microsoft.NET.Sdk -->
<FileAlignment Condition="'$(FileAlignment)' == '512'" />
<ErrorReport Condition="'$(ErrorReport)' == 'prompt'" />
<WarningsAsErrors Condition="'$(WarningsAsErrors)' == 'NU1605'" />
</PropertyGroup>
<PropertyGroup>
<!-- Override strong name key to default to Open for test projects,
Tests which wish to control this should set TestStrongNameKeyId. -->
<TestStrongNameKeyId Condition="'$(TestStrongNameKeyId)' == ''">Open</TestStrongNameKeyId>
<StrongNameKeyId Condition="'$(IsTestProject)' == 'true'">$(TestStrongNameKeyId)</StrongNameKeyId>
</PropertyGroup>
<Import Project="$(RepositoryEngineeringDir)resources.targets" />
<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />
<PropertyGroup>
<ArtifactsPackagesDir>$([MSBuild]::NormalizePath('$(ArtifactsDir)', 'packages', '$(ConfigurationGroup)'))</ArtifactsPackagesDir>
<ArtifactsShippingPackagesDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsPackagesDir)', 'Shipping'))</ArtifactsShippingPackagesDir>
<ArtifactsNonShippingPackagesDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsPackagesDir)', 'NonShipping'))</ArtifactsNonShippingPackagesDir>
<PackageOutputPath Condition="'$(IsShippingPackage)' == 'true'">$(ArtifactsShippingPackagesDir)</PackageOutputPath>
<PackageOutputPath Condition="'$(IsShippingPackage)' != 'true'">$(ArtifactsNonShippingPackagesDir)</PackageOutputPath>
</PropertyGroup>
<Import Project="$(RepositoryEngineeringDir)versioning.targets" />
<!-- Corefx-specific binplacing properties -->
<PropertyGroup>
<IsRuntimeAssembly Condition="'$(IsRuntimeAssembly)'=='' and '$(IsReferenceAssembly)' != 'true' and '$(BinPlaceRef)' != 'true' and '$(IsTestProject)' != 'true'">true</IsRuntimeAssembly>
<!-- Try to determine if this is a simple library without a ref project.
https://github.com/dotnet/corefx/issues/14291 is tracking cleaning this up -->
<IsRuntimeAndReferenceAssembly Condition="'$(IsRuntimeAndReferenceAssembly)' == '' and '$(IsRuntimeAssembly)' == 'true' and Exists('$(LibrariesProjectRoot)$(MSBuildProjectName)') and !Exists('$(LibrariesProjectRoot)$(MSBuildProjectName)/ref') and !$(MSBuildProjectName.StartsWith('System.Private'))">true</IsRuntimeAndReferenceAssembly>
<IsNETCoreAppRef Condition="'$(IsNETCoreAppRef)' == ''">$(IsNETCoreApp)</IsNETCoreAppRef>
<IsNetFxNETStandardRef Condition="'$(IsNetFxNETStandardRef)' == ''">$(IsNetFxNETStandard)</IsNetFxNETStandardRef>
<BinPlaceRef Condition="'$(BinPlaceRef)' == '' And ('$(IsReferenceAssembly)' == 'true' or '$(IsRuntimeAndReferenceAssembly)' == 'true')">true</BinPlaceRef>
<BinPlaceRuntime Condition="'$(BinPlaceRuntime)' == '' And ('$(IsRuntimeAssembly)' == 'true' or '$(IsRuntimeAndReferenceAssembly)' == 'true')">true</BinPlaceRuntime>
<BinPlaceForTargetVertical Condition="'$(BinPlaceForTargetVertical)' == ''">true</BinPlaceForTargetVertical>
</PropertyGroup>
<ItemGroup Condition="'@(BinPlaceConfiguration)' == ''">
<!-- binplace to directories for the target vertical -->
<BinPlaceConfiguration Include="$(_bc_TargetGroup)-$(_bc_OSGroup)" Condition="'$(BinPlaceForTargetVertical)' == 'true'">
<RefPath>$(BuildConfigurationRefPath)</RefPath>
<RuntimePath>$(RuntimePath)</RuntimePath>
</BinPlaceConfiguration>
<!-- binplace to directories for packages -->
<BinPlaceConfiguration Condition="'$(IsNETCoreApp)' == 'true' and '$(BuildingNETCoreAppVertical)' == 'true'" Include="$(NetCoreAppCurrent)-$(_bc_OSGroup)">
<PackageFileRefPath Condition="'$(IsNETCoreAppRef)' == 'true'">$(NETCoreAppPackageRefPath)</PackageFileRefPath>
<PackageFileRuntimePath>$(NETCoreAppPackageRuntimePath)</PackageFileRuntimePath>
<RuntimePath Condition="'$(BinPlaceNETCoreAppPackage)' == 'true'">$(NETCoreAppPackageRuntimePath)\..\runtime\$(_bc_OSGroup)-$(ConfigurationGroup)-$(ArchGroup)</RuntimePath>
<RefPath Condition="'$(BinPlaceNETCoreAppPackage)' == 'true' and '$(IsNETCoreAppRef)' == 'true'">$(RefRootPath)microsoft.netcore.app\$(ConfigurationGroup)</RefPath>
<!-- enable trimming for any runtime project that's part of the shared framework and hasn't already set ILLinkTrimAssembly -->
<SetProperties Condition="'$(BinPlaceRuntime)' == 'true' and '$(ILLinkTrimAssembly)' == ''">ILLinkTrimAssembly=true</SetProperties>
</BinPlaceConfiguration>
<!-- Setup the shared framework directory for testing -->
<BinPlaceConfiguration Condition="'$(BinPlaceTestSharedFramework)' == 'true'" Include="$(NetCoreAppCurrent)-$(_bc_OSGroup)">
<RuntimePath>$(NETCoreAppTestSharedFrameworkPath)</RuntimePath>
</BinPlaceConfiguration>
<BinPlaceConfiguration Condition="'$(BinPlaceNETFXRuntime)' == 'true'" Include="$(NetFrameworkCurrent)-Windows_NT">
<RuntimePath>$(TestHostRootPath)</RuntimePath>
</BinPlaceConfiguration>
<!-- binplace targeting packs which may be different from BuildConfiguration -->
<BinPlaceConfiguration Include="netstandard2.0">
<RefPath>$(NetStandard20RefPath)</RefPath>
</BinPlaceConfiguration>
<BinPlaceConfiguration Include="netstandard2.1">
<RefPath>$(NetStandard21RefPath)</RefPath>
</BinPlaceConfiguration>
<!-- some libraries that produce packages will remain targeting netcoreapp2.0 -->
<BinPlaceConfiguration Condition="'$(BuildingNETCoreAppVertical)' == 'true'" Include="netcoreapp2.0">
<RefPath>$(RefRootPath)netcoreapp2.0/</RefPath>
</BinPlaceConfiguration>
<!-- for BuildAllConfigurations make sure all refpaths are created. -->
<BinPlaceConfiguration Condition="'$(BuildAllConfigurations)' == 'true'" Include="@(TargetGroups)">
<RefPath>$(RefRootPath)%(Identity)/</RefPath>
</BinPlaceConfiguration>
<!-- for BuildAllConfigurations make sure runtimepaths are created for all vertical targetgroups. -->
<BinPlaceConfiguration Condition="'$(BuildAllConfigurations)' == 'true' and ('$(BinPlaceForTargetVertical)' == 'true' or '$(_bc_TargetGroup)' != '$(NetCoreAppCurrent)')" Include="$(NetCoreAppCurrent)-$(_bc_OSGroup)">
<RuntimePath>$(ArtifactsBinDir)runtime/%(Identity)-$(ConfigurationGroup)-$(ArchGroup)</RuntimePath>
</BinPlaceConfiguration>
<BinPlaceConfiguration Include="@(AdditionalBinPlaceConfiguration)" />
</ItemGroup>
<Import Project="$(RepositoryEngineeringDir)codeOptimization.targets" />
<Import Project="$(RepositoryEngineeringDir)depProj.targets" Condition="'$(MSBuildProjectExtension)' == '.depproj'" />
<Import Project="$(RepositoryEngineeringDir)references.targets" />
<Import Project="$(RepositoryEngineeringDir)resolveContract.targets" />
<Import Project="$(RepositoryEngineeringDir)testing\runtimeConfiguration.targets" />
<Import Project="$(RepositoryEngineeringDir)testing\launchSettings.targets" Condition="'$(EnableLaunchSettings)' == 'true'" />
<Import Project="$(RepositoryEngineeringDir)testing\tests.targets" Condition="'$(EnableTestSupport)' == 'true'" />
<Import Project="$(RepositoryEngineeringDir)testing\coverage.targets" Condition="'$(EnableCoverageSupport)' == 'true'" />
<Import Sdk="Microsoft.DotNet.Build.Tasks.Configuration" Project="Sdk.targets" />
<Import Condition="'$(EnableProjectRestore)' != 'true'" Project="$(RepositoryEngineeringDir)restore\repoRestore.targets" />
<Import Project="$(RepositoryEngineeringDir)referenceFromRuntime.targets" />
<Import Project="$(RepositoryEngineeringDir)illink.targets" />
<Import Project="$(RepositoryEngineeringDir)notSupported.SourceBuild.targets" Condition="'$(DotNetBuildFromSource)' == 'true'" />
<Target Name="ReportConfigurationErrorMessage"
BeforeTargets="AssignProjectConfiguration"
Condition="'$(BuildConfigurations)' != ''" >
<Message Importance="Low" Text="$(MSBuildProjectFullPath), C: $(Configuration) BC: $(BuildConfiguration) BCs: $(BuildConfigurations)" />
<Message Importance="High" Condition="'$(ConfigurationErrorMsg)' != ''" Text="$(MSBuildProjectFullPath) ConfigurationErrorMessage: $(ConfigurationErrorMsg)" />
</Target>
<Target Name="GenerateReferenceSource">
<PropertyGroup>
<_RefSourceFileOutputPath>$([MSBuild]::NormalizePath('$(MSBuildProjectDirectory)', '..', 'ref', '$(AssemblyName).cs'))</_RefSourceFileOutputPath>
<_ExcludeAPIList>$([MSBuild]::NormalizePath('$(MSBuildProjectDirectory)', '..', 'ref', 'ReferenceSourceExcludeApi.txt'))</_ExcludeAPIList>
<_ExcludeAttributesList>$(RepositoryEngineeringDir)DefaultGenApiDocIds.txt</_ExcludeAttributesList>
<_LicenseHeaderTxtPath>$(RepositoryEngineeringDir)LicenseHeader.txt</_LicenseHeaderTxtPath>
</PropertyGroup>
<PropertyGroup>
<_GenAPICmd>$(_GenAPICommand)</_GenAPICmd>
<_GenAPICmd>$(_GenAPICmd) "@(IntermediateAssembly)"</_GenAPICmd>
<_GenAPICmd>$(_GenAPICmd) --lib-path "$(RefPath.Trim('\/'))"</_GenAPICmd>
<_GenAPICmd>$(_GenAPICmd) --out "$(_RefSourceFileOutputPath)"</_GenAPICmd>
<_GenAPICmd>$(_GenAPICmd) --exclude-attributes-list "$(_ExcludeAttributesList)"</_GenAPICmd>
<_GenAPICmd Condition="Exists('$(_ExcludeAPIList)')">$(_GenAPICmd) --exclude-api-list "$(_ExcludeAPIList)"</_GenAPICmd>
<_GenAPICmd>$(_GenAPICmd) --header-file "$(_LicenseHeaderTxtPath)"</_GenAPICmd>
<_GenAPICmd Condition="'$(LangVersion)' != ''">$(_GenAPICmd) --lang-version "$(LangVersion)"</_GenAPICmd>
</PropertyGroup>
<Exec Command="$(_GenAPICmd)" />
<Message Text="Generated reference assembly source code: $(_RefSourceFileOutputPath)" />
</Target>
<!-- Import Packaging targets -->
<Import Project="$(RepositoryEngineeringDir)packaging.targets" />
<Import Project="$(RepositoryEngineeringDir)DisableSourceControlManagement.targets" Condition="'$(EnableSourceLink)' == 'false'" />
<!-- Define this now until we can clean-up targets that depend on it in the packaging targets -->
<Target Name="CreateVersionFileDuringBuild" />
<!-- Define this target to override the workaround in arcade as we don't need it for our pkgprojs -->
<Target Name="InitializeStandardNuspecProperties" />
<Target Name="AddSkipGetTargetFrameworkToProjectReferences" Condition="'@(ProjectReference)' != ''">
<ItemGroup>
<ProjectReference>
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
</ProjectReference>
</ItemGroup>
</Target>
<!-- Used for packaging -->
<Target Name="IsNotNetCoreAppProject" Returns="@(IsNotNetCoreAppProjectResult)">
<ItemGroup>
<IsNotNetCoreAppProjectResult Condition="'$(IsNetCoreApp)' != 'true'" Include="$(MSBuildProjectName)" Version="$(PackageVersion)" />
</ItemGroup>
</Target>
<PropertyGroup>
<!--
Hack workaround to skip the GenerateCompiledExpressionsTempFile target in
Microsoft.WorkflowBuildExtensions.targets target that always runs in VS
-->
<GenerateCompiledExpressionsTempFilePathForEditing />
</PropertyGroup>
<!-- Returns the assembly version of the project for consumption
by the NuGet package generation -->
<Target Name="GetAssemblyVersion"
Returns="$(AssemblyVersion)"/>
<!-- Returns the generated documentation file for consumption
by the NuGet package generation -->
<Target Name="GetDocumentationFile"
Returns="$(DocumentationFile)"/>
<!-- Adds Nullable annotation attributes to netstandard <= 2.0 builds -->
<Choose>
<When Condition="'$(Nullable)' != '' and ($(TargetFramework.StartsWith('netstandard1')) or '$(TargetFramework)' == 'netstandard2.0' or $(TargetFramework.StartsWith('netcoreapp2')) or '$(TargetsNetFx)' == 'true')">
<PropertyGroup>
<DefineConstants>$(DefineConstants),INTERNAL_NULLABLE_ATTRIBUTES</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\NullableAttributes.cs" Link="System\Diagnostics\CodeAnalysis\NullableAttributes.cs" />
</ItemGroup>
</When>
</Choose>
</Project>