-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathfinish-source-only.proj
321 lines (268 loc) · 16.1 KB
/
finish-source-only.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
<Project Sdk="Microsoft.Build.NoTargets">
<PropertyGroup>
<!-- Need to set to false to calculate RepositoryCommit. -->
<EnableSourceControlManagerQueries>false</EnableSourceControlManagerQueries>
<TargetFramework>$(NetCurrent)</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="$(TasksDir)Microsoft.DotNet.UnifiedBuild.Tasks\Microsoft.DotNet.UnifiedBuild.Tasks.csproj" />
<ProjectReference Include="$(TasksDir)Microsoft.DotNet.SourceBuild.Tasks.LeakDetection\Microsoft.DotNet.SourceBuild.Tasks.LeakDetection.csproj" />
<ProjectReference Include="$(RepositoryEngineeringDir)extract-sdk-archive.proj" />
<ProjectReference Include="$(RepositoryEngineeringDir)merge-asset-manifests.proj" />
</ItemGroup>
<!-- After building, generate a prebuilt usage report. -->
<Target Name="ReportPrebuiltUsage"
BeforeTargets="Build"
Condition="'$(SkipReportPrebuiltUsage)' != 'true'">
<MSBuild Projects="$(RepoProjectsDir)$(RootRepo).proj" Targets="WritePrebuiltUsageData;ReportPrebuiltUsage" />
</Target>
<UsingTask TaskName="Microsoft.DotNet.UnifiedBuild.Tasks.WriteSBRPUsageReport" AssemblyFile="$(MicrosoftDotNetUnifiedBuildTasksAssembly)" TaskFactory="TaskHostFactory" />
<Target Name="ReportSbrpUsage"
BeforeTargets="Build"
Condition="'$(ReportSbrpUsage)' == 'true'">
<ItemGroup>
<ProjectAssetsJsonFile Include="$(ArtifactsDir)**/project.assets.json" />
<ProjectAssetsJsonFile Include="$(SrcDir)**/artifacts/**/project.assets.json" />
</ItemGroup>
<WriteSbrpUsageReport SbrpRepoSrcPath="$(SbrpRepoSrcDir)"
ProjectAssetsJsons="@(ProjectAssetsJsonFile)"
OutputPath="$(ArtifactsLogDir)" />
</Target>
<Target Name="DetermineSourceBuiltSdkNonStableVersion"
DependsOnTargets="DetermineSourceBuiltSdkVersion">
<ItemGroup>
<SdkVersionFileItem Include="$(DotNetSdkExtractDir)/sdk/**/.version" />
</ItemGroup>
<PropertyGroup>
<SourceBuiltSdkNonStableVersion>$([System.Text.RegularExpressions.Regex]::Split('$([System.IO.File]::ReadAllText('%(SdkVersionFileItem.Identity)'))', '\r\n|\r|\n')[3])</SourceBuiltSdkNonStableVersion>
</PropertyGroup>
</Target>
<!--
Determine symbols tarball names and discover all intermediate symbols,
to be used as inputs and outputs of symbols repackaging targets.
-->
<Target Name="DetermineSymbolsTargetsInputsAndOutputs"
AfterTargets="Build"
DependsOnTargets="DetermineSourceBuiltSdkNonStableVersion">
<PropertyGroup>
<UnifiedSymbolsTarball>$(ArtifactsAssetsDir)dotnet-symbols-all-$(SourceBuiltSdkNonStableVersion)-$(TargetRid)$(ArchiveExtension)</UnifiedSymbolsTarball>
<SdkSymbolsTarball>$(ArtifactsAssetsDir)dotnet-symbols-sdk-$(SourceBuiltSdkNonStableVersion)-$(TargetRid)$(ArchiveExtension)</SdkSymbolsTarball>
</PropertyGroup>
<ItemGroup>
<IntermediateSymbol Include="$(IntermediateSymbolsRootDir)**/*" />
</ItemGroup>
</Target>
<!-- After building, repackage symbols into a single tarball. -->
<Target Name="RepackageSymbols"
BeforeTargets="Build"
DependsOnTargets="DetermineSymbolsTargetsInputsAndOutputs"
Inputs="@(IntermediateSymbol)"
Outputs="$(UnifiedSymbolsTarball)">
<MakeDir Directories="$([System.IO.Path]::GetDirectoryName('$(UnifiedSymbolsTarball)'))" />
<Exec Command="tar --numeric-owner -czf $(UnifiedSymbolsTarball) *"
WorkingDirectory="$(IntermediateSymbolsRootDir)" />
<!-- Mark the artifact so that it gets binplaced. -->
<ItemGroup>
<BinPlaceFile Include="$(UnifiedSymbolsTarball)" />
</ItemGroup>
<Message Importance="High" Text="Packaged all symbols in '$(UnifiedSymbolsTarball)'" />
</Target>
<!-- After building, create the sdk symbols tarball. -->
<UsingTask TaskName="Microsoft.DotNet.UnifiedBuild.Tasks.CreateSdkSymbolsLayout" AssemblyFile="$(MicrosoftDotNetUnifiedBuildTasksAssembly)" TaskFactory="TaskHostFactory" />
<Target Name="CreateSdkSymbolsTarball"
BeforeTargets="Build"
DependsOnTargets="RepackageSymbols"
Inputs="@(IntermediateSymbol);$(SdkTarballPath)"
Outputs="$(SdkSymbolsTarball)">
<PropertyGroup>
<IntermediateSdkSymbolsLayout>$(BaseIntermediateOutputPath)SdkSymbols</IntermediateSdkSymbolsLayout>
</PropertyGroup>
<CreateSdkSymbolsLayout SdkLayoutPath="$(DotNetSdkExtractDir)"
AllSymbolsPath="$(IntermediateSymbolsRootDir)"
SdkSymbolsLayoutPath="$(IntermediateSdkSymbolsLayout)"
FailOnMissingPDBs="false" />
<Exec Command="tar --numeric-owner -czf $(SdkSymbolsTarball) *"
WorkingDirectory="$(IntermediateSdkSymbolsLayout)" />
<!-- Mark the artifact so that it gets binplaced. -->
<ItemGroup>
<BinPlaceFile Include="$(SdkSymbolsTarball)" />
</ItemGroup>
<Message Importance="High" Text="Packaged sdk symbols in '$(SdkSymbolsTarball)'" />
<RemoveDir Directories="$(IntermediateSdkSymbolsLayout)" />
</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 artifacts/.
-->
<Target Name="RewritePrebuiltUsageReport">
<MSBuild Projects="$(RepoProjectsDir)$(RootRepo).proj"
Targets="ReportPrebuiltUsage" />
</Target>
<UsingTask TaskName="Microsoft.DotNet.SourceBuild.Tasks.LeakDetection.CheckForPoison" AssemblyFile="$(MicrosoftDotNetSourceBuildTasksLeakDetectionAssembly)" TaskFactory="TaskHostFactory" Condition="'$(EnablePoison)' == 'true'" />
<Target Name="ReportPoisonUsage"
BeforeTargets="Build"
DependsOnTargets="CopySdkArchive"
Condition="'$(EnablePoison)' == 'true'"
Inputs="$(MSBuildProjectFullPath)"
Outputs="$(BaseIntermediateOutputPath)ReportPoisonUsage.complete" >
<ItemGroup>
<!-- Include dotnet-sdk-*.tar.gz -->
<AssetToCheck Include="$(ArtifactsAssetsDir)dotnet-sdk-*$(ArchiveExtension)" />
<!-- Include shipping nuget packages. -->
<ShippingPackageToCheck Include="$(ArtifactsShippingPackagesDir)**/*.nupkg" />
<!-- Add and mark SBRP packages to validate that they have the correct poison attribute. -->
<SbrpPackageToCheck Include="$(ReferencePackagesDir)**\*.nupkg" IsSourceBuildReferencePackage="true" />
</ItemGroup>
<Error Condition="'@(AssetToCheck)' == ''" Text="No assets will be poison checked - this is unexpected!" />
<Error Condition="'@(ShippingPackageToCheck)' == ''" Text="No shipping packages will be poison checked - this is unexpected!" />
<Error Condition="'@(SbrpPackageToCheck)' == ''" Text="No SBRP packages will be poison checked - this is unexpected!" />
<ItemGroup>
<PoisonFileToCheck Include="@(AssetToCheck)" />
<PoisonFileToCheck Include="@(ShippingPackageToCheck)" />
<PoisonFileToCheck Include="@(SbrpPackageToCheck)" />
</ItemGroup>
<Message Importance="High" Text="[$([System.DateTime]::Now.ToString('HH:mm:ss.ff'))] Checking @(PoisonFileToCheck) for poisoned files." />
<CheckForPoison FilesToCheck="@(PoisonFileToCheck)"
ProjectDirPath="$(RepoRoot)"
HashCatalogFilePath="$(PoisonReportDataFile)"
MarkerFileName="$(PoisonMarkerFile)"
PoisonReportOutputFilePath="$(PoisonUsageReportFile)" />
<Message Importance="High" Text="[$([System.DateTime]::Now.ToString('HH:mm:ss.ff'))] Done checking for poison." />
<MakeDir Directories="$(BaseIntermediateOutputPath)" />
<Touch Files="$(BaseIntermediateOutputPath)ReportPoisonUsage.complete" AlwaysCreate="true">
<Output TaskParameter="TouchedFiles" ItemName="FileWrites" />
</Touch>
</Target>
<UsingTask TaskName="Microsoft.DotNet.UnifiedBuild.Tasks.UsageReport.WriteUsageBurndownData" AssemblyFile="$(MicrosoftDotNetUnifiedBuildTasksAssembly)" TaskFactory="TaskHostFactory" />
<Target Name="GeneratePrebuiltBurndownData"
Inputs="$(MSBuildProjectFullPath)"
Outputs="$(BaseIntermediateOutputPath)GeneratePrebuiltBurndownData.complete" >
<PropertyGroup>
<PrebuiltBurndownDataFile>$(PackageReportDir)PrebuiltBurndownData.csv</PrebuiltBurndownDataFile>
</PropertyGroup>
<WriteUsageBurndownData RootDirectory="$(RepoRoot)"
PrebuiltBaselineFile="$(BaselineDataFile)"
OutputFilePath="$(PrebuiltBurndownDataFile)" />
<MakeDir Directories="$(BaseIntermediateOutputPath)" />
<Touch Files="$(BaseIntermediateOutputPath)GeneratePrebuiltBurndownData.complete" AlwaysCreate="true">
<Output TaskParameter="TouchedFiles" ItemName="FileWrites" />
</Touch>
</Target>
<Target Name="CreatePrebuiltsTarball"
BeforeTargets="Build"
DependsOnTargets="
CheckIfPrebuiltsExistToPack;
CreatePrebuiltsTarballIfPrebuiltsExist"/>
<Target Name="CheckIfPrebuiltsExistToPack">
<!-- Directory existence doesn't mean there are files inside. Use a pattern to find files. -->
<ItemGroup>
<PrebuiltFile Include="$(ResultingPrebuiltPackagesDir)**" />
</ItemGroup>
<Message Text="Found @(PrebuiltFile->Count()) files in prebuilt packages dir." Importance="High" />
</Target>
<Target Name="CreatePrebuiltsTarballIfPrebuiltsExist"
DependsOnTargets="DetermineSourceBuiltSdkNonStableVersion"
Condition="'@(PrebuiltFile)' != ''">
<PropertyGroup>
<PrebuiltsTarball>$(ArtifactsAssetsDir)$(SourceBuiltPrebuiltsTarballName).$(SourceBuiltSdkNonStableVersion).$(TargetRid)$(ArchiveExtension)</PrebuiltsTarball>
<PrebuiltsTarballWorkingDir>$(ResultingPrebuiltPackagesDir)</PrebuiltsTarballWorkingDir>
</PropertyGroup>
<MakeDir Directories="$([System.IO.Path]::GetDirectoryName('$(PrebuiltsTarball)'))" />
<Exec Command="tar --numeric-owner -zcf $(PrebuiltsTarball) -C $(PrebuiltsTarballWorkingDir) ." />
<!-- Mark the artifact so that it gets binplaced. -->
<ItemGroup>
<BinPlaceFile Include="$(PrebuiltsTarball)" />
</ItemGroup>
<Message Text="Tarball '$(PrebuiltsTarball)' was successfully created from '$(PrebuiltsTarballWorkingDir)'" Importance="High" />
</Target>
<Target Name="ErrorOnPrebuilts"
DependsOnTargets="CreatePrebuiltsTarball"
AfterTargets="BinPlaceFiles;Build"
Condition="'@(PrebuiltFile)' != '' and '$(SkipErrorOnPrebuilts)' != 'true'">
<Error Text="@(PrebuiltFile->Count()) Prebuilts Exist" />
</Target>
<Target Name="GetInputsOutputForCreatePrivateSourceBuiltArtifactsArchive"
DependsOnTargets="DetermineSourceBuiltSdkNonStableVersion;ResolveProjectReferences">
<!-- Inputs: Packages to include in the tarball -->
<ItemGroup>
<ArtifactsPackageToBundle Include="$(ArtifactsShippingPackagesDir)**;
$(ArtifactsNonShippingPackagesDir)**" />
<ArtifactsPackageToBundle Remove="@(ArtifactsPackageToBundle)"
Condition="$([System.String]::Copy('%(Identity)').EndsWith('.symbols.nupkg'))" />
<ReferencePackageToBundle Include="$(ReferencePackagesDir)**" />
<ReferencePackageToBundle Remove="@(ReferencePackageToBundle)"
Condition="$([System.String]::Copy('%(Identity)').EndsWith('.symbols.nupkg'))" />
<MergedAssetManifest Include="$(MergedAssetManifestOutputPath)" />
</ItemGroup>
<PropertyGroup>
<!-- Create a layout directory for the files that are to be included in the artifacts tarball. -->
<SourceBuiltLayoutDir>$([MSBuild]::NormalizeDirectory('$(BaseIntermediateOutputPath)', 'artifacts-layout'))</SourceBuiltLayoutDir>
<!-- Outputs -->
<SourceBuiltTarballName>$(ArtifactsAssetsDir)$(SourceBuiltArtifactsTarballName).$(SourceBuiltSdkNonStableVersion).$(TargetRid)$(ArchiveExtension)</SourceBuiltTarballName>
<SourceBuiltVersionName>$(SourceBuiltLayoutDir).version</SourceBuiltVersionName>
<AllPackageVersionsPropsName>$(SourceBuiltLayoutDir)PackageVersions.props</AllPackageVersionsPropsName>
<SourceBuiltMergedAssetManifestName>$(SourceBuiltLayoutDir)%(MergedAssetManifest.Filename)%(MergedAssetManifest.Extension)</SourceBuiltMergedAssetManifestName>
</PropertyGroup>
</Target>
<!-- Discover the produced packages from the merged asset manifest -->
<UsingTask TaskName="Microsoft.DotNet.UnifiedBuild.Tasks.GetKnownArtifactsFromAssetManifests" AssemblyFile="$(MicrosoftDotNetUnifiedBuildTasksAssembly)" TaskFactory="TaskHostFactory" />
<Target Name="GetProducedPackages" Returns="@(ProducedPackage)">
<GetKnownArtifactsFromAssetManifests AssetManifests="$(MergedAssetManifestOutputPath)">
<Output TaskParameter="KnownPackages" ItemName="ProducedPackage" />
</GetKnownArtifactsFromAssetManifests>
</Target>
<!-- Create the SourceBuilt.Private.Artifacts archive when building source-only. -->
<UsingTask TaskName="Microsoft.DotNet.UnifiedBuild.Tasks.WritePackageVersionsProps" AssemblyFile="$(MicrosoftDotNetUnifiedBuildTasksAssembly)" TaskFactory="TaskHostFactory" />
<Target Name="CreatePrivateSourceBuiltArtifactsArchive"
BeforeTargets="Build"
DependsOnTargets="GetInputsOutputForCreatePrivateSourceBuiltArtifactsArchive;GetProducedPackages"
Inputs="@(ArtifactsPackageToBundle);@(ReferencePackageToBundle);@(MergedAssetManifest)"
Outputs="$(SourceBuiltTarballName);$(SourceBuiltVersionName);$(AllPackageVersionsPropsName);$(SourceBuiltMergedAssetManifestName)">
<!-- Copy packages to layout directory. Since there are a large number of files,
this will use symlinks instead of copying files to make this execute quickly. -->
<Copy SourceFiles="@(ArtifactsPackageToBundle)"
DestinationFolder="$(SourceBuiltLayoutDir)"
UseSymbolicLinksIfPossible="true" />
<Copy SourceFiles="@(ReferencePackageToBundle)"
DestinationFolder="$(SourceBuiltLayoutDir)$(PreviouslySourceBuiltReferencePackagesDirName)"
UseSymbolicLinksIfPossible="true" />
<!-- Content of the .version file to include in the tarball -->
<ItemGroup>
<VersionFileContent Include="$(RepositoryCommit);$(SourceBuiltSdkNonStableVersion)" />
</ItemGroup>
<WriteLinesToFile File="$(SourceBuiltVersionName)"
Lines="@(VersionFileContent)"
Overwrite="true" />
<!-- Copy the merged asset manifest into the tarball -->
<Copy SourceFiles="@(MergedAssetManifest)"
DestinationFolder="$(SourceBuiltLayoutDir)"
UseSymbolicLinksIfPossible="true" />
<!-- Create a PackageVersions.props file that includes entries for all packages. -->
<WritePackageVersionsProps KnownPackages="@(ProducedPackage)"
ExtraProperties="@(ExtraPackageVersionPropsPackageInfo)"
VersionPropsFlowType="AllPackages"
OutputPath="$(AllPackageVersionsPropsName)" />
<Exec Command="tar --numeric-owner -czhf $(SourceBuiltTarballName) $([System.IO.Path]::GetFileName('$(SourceBuiltVersionName)')) *"
WorkingDirectory="$(SourceBuiltLayoutDir)" />
<!-- Mark the artifact so that it gets binplaced. -->
<ItemGroup>
<BinPlaceFile Include="$(SourceBuiltTarballName)" />
</ItemGroup>
<Message Importance="High" Text="Packaged source-built artifacts to $(SourceBuiltTarballName)" />
</Target>
<!-- Copy SDK archive to assets root as source-only build partners expect the file to be there. -->
<Target Name="CopySdkArchive"
BeforeTargets="Build"
DependsOnTargets="DetermineSourceBuiltSdkVersion">
<Copy SourceFiles="$(SdkTarballPath)"
DestinationFolder="$(ArtifactsAssetsDir)"
SkipUnchangedFiles="true"
UseHardlinksIfPossible="true" />
<!-- Mark the artifact so that it gets binplaced. -->
<ItemGroup>
<BinPlaceFile Include="$(ArtifactsAssetsDir)$([System.IO.Path]::GetFileName('$(SdkTarballPath)'))" />
</ItemGroup>
</Target>
</Project>