diff --git a/src/SourceBuild/content/eng/finish-source-only.proj b/src/SourceBuild/content/eng/finish-source-only.proj index df0ef28dde91..bd569ab83db6 100644 --- a/src/SourceBuild/content/eng/finish-source-only.proj +++ b/src/SourceBuild/content/eng/finish-source-only.proj @@ -25,8 +25,13 @@ + + + + + diff --git a/src/SourceBuild/content/eng/tools/tasks/Microsoft.DotNet.UnifiedBuild.Tasks/WriteSbrpUsageReport.cs b/src/SourceBuild/content/eng/tools/tasks/Microsoft.DotNet.UnifiedBuild.Tasks/WriteSbrpUsageReport.cs index 49a7f8213069..baf653674960 100644 --- a/src/SourceBuild/content/eng/tools/tasks/Microsoft.DotNet.UnifiedBuild.Tasks/WriteSbrpUsageReport.cs +++ b/src/SourceBuild/content/eng/tools/tasks/Microsoft.DotNet.UnifiedBuild.Tasks/WriteSbrpUsageReport.cs @@ -31,10 +31,12 @@ public class WriteSbrpUsageReport : Task public required string SbrpRepoSrcPath { get; set; } /// - /// Path to the VMR src directory. + /// Paths to the project.assets.json files produced by the build. + /// + /// %(Identity): project.assets.json file path. /// [Required] - public required string SrcPath { get; set; } + public required ITaskItem[] ProjectAssetsJsons { get; set; } /// /// Path to the usage report to. @@ -61,6 +63,12 @@ private void GenerateUsageReport() PackageInfo[] existingSbrps = [.. _sbrpPackages.Values.OrderBy(pkg => pkg.Id)]; PurgeNonReferencedReferences(); IEnumerable unreferencedSbrps = GetUnreferencedSbrps().Select(pkg => pkg.Path).OrderBy(id => id); + + if (unreferencedSbrps.Count() == existingSbrps.Length) + { + Log.LogError("No SBRP packages are detected as being referenced."); + } + Report report = new(existingSbrps, unreferencedSbrps); string reportFilePath = Path.Combine(OutputPath, "sbrpPackageUsage.json"); @@ -144,7 +152,13 @@ private void ReadSbrpPackages(string packageType, bool trackTfms) private void ScanProjectReferences() { - foreach (string projectJsonFile in Directory.GetFiles(SrcPath, "project.assets.json", SearchOption.AllDirectories)) + if (ProjectAssetsJsons.Length == 0) + { + Log.LogError($"No project.assets.json files were specified."); + return; + } + + foreach (string projectJsonFile in ProjectAssetsJsons.Select(item => item.GetMetadata("Identity"))) { LockFile lockFile = new LockFileFormat().Read(projectJsonFile); foreach (LockFileTargetLibrary lib in lockFile.Targets.SelectMany(t => t.Libraries))