forked from dotnet/source-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.proj
282 lines (243 loc) · 18.2 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
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" InitialTargets="PrepareOutput" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="dir.props" />
<Import Project="eng/Versions.props" Condition="'$(OfflineBuild)' != 'true'" />
<UsingTask AssemblyFile="$(LeakDetectionTasksAssembly)" TaskName="CheckForPoison" />
<UsingTask AssemblyFile="$(XPlatSourceBuildTasksAssembly)" TaskName="CopyReferenceOnlyPackages" />
<UsingTask AssemblyFile="$(XPlatSourceBuildTasksAssembly)" TaskName="WriteUsageBurndownData" />
<Target Name="Build" DependsOnTargets="PrepareOutput;InitBuild">
<Message Text="Build Environment: $(Platform) $(Configuration) $(TargetOS) $(TargetRid)" />
<MSBuild Projects="repos\$(RootRepo).proj" Targets="Build" BuildInParallel="$(BuildInParallel)" StopOnFirstFailure="true" />
</Target>
<Target Name="RunTests" DependsOnTargets="PrepareOutput;InitBuild">
<Message Text="Build Environment: $(Platform) $(Configuration) $(TargetOS) $(TargetRid)" />
<MSBuild Projects="repos\$(RootRepoTests).proj" Targets="Build" Properties="PrepForTests=true;SkipEnsurePackagesCreated=true" BuildInParallel="$(BuildInParallel)" StopOnFirstFailure="true" />
<MSBuild Projects="repos\$(RootRepoTests).proj" Targets="Build" Properties="RunTests=true;SkipEnsurePackagesCreated=true" BuildInParallel="$(BuildInParallel)" StopOnFirstFailure="true" />
</Target>
<Target Name="CreateRootRepoFile" AfterTargets="PrepareOutput">
<WriteLinesToFile Lines="$(RootRepo)" File="$(BaseIntermediatePath)rootrepo.txt" Overwrite="True" />
</Target>
<Target Name="PrepareOutput">
<MakeDir Directories="$(OutputPath)" />
<MakeDir Directories="$(LoggingDir)" />
<MakeDir Directories="$(GitInfoOutputDir)" />
<MakeDir Directories="$(IntermediatePath)" />
<MakeDir Directories="$(SourceBuiltBlobFeedDir)" />
<MakeDir Directories="$(SourceBuiltPackagesPath)" />
<MakeDir Directories="$(SourceBuiltAssetsDir)" />
<MakeDir Directories="$(LocalBlobStorageRoot)" />
<MakeDir Directories="$(MSBuildDebugPathTargetDir)" />
<MakeDir Directories="$(RoslynDebugPathTargetDir)" />
<MakeDir Condition="'$(OfflineBuild)' != 'true'" Directories="$(GeneratedSourcePathOnline)" />
<MakeDir Condition="'$(OfflineBuild)' == 'true'" Directories="$(GeneratedSourcePathOffline)" />
</Target>
<Target Name="InitBuild">
<MSBuild Projects="tools-local/init-build.proj" />
</Target>
<Target Name="Clone">
<MSBuild Projects="tools-local/init-build.proj" Targets="FetchSources" />
</Target>
<Target Name="Clean">
<RemoveDir Directories="$(BaseOutputPath)" />
</Target>
<!--
Workaround: Skip Windows_NT.
When trying to CopyReferenceOnlyPackages, it gets errors like:
System.IO.IOException: The process cannot access the file
'<root>\packages\microsoft.codeanalysis.compilers\2.6.0-beta3-62316-02\microsoft.codeanalysis.compilers.nuspec'
because it is being used by another process.
We don't support producing a tarball on Windows, so there's little value in fixing this.
-->
<Target Name="CopyAndDisassembleReferenceOnlyPackages"
AfterTargets="Build"
Condition="'$(OfflineBuild)' != 'true' and '$(ArchiveDownloadedPackages)' == 'true' and '$(OS)' != 'Windows_NT'">
<CopyReferenceOnlyPackages
PackageCacheDir="$(PackagesDir)"
DllDestinationDir="$(ReferencePackagesSourceDir)"
IdentifiedPackagesDir="$(ReferencePackagesToDeleteDir)"
DestinationDir="$(ReferencePackagesStagingDir)"
/>
<!-- Ildasm has trouble writing to paths that are longer than 260 chars. (see https://github.com/dotnet/coreclr/issues/20397)
Create a temporary path to write il output which will then be copied back to the reference-packages/source dir.
-->
<PropertyGroup>
<TempPath>$([System.IO.Path]::GetTempPath())</TempPath>
<IldasmTempOutputFolderName>$([System.IO.Path]::GetRandomFileName())</IldasmTempOutputFolderName>
<IldasmTempOutputPath>$([System.IO.Path]::Combine($(TempPath),$(IldasmTempOutputFolderName)))/</IldasmTempOutputPath>
</PropertyGroup>
<ItemGroup>
<ReferenceOnlyPackages Include="$(ReferencePackagesToDeleteDir)**/*.nupkg" />
<ReferenceOnlyPackageDlls Include="$(ReferencePackagesSourceDir)**/*.dll" />
</ItemGroup>
<!-- Temporary workaround to exclude dlls that can't be round-tripped. See: https://github.com/dotnet/coreclr/issues/20262
They'll end up in the source directory as dlls for now
-->
<ItemGroup>
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/System.Runtime.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/netstandard.dll" />
<!-- Microsoft.AspNet.App DLLs that include .resource files -->
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.Antiforgery.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.Authentication.OAuth.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.Authentication.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.Authorization.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.Cors.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.Cryptography.Internal.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.DataProtection.Abstractions.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.DataProtection.Extensions.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.DataProtection.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.Diagnostics.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.Hosting.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.Http.Abstractions.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.Identity.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.Localization.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.Mvc.Abstractions.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.Mvc.Core.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.Mvc.Cors.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.Mvc.DataAnnotations.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.Mvc.Formatters.Xml.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.Mvc.Razor.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.Mvc.RazorPages.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.Mvc.TagHelpers.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.Mvc.ViewFeatures.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.Authorization.Policy.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.Razor.Runtime.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.Rewrite.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.Routing.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.Server.HttpSys.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.Server.IIS.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.Server.IIS.CoreStrings.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.Server.Kestrel.Core.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.Server.Kestrel.Core.CoreStrings.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketsStrings.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.Session.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.StaticFiles.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.AspNetCore.WebUtilities.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.Extensions.Configuration.Binder.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.Extensions.Configuration.CommandLine.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.Extensions.Configuration.FileExtensions.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.Extensions.Configuration.Ini.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.Extensions.Configuration.Json.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.Extensions.Configuration.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.Extensions.Configuration.UserSecrets.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.Extensions.Configuration.Xml.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.Extensions.DependencyInjection.Abstractions.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.Extensions.DependencyInjection.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.Extensions.DependencyModel.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.Extensions.Http.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.Extensions.Identity.Core.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.Extensions.Localization.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.Extensions.Logging.Abstractions.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.Extensions.Logging.Abstractions.Resource.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.Extensions.Options.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/Microsoft.Extensions.Primitives.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/System.Diagnostics.Contracts.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/System.IO.Pipelines.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/System.Memory.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/System.Text.Encodings.Web.dll" />
<ReferenceOnlyPackageDlls Remove="$(ReferencePackagesSourceDir)**/System.Threading.Channels.dll" />
</ItemGroup>
<!-- End Temporary workaround -->
<Message Importance="High" Text="Reference-only Packages:" />
<Message Importance="High" Text="%(ReferenceOnlyPackages.Identity)" />
<Message Importance="High" Text="[$([System.DateTime]::Now.ToString('HH:mm:ss.ff'))] Disassembling @(ReferenceOnlyPackageDlls->Count()) dlls" />
<MakeDir Directories="$(IldasmTempOutputPath)%(ReferenceOnlyPackageDlls.RecursiveDir)" />
<Exec Command="$(IldasmPath) %(ReferenceOnlyPackageDlls.Identity) -all -out=$(IldasmTempOutputPath)%(ReferenceOnlyPackageDlls.RecursiveDir)%(ReferenceOnlyPackageDlls.Filename).il" />
<Message Importance="High" Text="[$([System.DateTime]::Now.ToString('HH:mm:ss.ff'))] Disassembly done." />
<ItemGroup>
<IlSourceFiles Include="$(IldasmTempOutputPath)/**/*.il" />
</ItemGroup>
<Message Importance="High" Text="[$([System.DateTime]::Now.ToString('HH:mm:ss.ff'))] Copying @(IlSourceFiles->Count()) IL source files" />
<Copy SourceFiles="@(IlSourceFiles)" DestinationFiles="$(ReferencePackagesSourceDir)%(IlSourceFiles.RecursiveDir)%(IlSourceFiles.Filename).il" />
<Message Importance="High" Text="[$([System.DateTime]::Now.ToString('HH:mm:ss.ff'))] Copying IL source files done." />
<Message Importance="High" Text="[$([System.DateTime]::Now.ToString('HH:mm:ss.ff'))] Deleting disassembled dlls and temp il source" />
<Delete Files="@(ReferenceOnlyPackageDlls)" />
<RemoveDir Directories="$(IldasmTempOutputPath)" />
<Message Importance="High" Text="[$([System.DateTime]::Now.ToString('HH:mm:ss.ff'))] Deleting disassembled dlls and temp il source done." />
</Target>
<Target Name="DownloadSourceBuildReferencePackages"
AfterTargets="Build"
Condition="'$(OfflineBuild)' != 'true' and '$(OS)' != 'Windows_NT'">
<DownloadFile
SourceUrl="$(ReferencePackagesTarballUrl)$(ReferencePackagesTarballName).$(PrivateSourceBuildReferencePackagesPackageVersion).tar.gz"
DestinationFolder="$(ReferencePackagesTarballDir)" />
<MakeDir Directories="$(ReferencePackagesDir)" />
<Exec Command="tar -xzf $(ReferencePackagesTarballDir)$(ReferencePackagesTarballName).$(PrivateSourceBuildReferencePackagesPackageVersion).tar.gz"
WorkingDirectory="$(ReferencePackagesDir)" />
</Target>
<!-- After building, generate a prebuilt usage report. -->
<Target Name="ReportPrebuiltUsage"
AfterTargets="Build"
Condition="'$(SkipReportPrebuiltUsage)' != 'true'">
<MSBuild Projects="repos\$(RootRepo).proj" Targets="WritePrebuiltUsageData;ReportPrebuiltUsage" />
</Target>
<!--
Dev scenario: rewrite a prebuilt-report. This makes it easy to add data to an existing
prebuilt report without performing another full build. This doesn't reevalutate which packages
are prebuilts or search the projects: it uses the existing usage.xml file to generate report
XMLs based on the info put in bin/.
-->
<Target Name="RewritePrebuiltUsageReport">
<MSBuild Projects="repos\$(RootRepo).proj" Targets="ReportPrebuiltUsage" />
</Target>
<Target Name="ReportPoisonUsage"
AfterTargets="Build"
Condition="'$(EnablePoison)' == 'true' and '$(OfflineBuild)' == 'true'">
<ItemGroup>
<FinalCliTarball Include="$(SourceBuiltTarBallPath)**/*$(TarBallExtension)" />
</ItemGroup>
<CheckForPoison FilesToCheck="@(FinalCliTarball)"
HashCatalogFilePath="$(PoisonReportDataFile)"
MarkerFileName="$(PoisonMarkerFile)"
PoisonReportOutputFilePath="$(PoisonUsageReportFile)" />
</Target>
<Target Name="GeneratePrebuiltBurndownData">
<WriteUsageBurndownData RootDirectory="$(ProjectDir)"
PrebuiltBaselineFile="$(OnlineBaselineDataFile)"
OutputFilePath="$(OnlinePrebuiltBurndownDataFile)" />
<WriteUsageBurndownData RootDirectory="$(ProjectDir)"
PrebuiltBaselineFile="$(OfflineBaselineDataFile)"
OutputFilePath="$(OfflinePrebuiltBurndownDataFile)" />
</Target>
<Target Name="RunSmokeTest" DependsOnTargets="GetProdConBlobFeedUrl">
<PropertyGroup>
<SmokeTestCommand>./smoke-test.sh</SmokeTestCommand>
<SmokeTestCommand>$(SmokeTestCommand) --minimal</SmokeTestCommand>
<SmokeTestCommand>$(SmokeTestCommand) --projectOutput</SmokeTestCommand>
<SmokeTestCommand>$(SmokeTestCommand) --configuration $(Configuration)</SmokeTestCommand>
<SmokeTestCommand>$(SmokeTestCommand) --archiveRestoredPackages</SmokeTestCommand>
<!-- Dev certs don't work on this platform. -->
<SmokeTestCommand Condition="'$(TargetOS)' == 'OSX'">$(SmokeTestCommand) --excludeWebHttpsTests</SmokeTestCommand>
</PropertyGroup>
<!--
Pass prodConBlobFeedUrl via EnvironmentVariables because it has '//' in it, which is
translated into '/' if it's passed in the Command arg.
This is also a problem when passing CLI feeds: https://github.com/dotnet/source-build/issues/561
-->
<Exec Command="$(SmokeTestCommand)"
EnvironmentVariables="prodConBlobFeedUrl=$(ProdConBlobFeedUrl)" />
</Target>
<UsingTask AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.CloudTestTasks.dll" TaskName="UploadToAzure" />
<Target Name="PublishPrebuiltReportData">
<Error Text="RelativeBlobPath must be set to a non-empty string." Condition="'$(RelativeBlobPath)' == ''" />
<Error Text="ContainerName must be set to a non-empty string." Condition="'$(ContainerName)' == ''" />
<Error Text="AzureAccountName must be set to a non-empty string." Condition="'$(AzureAccountName)' == ''" />
<Error Text="AzureAccessToken must be set to a non-empty string." Condition="'$(AzureAccessToken)' == ''" />
<ItemGroup>
<ItemsToPublish Include="$(PackageReportDir)*.xml" />
<ItemsToPublish Include="$(PackageReportDir)*.csv" />
<ItemsToPublish>
<RelativeBlobPath>$(RelativeBlobPath)/%(Filename)%(Extension)</RelativeBlobPath>
</ItemsToPublish>
</ItemGroup>
<Message Text="Uploading files to '$(AzureAccountName)' blob storage at $(ContainerName)/$(RelativeBlobPath)" />
<UploadToAzure AccountName="$(AzureAccountName)"
AccountKey="$(AzureAccessToken)"
ContainerName="$(ContainerName)"
Items="@(ItemsToPublish)"
Overwrite="true" />
</Target>
<Import Project="$(ProjectDir)dependencies.targets" />
<Import Project="$(ToolsDir)VersionTools.targets" />
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))/dir.targets" />
</Project>