This repository has been archived by the owner on Jan 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 241
/
Copy pathBuild.Common.targets
270 lines (221 loc) · 14.3 KB
/
Build.Common.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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" InitialTargets="CheckDesignTime">
<PropertyGroup>
<BuildToolsTaskDir Condition="'$(BuildToolsTaskDir)' == ''">$(ToolsDir)</BuildToolsTaskDir>
<!-- A number of the imports below depend on these default properties -->
<AssemblyVersion Condition="'$(AssemblyVersion)'==''">999.999.999.999</AssemblyVersion>
<CLSCompliant Condition="'$(CLSCompliant)'=='' and '$(IsTestProject)'=='true'">false</CLSCompliant>
<CLSCompliant Condition="'$(CLSCompliant)'==''">true</CLSCompliant>
<!--
Check if the project has been localized by looking for the existence of the .de.xlf file. By convention, we assume that if
a project is localized in German, then it is localized in all languages.
-->
<ExcludeLocalizationImport Condition="'$(ExcludeLocalizationImport)'=='' And !Exists('$(MSBuildProjectDirectory)/MultilingualResources/$(MSBuildProjectName).de.xlf')">true</ExcludeLocalizationImport>
</PropertyGroup>
<!-- used by test projects that need to copy supplemental content to the output directory -->
<ItemDefinitionGroup Condition="'$(IsTestProject)'=='true'">
<SupplementalTestData>
<DestinationDir />
</SupplementalTestData>
</ItemDefinitionGroup>
<!-- Assembly metadata indicating that an assembly is a framework (as opposed to user) assembly:
Test projects need to not have this because of the way "IsFrameworkAssembly" APIs work to check this. -->
<ItemGroup Condition="'$(IsDotNetFrameworkProductAssembly)' == 'true' AND '$(IsTestProject)' != 'true'" >
<AssemblyMetadata Include=".NETFrameworkAssembly">
<Value></Value>
</AssemblyMetadata>
<AssemblyMetadata Include="Serviceable">
<Value>True</Value>
</AssemblyMetadata>
</ItemGroup>
<!--
Import the provides support for EnsureBuildToolsRuntime target which will restore a .NET Core based
runtime and setup a $(ToolRuntimePath) and $(ToolHost) for others to consume.
This must be imported before any tools that need to use it are imported.
-->
<Import Project="$(MSBuildThisFileDirectory)toolruntime.targets" Condition="'$(ExcludeToolRuntimeImport)' != 'true'"/>
<!--
Import the reference assembly targets
This must be imported early because it modifies OutputPath and IntermediateOutputPath
used by other targets
Depends on Properties:
AssemblyVersion - Needed to determine API version used in
IsReferenceAssembly - Set if the project is in the ref assm path
Sets Properties:
APIVersion - Major.Minor assembly version for the project
-->
<Import Project="$(MSBuildThisFileDirectory)ReferenceAssemblies.targets" Condition="'$(ExcludeReferenceAssembliesImport)'!='true'" />
<!--
Import the codeAnalysis.targets file to enable analyzer support during build.
This should happen before we import the frameworkTargeting.targets because that import leads to computing a default
for the CodeAnalysisRuleset unless one is already specified
-->
<Import Project="$(MSBuildThisFileDirectory)codeAnalysis.targets" />
<!--
Import the codeOptimization.targets file to enable profile guided code optimization for managed assemblies.
-->
<Import Project="$(MSBuildThisFileDirectory)codeOptimization.targets" />
<!--
Import the default target framework targets.
Inputs:
TargetFrameworkIdentifier - If not set defaults to .NETPortable
TargetFrameworkVersion - If not set defaults to v4.5
TargetFrameworkProfile - If not set defaults to Profile7
This Imports portable.csharp/visualbasic.targets if .NETPortable is the identifier otherwise it imports csharp/visualbasic.targets
-->
<Import Project="$(MSBuildThisFileDirectory)FrameworkTargeting.targets" Condition="'$(ExcludeFrameworkTargetingImport)'!='true'" />
<!--
Import the default assembly info generation targets
Inputs:
GenerateAssemblyInfo - Controls whether or not to generate the assembly info file and defaults to true if not set.
AssemblyVersion - If not set defaults to 1.0.0.0 but it is expected to be set in csproj files.
CLSCompliant - If not set defaults to true and if it is true then adds the assembly level CLSCompliant(true) attribute.
File Version Inputs:
MajorVersion - If not set defaults to 1.
MinorVersion - If not set defaults to 0.
BuildNumberMajor - If not set defaults to 0.
BuildNumberMinor - If not set defaults to 0.
AssemblyFileVersion - If not set defaults to $(MajorVersion).$(MinorVersion).$(BuildNumberMajor).$(BuildNumberMinor).
BuildNumberTarget - If this property is set it will try to import the file which allows for it to override the properties above.
-->
<Import Project="$(MSBuildThisFileDirectory)versioning.targets" Condition="'$(ExcludeVersioningImport)'!='true'" />
<Import Project="$(MSBuildThisFileDirectory)Packaging.targets" Condition="'$(ExcludePackagingImport)'!='true' AND '$(MSBuildProjectExtension)' == '.pkgproj'" />
<!-- Property which signals whether to import buildagainstpackages.targets. This target contains
the targets necessary to build tests with project references converted to package dependencies.
-->
<PropertyGroup>
<_BuildAgainstPackages Condition="'$(KeepAllProjectReferences)' != 'true' and '$(IsTestProject)' == 'true' and '$(MSBuildProjectExtension)' != '.builds' and '$(SkipBuildAgainstPackages)'!='true'">$(BuildTestsAgainstPackages)</_BuildAgainstPackages>
</PropertyGroup>
<!--
Import the default package restore and resolve targets
Inputs:
ProjectJson - If not set defaults to $(MSBuildProjectDirectory)\project.json
RestorePackages - If not set defaults to the existence of the $(ProjectJson)
ResolveNuGetPackages - If not set defaults to the existance of $(ProjectJson)
Depends on properties:
NugetRestoreCommand - Used to restore the project packages from packages.config
DnuRestoreCommand - Used to restore the project packages from project.json
PackagesDir - Packages are restored to and resolved from this location
Depends on properties set by csharp/visualbasic.targets so needs to be imported after.
-->
<Import Project="$(MSBuildThisFileDirectory)packageresolve.targets" Condition="'$(ExcludePackageResolveImport)'!='true'" />
<!--
Import the partial facade generation targets
Inputs:
GeneratePlatformNotSupportedAssembly - Determines wether to generate not-supported API for this assembly
-->
<Import Project="$(MSBuildThisFileDirectory)notsupported.targets" Condition="'$(ExcludePartialFacadesImport)' != 'true'"/>
<!--
Import the default SR resource generation targets
Inputs:
ResourcesSourceOutputDirectory - If not set defaults to $(MSBuildProjectDirectory)\Resources.
StringResourcesPath - If not set defaults to $(ResourcesSourceOutputDirectory\Strings.resx if it exists. If the file exists
then the targets generates the strongly typed $(ResourcesSourceOutputDirectory)\SR.cs/vb file based on resource strings.
OmitResources - If set to true will skip resource inclusion even if StringResourcesPath exists.
-->
<Import Project="$(MSBuildThisFileDirectory)resources.targets" Condition="'$(ExcludeResourcesImport)'!='true'" />
<!--
Import the localization target
-->
<Import Project="$(MSBuildThisFileDirectory)localization.targets" Condition="'$(ExcludeLocalizationImport)'!='true'" />
<!--
Import the partial facade generation targets
Inputs:
IsPartialFacadeAssembly - Determines whether the partial facade generation targets will be as a post-processing step on the
assembly. Also invokes special logic for determining References.
-->
<Import Project="$(MSBuildThisFileDirectory)partialfacades.targets" Condition="'$(ExcludePartialFacadesImport)' != 'true'"/>
<!-- Import the ApiCompat targets. -->
<Import Project="$(MSBuildThisFileDirectory)ApiCompat.targets" />
<!--
Import the contract resolution targets
Inputs:
AssemblyName - Needed to determine which contract name to map to
AssemblyVersion - Needed to determine which contract version to map to
-->
<Import Project="$(MSBuildThisFileDirectory)resolveContract.targets" Condition="'$(ExcludeResolveContractImport)' != 'true'"/>
<!--
Import the default signing targets which will setup the authenticode properties and do OpenSourceSigning
Inputs:
SkipSigning - For projects that want to opt-out of strong name signing the can set this to true.
-->
<Import Project="$(MSBuildThisFileDirectory)sign.targets" Condition="'$(ExcludeSigningImport)'!='true'" />
<!--
Import the tests.targets which controls the publishing and running of the tests, including code coverage options.
Inputs:
RunTestsForProject - Usually set at the project level to disable the tests for a single project.
CoverageEnabledForProject - Usually set at the project level to disable code coverage for a single project.
SkipTests - Usually set at the root level for builds that want to disable all the tests.
ProjectJson - If not set defaults to $(MSBuildProjectDirectory)\project.json
CopyTestToTestDirectory - If not set defaults to $(IsTestProject)
Depends on Properties:
TestPath - Controls the root path from where the test assets are published and run from.
NugetRestoreCommand - Used to restore the test runtime package
DnuRestoreCommand - Used to restore the project packages from project.json
PackagesDir - Packages are restored to and resolved from this location
-->
<Import Project="$(MSBuildThisFileDirectory)tests.targets" Condition="'$(IsTestProject)'=='true' and '$(ExcludeTestsImport)'!='true'"/>
<!--
Import the PackageLibs.targets which exposes targets from library projects to report what
assets they contribute to nuget packages.
Inputs:
PackageTargetFramework - Target moniker to use for harvested dependencies.
If PackageTargetPath is not set, PackageTargetPath will be constructed
based on PackageTargetFramework.
Optional Inputs:
PackageSourcePath - Source path to the built output to be packaged, default is $(TargetPath)
Can be overridden.
IsReferenceAssembly - true if this project is a reference assembly.
PackageTargetPath - Destination subpath in the package at which all assets from this project
should be located. Default is lib\$(PackageTargetFramework) for implementation
assemblies, ref\$(PackageTargetFramework) for reference assemblies. Can be
overridden. When overridding also override PackageTargetFramework.
PackageTargetRuntime - Runtime id to use for harvested dependencies, default is none.
Can be overridden. If PackageTargetRuntime is overridden and PackageTargetPath
is not, PackageTargetPath will be constructed based on PackageTargetRuntime.
@(PackageDestination) - List of items with TargetFramework metadata that represent destination
subpaths in the package at which all assets from this project should be
located. When specified takes precedence over PackageTargetPath &
PackageTargetFramework.
DocumentationFile - location of xml doc produced by this project.
XmlDocFileRoot - location to pre-authored localized xml doc files
PackageIncludeDocs - true to include the docs next to this project's ouput. Default
is true for reference assemblies, false for implementation.
-->
<Import Project="$(MSBuildThisFileDirectory)PackageLibs.targets" Condition="'$(ExcludePackageLibsImport)'!='true'"/>
<Target Name="CheckDesignTime">
<!--
Visual Studio does a number of background builds to do a variety of tasks such as resolving references and preparing for intellisense.
These are called "design time" builds. You can only determine this state within a target as the properties VS sets are added at build time.
To see design time logs set TRACEDESIGNTIME=true before launching Visual Studio. Logs will go to %TEMP%.
Note that the existing $(DesignTimeBuild) is not set for all background builds.
-->
<PropertyGroup>
<VSDesignTimeBuild Condition="'$(BuildingInsideVisualStudio)'=='true' and '$(BuildingOutOfProcess)'=='false'">true</VSDesignTimeBuild>
</PropertyGroup>
</Target>
<!--
import the MicroBuild boot-strapper project (only relevant for shipping binaries)
NOTE: we import this at the end as it will override some dummy targets (e.g. SignFiles)
-->
<Import Project="$(MSBuildThisFileDirectory)MicroBuild.Core.targets" Condition="'$(IsTestProject)'!='true' and '$(SignType)' != 'oss'" />
<!--
Providing a definition for __BlockReflectionAttribute in an assembly is a signal to the .NET Native toolchain
to remove the metadata for all non-public APIs. This both reduces size and disables private reflection on those
APIs in libraries that include this. The attribute can also be applied to individual public APIs to similarly block them.
-->
<PropertyGroup>
<BlockReflectionAttribute Condition="'$(BlockReflectionAttribute)'=='' and ('$(TargetGroup)'=='netcore50' or '$(TargetGroup)'=='netcore50aot')">true</BlockReflectionAttribute>
<BlockReflectionAttribute Condition="'$(MSBuildProjectExtension)' == '.vbproj'">false</BlockReflectionAttribute>
</PropertyGroup>
<PropertyGroup Condition="'$(BlockReflectionAttribute)'=='true'">
<CoreCompileDependsOn>$(CoreCompileDependsOn);AddBlockReflectionAttribute</CoreCompileDependsOn>
<BlockReflectionAtributeFile>$(MSBuildThisFileDirectory)/BlockReflectionAttribute.cs</BlockReflectionAtributeFile>
</PropertyGroup>
<Target Name="AddBlockReflectionAttribute" >
<ItemGroup>
<Compile Include="$(BlockReflectionAtributeFile)" />
</ItemGroup>
</Target>
<Import Project="$(CustomAfterBuildCommonTargets)" Condition="Exists('$(CustomAfterBuildCommonTargets)')"/>
</Project>