-
Notifications
You must be signed in to change notification settings - Fork 753
Expand file tree
/
Copy pathcommon.targets
More file actions
274 lines (236 loc) · 12.7 KB
/
common.targets
File metadata and controls
274 lines (236 loc) · 12.7 KB
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
271
272
273
274
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0">
<!-- Set AssemblyVersion in targets as it is TFM dependent. -->
<PropertyGroup Condition="'$(AssemblyVersion)' == ''">
<AssemblyVersion Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">$(SemanticVersion).$(PreReleaseVersion)</AssemblyVersion>
<AssemblyVersion Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">$(SemanticVersion).0</AssemblyVersion>
</PropertyGroup>
<!-- Compiler flags -->
<PropertyGroup>
<DefineConstants Condition="'$(TargetFramework)' == '$(NETFXTargetFramework)'">$(DefineConstants);IS_DESKTOP</DefineConstants>
<DefineConstants Condition="'$(TargetFramework)' != '$(NETFXTargetFramework)'">$(DefineConstants);IS_CORECLR</DefineConstants>
</PropertyGroup>
<!-- Include shared files for test netcore projects -->
<ItemGroup Condition="'$(SkipShared)' != 'true' AND '$(TestProject)' == 'true' ">
<Compile Include="$(BuildCommonDirectory)TestShared\*.cs" />
</ItemGroup>
<Target Name="_NuGetClientAddVsThreadingAnalyzerAdditionalFiles" AfterTargets="ResolvePackageAssets;ResolveNuGetPackageAssets">
<ItemGroup Condition=" '@(PackageDependencies->AnyHaveMetadataValue('Identity', 'Microsoft.VisualStudio.Threading.Analyzers'))' == 'true'
OR '@(ReferencedNuGetPackages->AnyHaveMetadataValue('Identity', 'Microsoft.VisualStudio.Sdk'))' == 'true' ">
<AdditionalFiles Include="$(SharedDirectory)\vs-threading.*.txt" />
</ItemGroup>
</Target>
<Import Project="sign.targets" Condition=" '$(SkipSigning)' != 'true' "/>
<PropertyGroup Condition="'$(Shipping)' == 'true'">
<GetSymbolsToIndexDependsOn Condition="'$(GetSymbolsToIndexDependsOn)' == ''">GetSymbolsToIndexDefault</GetSymbolsToIndexDependsOn>
<SymbolTargetsToGetPdbs Condition="'$(SymbolTargetsToGetPdbs)' == ''">GetDebugSymbolsProjectOutput</SymbolTargetsToGetPdbs>
</PropertyGroup>
<ImportGroup Condition=" '$(PackProject)' == 'true' AND '$(NuGetBuildTasksPackTargets)' != '' ">
<Import Project="$(NuGetBuildTasksPackTargets)" />
</ImportGroup>
<!-- Readme file in shipping packages -->
<PropertyGroup Condition=" '$(PackProject)' == 'true' ">
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(PackProject)' != 'true' ">
<NoWarn>$(NoWarn);CS0419;CS1570;CS1572;CS1573;CS1574;CS1584;CS1587;CS1591</NoWarn>
</PropertyGroup>
<ItemGroup Condition=" '$(PackProject)' == 'true' ">
<None Include="$(MSBuildThisFileDirectory)..\icon.png" Pack="true" PackagePath="\" Visible="false" />
<None Include="$(MSBuildProjectDirectory)\README.md" Pack="true" PackagePath="\"/>
</ItemGroup>
<!-- Don't use PublicApiAnalyzer on source-build .NET -->
<PropertyGroup Condition=" '$(DotNetBuildSourceOnly)' == 'true' ">
<UsePublicApiAnalyzer>false</UsePublicApiAnalyzer>
</PropertyGroup>
<!-- Projects we pack become public APIs that others can use -->
<PropertyGroup Condition=" '$(DotNetBuildSourceOnly)' != 'true' and '$(PackProject)' == 'true' ">
<UsePublicApiAnalyzer Condition=" '$(UsePublicApiAnalyzer)' == '' " >true</UsePublicApiAnalyzer>
</PropertyGroup>
<Target Name="UnknownUsePublicApiAnalyzerValue"
AfterTargets="Restore"
Condition=" '$(UsePublicApiAnalyzer)' != ''
and '$(UsePublicApiAnalyzer)' != 'true'
and '$(UsePublicApiAnalyzer)' != 'false'
and '$(UsePublicApiAnalyzer)' != 'perTfm' ">
<Error Text="Unknown/Unsupported value for UsePublicApiAnalyzer: $(UsePublicApiAnalyzer)" />
</Target>
<!-- Test Projects -->
<ImportGroup Condition=" '$(TestProject)' == 'true' ">
<Import Project="test.targets" />
</ImportGroup>
<!-- Allow WPF projects to run under NETCore SDK -->
<!-- Errors occur if the output path is not set correctly -->
<PropertyGroup Condition=" '$(NETCoreWPFProject)' == 'true' ">
<BaseOutputPath>bin\</BaseOutputPath>
<OutputPath>bin\$(Configuration)</OutputPath>
<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
</PropertyGroup>
<!-- These are needed because currently a VSIX project cannot reference a net core project that multi targets.
This is a hack for building the VSIX. It's because all these targets are available in the inner build, while the VSIX project
is non netcore, and isn't aware of inner/outer builds. -->
<Target Name="BuiltProjectOutputGroupDependencies" DependsOnTargets="PrintVSVersionAndNetcore" Condition="false" />
<Target Name="BuiltProjectOutputGroup" DependsOnTargets="PrintVSVersionAndNetcore" Condition="false" />
<Target Name="GetCopyToOutputDirectoryItems" DependsOnTargets="PrintVSVersionAndNetcore" Condition="false" />
<Target Name="SatelliteDllsProjectOutputGroup" DependsOnTargets="PrintVSVersionAndNetcore" Condition="false" />
<Target Name="DebugSymbolsProjectOutputGroup" DependsOnTargets="PrintVSVersionAndNetcore" Condition="false" />
<!--
============================================================
TestProject
Runs tests on the current project if it is a test project.
============================================================
-->
<Target Name="TestProject" Condition=" '$(TestProject)' == 'true' " DependsOnTargets="VSTest">
<Message Text="Tested project $(MSBuildProjectName)" Importance="high" />
</Target>
<!--
============================================================
PackProjects
This must be called after building. The dependency on build does
not exist to improve perf.
============================================================
-->
<Target Name="PackProjects" Condition=" '$(PackProject)' == 'true' ">
<!-- Run pack on the project -->
<MSBuild
Projects="$(MSBuildProjectFullPath)"
Targets="Pack"
Properties="Configuration=$(Configuration);
PackageOutputPath=$(NupkgOutputDirectory);
IncludeSymbols=true;
NoBuild=true;">
</MSBuild>
</Target>
<!--
============================================================
_IsProjectNeedsPack
Verify if the project needs to be packed.
============================================================
-->
<Target Name="_IsProjectNeedsPack" Returns="@(PackProjects)">
<ItemGroup Condition="'$(PackProject)' == 'true'">
<PackProjects Include="$(MSBuildProjectFullPath)">
</PackProjects>
</ItemGroup>
</Target>
<!--
============================================================
GetSymbolsToIndex - depends on targets that gather symbols that
need to be indexed on the symbol server.
============================================================
-->
<Target Name="GetSymbolsToIndex" DependsOnTargets="$(GetSymbolsToIndexDependsOn)" Returns="@(SymbolFilesToIndex)" />
<Target Name="GetSymbolsToIndexDefault" DependsOnTargets="GetTargetFrameworkSet" Returns="@(SymbolFilesToIndex)" Condition=" '$(Shipping)' == 'true' ">
<MSBuild
Projects="$(MSBuildProjectFullPath)"
Targets="$(SymbolTargetsToGetPdbs)"
Properties="TargetFramework=%(ProjectTargetFrameworkEntries.Identity);
BuildProjectReferences=false;">
<Output
TaskParameter="TargetOutputs"
ItemName="SymbolFilesToIndex" />
</MSBuild>
</Target>
<Target Name="GetXPLATProject" Returns="@(XPLATProjects)">
<ItemGroup Condition="'$(XPLATProject)' == 'true'">
<XPLATProjects Include="$(MSBuildProjectFullPath)">
</XPLATProjects>
</ItemGroup>
</Target>
<Target Name="GetDebugSymbolsProjectOutput" DependsOnTargets="DebugSymbolsProjectOutputGroup" Returns="@(PdbsToIndex)">
<ItemGroup>
<PdbsToIndex Include="@(DebugSymbolsProjectOutputGroupOutput->'%(FinalOutputPath)')"/>
</ItemGroup>
</Target>
<!--
============================================================
GetLocalizedFiles - gathers the list of files that have been
localized from each project
============================================================
-->
<!--Target is invoked by build\build.proj\MoveLocalizedFilesToLocalizedArtifacts to get all the localized files from all projects-->
<Target Name="GetNetCoreLocalizedFilesInProjectOutputPath" Returns="@(_LocalizedNetCoreDllsWithRelativeTargetPath)" Condition=" '$(PackProject)' == 'true' ">
<ItemGroup>
<_LocalizedDllsNetCoreApp Include="$(OutputPath)$(NETCoreTargetFramework)\**\$(AssemblyName).resources.dll"/>
<_LocalizedDllsNetCoreApp Include="$(OutputPath)$(LatestNETCoreTargetFramework)\**\$(AssemblyName).resources.dll"/>
<_LocalizedDllsNetStandard Include="$(OutputPath)$(NetStandardVersion)\**\$(AssemblyName).resources.dll"/>
<_LocalizedNetCoreDllsWithRelativeTargetPath Include="@(_LocalizedDllsNetCoreApp)" Condition=" '@(_LocalizedDllsNetCoreApp)' != '' ">
<RelativeTargetPath>$(NetStandardVersion)\%(_LocalizedDllsNetCoreApp.RecursiveDir)%(_LocalizedDllsNetCoreApp.FileName)%(_LocalizedDllsNetCoreApp.Extension)</RelativeTargetPath>
</_LocalizedNetCoreDllsWithRelativeTargetPath>
<_LocalizedNetCoreDllsWithRelativeTargetPath Include="@(_LocalizedDllsNetStandard)" Condition=" '@(_LocalizedDllsNetStandard)' != '' ">
<RelativeTargetPath>$(NetStandardVersion)\%(_LocalizedDllsNetStandard.RecursiveDir)%(_LocalizedDllsNetStandard.FileName)%(_LocalizedDllsNetStandard.Extension)</RelativeTargetPath>
</_LocalizedNetCoreDllsWithRelativeTargetPath>
</ItemGroup>
</Target>
<!--
============================================================
GetTestAssemblies
============================================================
-->
<Target Name="GetTestAssemblies"
DependsOnTargets="Build;GetTargetFrameworkSet"
Condition=" '$(TestProject)' == 'true' AND '$(SkipTests)' != 'true' "
Returns="@(TestAssemblyPath)">
<Message Text="Discovering test assemblies for $(AssemblyName)" Importance="high" />
<!-- Execute find for all frameworks -->
<MSBuild
Projects="$(MSBuildProjectFullPath)"
Targets="GetTestAssembliesInner"
Properties="TargetFramework=%(ProjectTargetFrameworkEntries.Identity);
Configuration=$(Configuration);">
<Output TaskParameter="TargetOutputs"
ItemName="TestAssemblyPath" />
</MSBuild>
</Target>
<!--
============================================================
GetTestAssembliesInner
============================================================
-->
<Target Name="GetTestAssembliesInner"
Returns="@(TestAssemblyPath)">
<PropertyGroup>
<TestAssemblyRelativePath>$(OutputPath)$(AssemblyName).dll</TestAssemblyRelativePath>
</PropertyGroup>
<ConvertToAbsolutePath Paths="$(TestAssemblyRelativePath)">
<Output TaskParameter="AbsolutePaths" PropertyName="AbsoluteTestAssemblyPath"/>
</ConvertToAbsolutePath>
<ItemGroup>
<TestAssemblyPath Include="$(AbsoluteTestAssemblyPath)">
<IsDesktop Condition=" '$(TargetFramework)' == '$(NETFXTargetFramework)' ">true</IsDesktop>
<IsCore Condition=" '$(TargetFramework)' != '$(NETFXTargetFramework)' ">true</IsCore>
</TestAssemblyPath>
</ItemGroup>
</Target>
<!--
============================================================
GetTargetFrameworkSet get all target frameworks
============================================================
-->
<Target Name="GetTargetFrameworkSet" Returns="@(ProjectTargetFrameworkEntries)">
<!-- Find all frameworks to run on -->
<ItemGroup>
<ProjectTargetFrameworkEntries Include="$(TargetFramework);$(TargetFrameworks)" />
</ItemGroup>
</Target>
<!--
============================================================
EnsureNewtonsoftJsonVersion ensures that the resolved version of Newtonsoft.Json is the version that ships with VS/.NET Core SDK
============================================================
-->
<Target Name="EnsureNewtonsoftJsonVersion" AfterTargets="ResolveAssemblyReferences">
<Error
Text="Newtonsoft.Json must be version $(NewtonsoftJsonPackageVersion) but resolved %(Reference.NuGetPackageVersion)"
Condition=" %(Reference.NuGetPackageId) == 'Newtonsoft.Json' AND %(Reference.NuGetPackageVersion) != '$(NewtonsoftJsonPackageVersion)' " />
</Target>
<Target Name="GetAllTargetFrameworks">
<PropertyGroup>
<EffectiveFramework Condition=" '$(TargetFrameworks)' != '' ">$(TargetFrameworks)</EffectiveFramework>
<EffectiveFramework Condition=" '$(EffectiveFramework)' == '' ">$(TargetFramework)</EffectiveFramework>
</PropertyGroup>
<Message
Text="$(MSBuildProjectFile) = $(EffectiveFramework)" Importance="High" />
</Target>
</Project>