|
2 | 2 | <Project Sdk="Microsoft.Build.NoTargets">
|
3 | 3 |
|
4 | 4 | <PropertyGroup>
|
| 5 | + <TargetFramework>$(NetCurrent)</TargetFramework> |
| 6 | + |
5 | 7 | <!-- Need to set to false to calculate RepositoryCommit. -->
|
6 | 8 | <EnableSourceControlManagerQueries>false</EnableSourceControlManagerQueries>
|
7 |
| - <TargetFramework>$(NetCurrent)</TargetFramework> |
| 9 | + |
| 10 | + <PackageReportDataFile>$(ArtifactsLogDir)prebuilt-usage.xml</PackageReportDataFile> |
| 11 | + <ProjectAssetsJsonArchiveFile>$(ArtifactsLogDir)all-project-assets-json-files.zip</ProjectAssetsJsonArchiveFile> |
| 12 | + <ProdConManifestFile>$(ArtifactsLogDir)prodcon-build.xml</ProdConManifestFile> |
| 13 | + |
| 14 | + <ResultingPrebuiltPackagesDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsLogDir)', 'prebuilt-packages'))</ResultingPrebuiltPackagesDir> |
8 | 15 | </PropertyGroup>
|
9 | 16 |
|
10 | 17 | <ItemGroup>
|
|
14 | 21 | <ProjectReference Include="$(RepositoryEngineeringDir)merge-asset-manifests.proj" />
|
15 | 22 | </ItemGroup>
|
16 | 23 |
|
17 |
| - <!-- After building, generate a prebuilt usage report. --> |
18 |
| - <Target Name="ReportPrebuiltUsage" |
| 24 | + <UsingTask TaskName="Microsoft.DotNet.UnifiedBuild.Tasks.UsageReport.WritePackageUsageData" AssemblyFile="$(MicrosoftDotNetUnifiedBuildTasksAssembly)" TaskFactory="TaskHostFactory" /> |
| 25 | + <Target Name="WritePrebuiltUsageData" |
19 | 26 | BeforeTargets="Build"
|
20 |
| - Condition="'$(SkipReportPrebuiltUsage)' != 'true'"> |
21 |
| - <MSBuild Projects="$(RepoProjectsDir)$(RootRepo).proj" Targets="WritePrebuiltUsageData;ReportPrebuiltUsage" /> |
| 27 | + Inputs="$(MSBuildProjectFullPath)" |
| 28 | + Outputs="$(BaseIntermediateOutputPath)WritePrebuiltUsageData.complete"> |
| 29 | + <ItemGroup> |
| 30 | + <!-- |
| 31 | + Note the usage of */*/*.nupkg and not **/*.nupkg. The latter would include nupkgs |
| 32 | + carried as content, i.e. in Microsoft.FSharp.Compiler nupkg, and cause false positives. |
| 33 | + Content nupkgs were not restored and should not be used in prebuit detection. |
| 34 | +
|
| 35 | + Example of a restored package: |
| 36 | + $(NuGetPackageRoot)microsoft.fsharp.compiler/12.8.300-beta.24203.1/microsoft.fsharp.compiler.12.8.300-beta.24203.1.nupkg |
| 37 | +
|
| 38 | + Example of a content package: |
| 39 | + $(NuGetPackageRoot)microsoft.fsharp.compiler/12.8.300-beta.24203.1/contentFiles/Release/FSharp.Core.8.0.300.nupkg |
| 40 | + --> |
| 41 | + <RestoredPackageFile Include="$(NuGetPackageRoot)*/*/*.nupkg" |
| 42 | + Exclude="$(NuGetPackageRoot)tests/**/*.nupkg" /> |
| 43 | + |
| 44 | + <!-- Only contains packages when building. --> |
| 45 | + <TarballPrebuiltPackageFile Include="$(PrebuiltPackagesPath)*.nupkg" /> |
| 46 | + |
| 47 | + <SourceBuiltPackageFile Include="$(ArtifactsPackagesDir)**/*.nupkg" /> |
| 48 | + <SourceBuiltPackageFile Include="$(PrebuiltSourceBuiltPackagesPath)*.nupkg" /> |
| 49 | + <ReferencePackageFile Include="$(ReferencePackagesDir)**/*.nupkg" /> |
| 50 | + |
| 51 | + <!-- Check all RIDs from all restored Microsoft.NETCore.Platforms packages. --> |
| 52 | + <PlatformsRuntimeJsonFile Include="$(NuGetPackageRoot)microsoft.netcore.platforms/*/PortableRuntimeIdentifierGraph.json" /> |
| 53 | + </ItemGroup> |
| 54 | + |
| 55 | + <ItemGroup> |
| 56 | + <RepoProject Include="$(RepoProjectsDir)*.proj" /> |
| 57 | + <RepoProjectDirectory Include="@(RepoProject->'$(SrcDir)%(Filename)')" /> |
| 58 | + |
| 59 | + <!-- Add some other potential top-level project directories for a more specific report. --> |
| 60 | + <RepoProjectDirectory Include="$(SourceBuiltSdksDir);$(TasksDir);$(ArtifactsObjDir)" /> |
| 61 | + <!-- Finally, scan entire source-build, in case project.assets.json ends up in an unexpected place. --> |
| 62 | + <RepoProjectDirectory Include="$(RepoRoot)" /> |
| 63 | + </ItemGroup> |
| 64 | + |
| 65 | + <ItemGroup> |
| 66 | + <!-- This file is a resource tracked by Git, not generated by restore. Ignore false positive. --> |
| 67 | + <IgnoredProjectAssetsJsonFile Include="$(SrcDir)*nuget-client*/**/test/NuGet.Core.Tests/NuGet.Build.Tasks.Pack.Test/compiler/resources/project.assets.json"/> |
| 68 | + </ItemGroup> |
| 69 | + |
| 70 | + <WritePackageUsageData |
| 71 | + RestoredPackageFiles="@(RestoredPackageFile)" |
| 72 | + TarballPrebuiltPackageFiles="@(TarballPrebuiltPackageFile)" |
| 73 | + SourceBuiltPackageFiles="@(SourceBuiltPackageFile)" |
| 74 | + ReferencePackageFiles="@(ReferencePackageFile)" |
| 75 | + PlatformsRuntimeJsonFiles="@(PlatformsRuntimeJsonFile)" |
| 76 | + TargetRid="$(TargetRid)" |
| 77 | + ProjectDirectories="@(RepoProjectDirectory)" |
| 78 | + RootDir="$(RepoRoot)" |
| 79 | + IgnoredProjectAssetsJsonFiles="@(IgnoredProjectAssetsJsonFile)" |
| 80 | + DataFile="$(PackageReportDataFile)" |
| 81 | + ProjectAssetsJsonArchiveFile="$(ProjectAssetsJsonArchiveFile)" /> |
| 82 | + |
| 83 | + <!-- Copy packages detected as prebuilts to the artifacts prebuilt folder --> |
| 84 | + <ItemGroup> |
| 85 | + <AllowedPackageFile Include="@(TarballPrebuiltPackageFile)" /> |
| 86 | + <AllowedPackageFile Include="@(SourceBuiltPackageFile)" /> |
| 87 | + <AllowedPackageFile Include="@(ReferencePackageFile)" /> |
| 88 | + <AllowedPackageFile> |
| 89 | + <LCFilename>$([System.String]::Copy(%(Filename)).ToLowerInvariant())</LCFilename> |
| 90 | + </AllowedPackageFile> |
| 91 | + |
| 92 | + <PrebuiltPackageFile Include="@(RestoredPackageFile)" > |
| 93 | + <LCFilename>$([System.String]::Copy(%(Filename)).ToLowerInvariant())</LCFilename> |
| 94 | + </PrebuiltPackageFile> |
| 95 | + <PrebuiltPackageFile Remove="@(AllowedPackageFile)" MatchOnMetadata="LCFilename" /> |
| 96 | + </ItemGroup> |
| 97 | + |
| 98 | + <Copy SourceFiles="@(PrebuiltPackageFile)" DestinationFolder="$(ResultingPrebuiltPackagesDir)" /> |
| 99 | + |
| 100 | + <MakeDir Directories="$(BaseIntermediateOutputPath)" /> |
| 101 | + <Touch Files="$(BaseIntermediateOutputPath)WritePrebuiltUsageData.complete" AlwaysCreate="true"> |
| 102 | + <Output TaskParameter="TouchedFiles" ItemName="FileWrites" /> |
| 103 | + </Touch> |
| 104 | + </Target> |
| 105 | + |
| 106 | + <!-- After building, generate a prebuilt usage report. |
| 107 | + Also, dev scenario: rewrite a prebuilt-report. This makes it easy to add data to an existing |
| 108 | + prebuilt report without performing another full build. This doesn't reevalutate which packages |
| 109 | + are prebuilts or search the projects: it uses the existing usage.xml file to generate report |
| 110 | + XMLs based on the info put in artifacts/. --> |
| 111 | + <UsingTask TaskName="Microsoft.DotNet.UnifiedBuild.Tasks.UsageReport.ValidateUsageAgainstBaseline" AssemblyFile="$(MicrosoftDotNetUnifiedBuildTasksAssembly)" TaskFactory="TaskHostFactory" /> |
| 112 | + <UsingTask TaskName="Microsoft.DotNet.UnifiedBuild.Tasks.UsageReport.WriteUsageReports" AssemblyFile="$(MicrosoftDotNetUnifiedBuildTasksAssembly)" TaskFactory="TaskHostFactory" /> |
| 113 | + <Target Name="ReportPrebuiltUsage" |
| 114 | + Inputs="$(MSBuildProjectFullPath)" |
| 115 | + Outputs="$(BaseIntermediateOutputPath)ReportPrebuiltUsage.complete" |
| 116 | + DependsOnTargets="WritePrebuiltUsageData" |
| 117 | + BeforeTargets="Build"> |
| 118 | + <PropertyGroup> |
| 119 | + <FailOnPrebuiltBaselineError Condition="'$(FailOnPrebuiltBaselineError)' == ''">false</FailOnPrebuiltBaselineError> |
| 120 | + </PropertyGroup> |
| 121 | + |
| 122 | + <ItemGroup> |
| 123 | + <PackageVersionPropsSavedSnapshotFile Include="$(PackageVersionsDir)PackageVersions.*.Snapshot.props" /> |
| 124 | + </ItemGroup> |
| 125 | + <Copy SourceFiles="@(PackageVersionPropsSnapshotFiles)" DestinationFolder="$(ArtifactsLogDir)snapshots/" /> |
| 126 | + |
| 127 | + <WriteUsageReports DataFile="$(PackageReportDataFile)" |
| 128 | + PackageVersionPropsSnapshots="@(PackageVersionPropsSavedSnapshotFile)" |
| 129 | + ProdConBuildManifestFile="$(ProdConManifestFile)" |
| 130 | + PoisonedReportFile="$(PoisonedReportFile)" |
| 131 | + OutputDirectory="$(ArtifactsLogDir)" /> |
| 132 | + |
| 133 | + <PropertyGroup Condition="'$(ContinueOnPrebuiltBaselineError)' == ''"> |
| 134 | + <ContinueOnPrebuiltBaselineError>false</ContinueOnPrebuiltBaselineError> |
| 135 | + <ContinueOnPrebuiltBaselineError Condition="'$(FailOnPrebuiltBaselineError)' != 'true'">true</ContinueOnPrebuiltBaselineError> |
| 136 | + </PropertyGroup> |
| 137 | + |
| 138 | + <ValidateUsageAgainstBaseline |
| 139 | + DataFile="$(PackageReportDataFile)" |
| 140 | + BaselineDataFile="$(BaselineDataFile)" |
| 141 | + OutputBaselineFile="$(ArtifactsLogDir)generated-new-baseline.xml" |
| 142 | + OutputReportFile="$(ArtifactsLogDir)baseline-comparison.xml" |
| 143 | + AllowTestProjectUsage="$(AllowTestProjectUsage)" |
| 144 | + ContinueOnError="$(ContinueOnPrebuiltBaselineError)" /> |
| 145 | + |
| 146 | + <MakeDir Directories="$(BaseIntermediateOutputPath)" /> |
| 147 | + <Touch Files="$(BaseIntermediateOutputPath)ReportPrebuiltUsage.complete" AlwaysCreate="true"> |
| 148 | + <Output TaskParameter="TouchedFiles" ItemName="FileWrites" /> |
| 149 | + </Touch> |
22 | 150 | </Target>
|
23 | 151 |
|
24 | 152 | <UsingTask TaskName="Microsoft.DotNet.UnifiedBuild.Tasks.WriteSBRPUsageReport" AssemblyFile="$(MicrosoftDotNetUnifiedBuildTasksAssembly)" TaskFactory="TaskHostFactory" />
|
|
110 | 238 | <RemoveDir Directories="$(IntermediateSdkSymbolsLayout)" />
|
111 | 239 | </Target>
|
112 | 240 |
|
113 |
| - <!-- |
114 |
| - Dev scenario: rewrite a prebuilt-report. This makes it easy to add data to an existing |
115 |
| - prebuilt report without performing another full build. This doesn't reevalutate which packages |
116 |
| - are prebuilts or search the projects: it uses the existing usage.xml file to generate report |
117 |
| - XMLs based on the info put in artifacts/. |
118 |
| - --> |
119 |
| - <Target Name="RewritePrebuiltUsageReport"> |
120 |
| - <MSBuild Projects="$(RepoProjectsDir)$(RootRepo).proj" |
121 |
| - Targets="ReportPrebuiltUsage" /> |
122 |
| - </Target> |
123 |
| - |
124 | 241 | <UsingTask TaskName="Microsoft.DotNet.SourceBuild.Tasks.LeakDetection.CheckForPoison" AssemblyFile="$(MicrosoftDotNetSourceBuildTasksLeakDetectionAssembly)" TaskFactory="TaskHostFactory" Condition="'$(EnablePoison)' == 'true'" />
|
125 | 242 | <Target Name="ReportPoisonUsage"
|
126 | 243 | BeforeTargets="Build"
|
|
168 | 285 | Inputs="$(MSBuildProjectFullPath)"
|
169 | 286 | Outputs="$(BaseIntermediateOutputPath)GeneratePrebuiltBurndownData.complete" >
|
170 | 287 | <PropertyGroup>
|
171 |
| - <PrebuiltBurndownDataFile>$(PackageReportDir)PrebuiltBurndownData.csv</PrebuiltBurndownDataFile> |
| 288 | + <PrebuiltBurndownDataFile>$(ArtifactsLogDir)PrebuiltBurndownData.csv</PrebuiltBurndownDataFile> |
172 | 289 | </PropertyGroup>
|
173 | 290 |
|
174 | 291 | <WriteUsageBurndownData RootDirectory="$(RepoRoot)"
|
|
0 commit comments