-
Notifications
You must be signed in to change notification settings - Fork 352
/
Build.proj
345 lines (287 loc) · 18.6 KB
/
Build.proj
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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. -->
<Project DefaultTargets="Execute">
<!--
Required parameters:
RepoRoot Repository root.
Projects List of projects to build. Semicolon separated, may include globs.
Optional parameters:
Configuration Build configuration: "Debug", "Release", etc.
DotNetBuildRepo Build the repo as part of the entire .NET stack.
DotNetBuildInnerRepo Build the repo as part of the entire .NET stack. This switch is used on the inner repo invocation and should not be passed by the user.
DotNetBuildOrchestrator Build the entire .NET stack.
DotNetBuildPass While building the repo as part of the entire .NET stack, this parameter specifies which build pass the current build is part of.
DotNetBuildSourceOnly Build the repo as part of the entire .NET stack with no external dependencies.
DotNetBuildFromSource Building the entire stack from source with no external dependencies.
DotNetPublishUsingPipelines Publish assets to Build Asset Registry.
DotNetSymbolServerTokenMsdl Personal access token for MSDL symbol server. Available from variable group DotNet-Symbol-Server-Pats.
DotNetSymbolServerTokenSymWeb Personal access token for SymWeb symbol server. Available from variable group DotNet-Symbol-Server-Pats.
DotNetSymbolExpirationInDays Symbol expiration time in days (defaults to 10 years).
DotNetSignType Specifies the signing type: 'real' (default), 'test'.
DotNetRuntimeSourceFeed Storage account to lookup for the .Net runtime files
DotNetRuntimeSourceFeedKey In case the storage account to fetch the .Net runtime files are private this should contain a SAS token.
ContinuousIntegrationBuild "true" when building on a CI server (PR build or official build)
Restore "true" to restore toolset and solution
Build "true" to build solution
Rebuild "true" to rebuild solution
Deploy "true" to deploy assets (e.g. VSIXes)
Test "true" to run tests
IntegrationTest "true" to run integration tests
PerformanceTest "true" to run performance tests
Pack "true" to build NuGet packages and VS insertion manifests
Sign "true" to sign built binaries
Publish "true" to publish artifacts (e.g. symbols)
-->
<PropertyGroup>
<_OriginalProjectsValue>$(Projects)</_OriginalProjectsValue>
<!-- Disable target framework filtering for top level projects -->
<NoTargetFrameworkFiltering>true</NoTargetFrameworkFiltering>
</PropertyGroup>
<ItemDefinitionGroup>
<ProjectToBuild>
<RestoreInParallel>true</RestoreInParallel>
<BuildInParallel>true</BuildInParallel>
<DotNetBuildPass>1</DotNetBuildPass>
</ProjectToBuild>
</ItemDefinitionGroup>
<Import Project="RepoDefaults.props"/>
<Import Project="RepoLayout.props"/>
<Import Project="SourceBuild/SourceBuildArcadeBuild.targets" Condition="'$(ArcadeBuildFromSource)' == 'true' or '$(DotNetBuildRepo)' == 'true'" />
<!-- Allow for repo specific Build properties such as the list of Projects to build -->
<Import Project="$(RepositoryEngineeringDir)Build.props" Condition="Exists('$(RepositoryEngineeringDir)Build.props')" />
<PropertyGroup>
<_ProjectsPropertyWasUpdatedInBuildProps Condition="'$(_OriginalProjectsValue)' != '$(Projects)'">true</_ProjectsPropertyWasUpdatedInBuildProps>
<!-- An empty DotNetBuildPass refers to the 1st build pass. -->
<_DotNetBuildPassNormalized Condition="'$(DotNetBuildPass)' != ''">$(DotNetBuildPass)</_DotNetBuildPassNormalized>
<_DotNetBuildPassNormalized Condition="'$(DotNetBuildPass)' == ''">1</_DotNetBuildPassNormalized>
</PropertyGroup>
<ItemGroup Condition="'$(Projects)' != ''">
<!-- Copy the original list so we can log diagnostics later. -->
<_OriginalProjectToBuild Include="@(ProjectToBuild)" />
<!-- Setting 'Projects' overrides the ProjectToBuild list. -->
<ProjectToBuild Remove="@(ProjectToBuild)" />
<ProjectToBuild Include="$(Projects)" />
</ItemGroup>
<!--
Filter out projects that are part of a different build pass in the inner build when doing a unified build.
Don't do this filtering in non-unified builds to allow repos to define how different build passes are handled
in their own repo-specific builds.
-->
<ItemGroup Condition="'$(DotNetBuildInnerRepo)' == 'true'">
<_ProjectToBuildCurrentBuildPass Include="@(ProjectToBuild->WithMetadataValue('DotNetBuildPass', '$(_DotNetBuildPassNormalized)'))" />
<ProjectToBuild Remove="@(ProjectToBuild)" />
<ProjectToBuild Include="@(_ProjectToBuildCurrentBuildPass)" />
</ItemGroup>
<!--
Default values.
If Projects is unspecified and ProjectToBuild was not set via Build.props, fallback to building .sln files in the repo root.
For build passes after the first, build nothing by default.
-->
<ItemGroup Condition="'@(ProjectToBuild)' == '' and '$(_DotNetBuildPassNormalized)' == '1'">
<ProjectToBuild Include="$(RepoRoot)*.sln" />
</ItemGroup>
<Target Name="Execute">
<Error Text="No projects were found to build. Either the 'Projects' property or 'ProjectToBuild' item group must be specified." Condition="'@(ProjectToBuild)' == ''"/>
<Error Text="Property 'RepoRoot' must be specified" Condition="'$(RepoRoot)' == ''"/>
<Error Text="File 'global.json' must exist in directory specified by RepoRoot: '$(RepoRoot)'" Condition="'$(RepoRoot)' != '' and !Exists('$(RepoRoot)global.json')"/>
<PropertyGroup>
<!-- 'IsRunningFromVisualStudio' may be true even when running msbuild.exe from command line. This generally means that MSBuild is from a Visual Studio installation and therefore we need to find NuGet.targets in a different location. -->
<_NuGetRestoreTargets Condition="Exists('$(MSBuildToolsPath)\NuGet.targets')" >$(MSBuildToolsPath)\NuGet.targets</_NuGetRestoreTargets>
<_NuGetRestoreTargets Condition="'$([MSBuild]::IsRunningFromVisualStudio())' == 'true' And Exists('$(MSBuildToolsPath32)\..\..\..\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.targets')">$(MSBuildToolsPath32)\..\..\..\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.targets</_NuGetRestoreTargets>
<!-- If `DotNetPublishUsingPipelines` is not set we default it to false. -->
<DotNetPublishUsingPipelines Condition="'$(DotNetPublishUsingPipelines)' == ''">false</DotNetPublishUsingPipelines>
<!--
If DotNetPublishUsingPipelines is set we don't publish symbols during the build stage,
only in the Maestro post-build stages. If DotNetPublishUsingPipelines is NOT set then
we publish symbols during the build stage.
-->
<PublishToSymbolServer>true</PublishToSymbolServer>
<PublishToSymbolServer Condition="'$(DotNetPublishUsingPipelines)' == 'true'">false</PublishToSymbolServer>
</PropertyGroup>
<ItemGroup>
<_SolutionBuildTargets Include="Rebuild" Condition="'$(Rebuild)' == 'true'" />
<_SolutionBuildTargets Include="Build" Condition="'$(Build)' == 'true' and '$(Rebuild)' != 'true'" />
<!-- Deploy target is set up to chain after Build so that F5 in VS works. -->
<_SolutionBuildTargets Include="Test" Condition="'$(Test)' == 'true'" />
<!-- Pack before running integration and performance tests so that these tests can test packages produced by the repo. -->
<_SolutionBuildTargets Include="Pack" Condition="'$(Pack)' == 'true'" />
<_SolutionBuildTargets Include="IntegrationTest" Condition="'$(IntegrationTest)' == 'true'" />
<_SolutionBuildTargets Include="PerformanceTest" Condition="'$(PerformanceTest)' == 'true'" />
</ItemGroup>
<PropertyGroup>
<_RemoveProps>Projects;Restore;Deploy;Sign;Publish;NETCORE_ENGINEERING_TELEMETRY;@(_SolutionBuildTargets)</_RemoveProps>
</PropertyGroup>
<ItemGroup>
<_CommonProps Include="Configuration=$(Configuration)"/>
<_CommonProps Include="ContinuousIntegrationBuild=$(ContinuousIntegrationBuild)"/>
<_CommonProps Include="RepoRoot=$(RepoRoot)"/>
<_CommonProps Include="VersionsPropsPath=$(VersionsPropsPath)"/>
<!--
When building in source-only or product scenarios, some projects may have set ExcludeFromSourceBuild=true or ExcludeFromDotNetBuild.
NuGet Restore task reports a warning for such projects, which we suppress here.
-->
<_CommonProps Include="DisableWarnForInvalidRestoreProjects=true" Condition="'$(DotNetBuildFromSource)' == 'true' or '$(DotNetBuild)' == 'true'"/>
<!--
C++ projects expect VCTargetsPath property to be set. MSBuild generates this property to solution
metaproject when solution is build directly, but doesn't do so when the solution is built using MSBuild task.
-->
<_CommonProps Include="VCTargetsPath=$([MSBuild]::ValueOrDefault('$(VCTargetsPath)', '$([MSBuild]::GetVsInstallRoot())\Common7\IDE\VC\VCTargets\'))" Condition="'$(MSBuildRuntimeType)' != 'Core'"/>
</ItemGroup>
<ItemGroup Condition="'$(Restore)' == 'true'">
<_RestoreToolsProps Include="@(_CommonProps)"/>
<_RestoreToolsProps Include="BaseIntermediateOutputPath=$(ArtifactsToolsetDir)Common"/>
<_RestoreToolsProps Include="ExcludeRestorePackageImports=true"/>
<_RestoreToolsProps Include="_NuGetRestoreTargets=$(_NuGetRestoreTargets)"/>
<!-- Used in the SDK (Tools.proj) to control whether Build.Tasks.Feed will be restored or not. -->
<_RestoreToolsProps Include="Publish=$(Publish)"/>
<!-- Used in the SDK (Tools.proj) to control whether SymbolUploader.Build.Task will be restored or not. -->
<_RestoreToolsProps Include="PublishToSymbolServer=$(PublishToSymbolServer)"/>
<!-- Forward this property because we can't assume it will be available globally. -->
<_RestoreToolsProps Include="DotNetPublishUsingPipelines=$(DotNetPublishUsingPipelines)"/>
</ItemGroup>
<!--
Builds from the 'internal' project, and only those, can download the .net Runtime
from a private location.
-->
<ItemGroup Condition="'$(SYSTEM_TEAMPROJECT)' == 'internal'">
<_RestoreToolsProps Include="DotNetRuntimeSourceFeed=$(DotNetRuntimeSourceFeed)"/>
<_RestoreToolsProps Include="DotNetRuntimeSourceFeedKey=$(DotNetRuntimeSourceFeedKey)"/>
</ItemGroup>
<ItemGroup>
<_PublishProps Include="@(_CommonProps)"/>
<!-- Used in a few places in the stack to decide if publishing was enabled or not. -->
<_PublishProps Include="Publish=$(Publish)"/>
<!-- Used in the SDK (Publish.proj) to control whether in-build symbol publishing should be performed. -->
<_PublishProps Include="PublishToSymbolServer=$(PublishToSymbolServer)"/>
<!-- Forward this property because we can't assume it will be available globally. -->
<_PublishProps Include="DotNetPublishUsingPipelines=$(DotNetPublishUsingPipelines)"/>
</ItemGroup>
<ItemGroup>
<_SolutionBuildProps Include="@(_CommonProps)"/>
<_SolutionBuildProps Include="__DeployProjectOutput=$(Deploy)" Condition="'$(Deploy)' != ''"/>
<_SolutionBuildProps Include="__ImportPackTargets=true" Condition="'$(Pack)' == 'true'" />
</ItemGroup>
<!--
Restore built-in tools.
-->
<MSBuild Projects="Tools.proj"
Targets="Restore"
Properties="@(_RestoreToolsProps);_NETCORE_ENGINEERING_TELEMETRY=Restore"
Condition="'$(Restore)' == 'true'"/>
<!--
Restore solutions and projects.
Run solution restore separately from the other targets, in a different build phase.
Since restore brings in new .props and .targets files we need to rerun evaluation.
Workarounds:
- Invoke restore using NuGet.targets directly (see https://github.com/NuGet/Home/issues/7648).
This avoids duplicate calls to RestoreTask and race conditions on writing restore results to disk.
- msbuild caches the metaproject for the solution (see https://github.com/Microsoft/msbuild/issues/1695)
We invalidate the cache by changing the value of __BuildPhase property.
-->
<ItemGroup>
<_SolutionRestoreProps Include="@(_SolutionBuildProps)" />
<_SolutionRestoreProps Include="__BuildPhase=SolutionRestore" />
<_SolutionRestoreProps Include="_NETCORE_ENGINEERING_TELEMETRY=Restore" />
<_SolutionRestoreProps Include="MSBuildRestoreSessionId=$([System.Guid]::NewGuid())" />
<_SolutionRestoreProps Include="RestoreUseStaticGraphEvaluation=$(RestoreUseStaticGraphEvaluation)" />
</ItemGroup>
<PropertyGroup>
<!-- This can be set to false as an optimization for repos that don't use NuGet. -->
<RestoreUsingNuGetTargets Condition="'$(RestoreUsingNuGetTargets)' == ''">true</RestoreUsingNuGetTargets>
</PropertyGroup>
<!--
Detect which projects support restoring with NuGet targets.
As a perf optimization, the Properties list here should match exactly with
the properties passed to the "Restore" target a few lines below.
This helps MSBuild cache the result of _IsProjectRestoreSupported.
No need to call into the nuget internal target when restoring using
the new msbuild static graph APIs (RestoreUseStaticGraphEvaluation=true).
-->
<MSBuild Projects="@(ProjectToBuild)"
Properties="@(_SolutionRestoreProps)"
RemoveProperties="$(_RemoveProps)"
Targets="_IsProjectRestoreSupported"
SkipNonexistentTargets="true"
BuildInParallel="true"
Condition="'$(RestoreUsingNuGetTargets)' != 'false' and '%(ProjectToBuild.Extension)' != '.sln' and '%(ProjectToBuild.Extension)' != '.slnf' and '$(RestoreUseStaticGraphEvaluation)' != 'true' and '$(Restore)' == 'true'">
<Output TaskParameter="TargetOutputs" ItemName="_ProjectToRestoreWithNuGet" />
</MSBuild>
<PropertyGroup>
<!-- Normalize paths to avoid false warnings by NuGet about missing project references. -->
<_ProjectToRestoreWithNuGetList>@(_ProjectToRestoreWithNuGet->'%(FullPath)')</_ProjectToRestoreWithNuGetList>
</PropertyGroup>
<ItemGroup>
<_ProjectToRestore Include="$(_NuGetRestoreTargets)" Condition="'$(_ProjectToRestoreWithNuGetList)' != '' and '$(RestoreUsingNuGetTargets)' != 'false'">
<AdditionalProperties>RestoreGraphProjectInput=$(_ProjectToRestoreWithNuGetList)</AdditionalProperties>
<RestoreInParallel>true</RestoreInParallel>
</_ProjectToRestore>
<!-- Invoke the 'Restore' target on solutions and projects which do not support NuGet. -->
<_ProjectToRestore Include="@(ProjectToBuild)" Exclude="@(_ProjectToRestoreWithNuGet)" />
</ItemGroup>
<!-- Enable binlog generation during static graph restore evaluation -->
<ItemGroup Condition="'$(GenerateRestoreUseStaticGraphEvaluationBinlog)' == 'true'">
<_ProjectToRestore>
<AdditionalProperties>RESTORE_TASK_BINLOG_PARAMETERS=$(ArtifactsLogDir)Restore-%(Filename)%(Extension).binlog</AdditionalProperties>
</_ProjectToRestore>
</ItemGroup>
<MSBuild Projects="@(_ProjectToRestore)"
Properties="@(_SolutionRestoreProps)"
RemoveProperties="$(_RemoveProps);TreatWarningsAsErrors"
Targets="Restore"
SkipNonexistentTargets="true"
BuildInParallel="%(_ProjectToRestore.RestoreInParallel)"
Condition="'$(Restore)' == 'true'"/>
<!--
Build solution.
-->
<MSBuild Projects="@(ProjectToBuild)"
Properties="@(_SolutionBuildProps);__BuildPhase=SolutionBuild;_NETCORE_ENGINEERING_TELEMETRY=Build"
RemoveProperties="$(_RemoveProps)"
Targets="@(_SolutionBuildTargets)"
BuildInParallel="%(ProjectToBuild.BuildInParallel)"
Condition="'@(_SolutionBuildTargets)' != ''" />
<MSBuild Projects="AfterSolutionBuild.proj"
Properties="@(_CommonProps);_NETCORE_ENGINEERING_TELEMETRY=Build"
Targets="@(_SolutionBuildTargets)"
Condition="'@(_SolutionBuildTargets)' != ''" />
<!--
Sign artifacts.
-->
<MSBuild Projects="Sign.proj"
Properties="@(_CommonProps)"
Targets="Sign"
Condition="'$(Sign)' == 'true'"/>
<MSBuild Projects="AfterSigning.proj"
Properties="@(_CommonProps);_NETCORE_ENGINEERING_TELEMETRY=Sign"
Targets="@(_SolutionBuildTargets)"
Condition="'@(_SolutionBuildTargets)' != ''"/>
<!--
Perform post-source-build tasks. Validate source-build requirements, such as the prebuilt
usage baseline, and generate the source-build intermediate nupkg.
Only run this when we are actually building/packing something (vs. just restoring).
-->
<MSBuild Projects="SourceBuild\AfterSourceBuild.proj"
Properties="@(_CommonProps);_NETCORE_ENGINEERING_TELEMETRY=AfterSourceBuild"
Condition="'@(_SolutionBuildTargets)' != '' and ('$(ArcadeBuildFromSource)' == 'true' or '$(DotNetBuildRepo)' == 'true')"/>
<!--
Publish artifacts. This should run in the following situations:
- Regular single repo builds
- When running in the outer build phase of a source-only repo build, to properly publish the source-build intermediate nupkg.
- VMR builds
- When running in the inner build phase
It shouldn't run:
- In an inner build if running from single repo build.
- In an outer build if running from the full product build.
-->
<PropertyGroup>
<_VmrBuild Condition="'$(DotNetBuildFromSourceFlavor)' == 'Product' or '$(DotNetBuildOrchestrator)' == 'true'">true</_VmrBuild>
<_InnerRepoBuild Condition="'$(ArcadeInnerBuildFromSource)' == 'true' or '$(DotNetBuildPhase)' == 'InnerRepo'">true</_InnerRepoBuild>
<_ShouldRunPublish Condition="'$(_InnerRepoBuild)' == 'true' and '$(_VmrBuild)' == 'true'">true</_ShouldRunPublish>
<_ShouldRunPublish Condition="'$(_InnerRepoBuild)' != 'true' and '$(_VmrBuild)' != 'true'">true</_ShouldRunPublish>
</PropertyGroup>
<!-- Make sure we always publish in VMR build - working around runtime repo which sets Publish to false. -->
<MSBuild Projects="Publish.proj"
Properties="@(_PublishProps);_NETCORE_ENGINEERING_TELEMETRY=Publish"
Targets="Publish"
Condition="'$(Publish)' == 'true' and '$(_ShouldRunPublish)' == 'true'"/>
</Target>
</Project>