diff --git a/src/SourceBuild/content/eng/tools/tasks/Microsoft.DotNet.UnifiedBuild.Tasks/WritePackageVersionsProps.cs b/src/SourceBuild/content/eng/tools/tasks/Microsoft.DotNet.UnifiedBuild.Tasks/WritePackageVersionsProps.cs index 2058d73fc..4c1413756 100644 --- a/src/SourceBuild/content/eng/tools/tasks/Microsoft.DotNet.UnifiedBuild.Tasks/WritePackageVersionsProps.cs +++ b/src/SourceBuild/content/eng/tools/tasks/Microsoft.DotNet.UnifiedBuild.Tasks/WritePackageVersionsProps.cs @@ -20,7 +20,7 @@ namespace Microsoft.DotNet.UnifiedBuild.Tasks public class VersionEntry { public string Name; - public string Version; + public NuGetVersion Version; } /// @@ -52,9 +52,16 @@ namespace Microsoft.DotNet.UnifiedBuild.Tasks /// /// Set of input nuget package files to generate version properties for. /// - [Required] public ITaskItem[] NuGetPackages { get; set; } + /// + /// Set of packages built by dependencies of this repo during this build. + /// + /// %(Identity): Package identity. + /// %(Version): Package version. + /// + public ITaskItem[] KnownPackages { get; set; } + /// /// File where the version properties should be written. /// @@ -63,7 +70,7 @@ namespace Microsoft.DotNet.UnifiedBuild.Tasks /// /// Properties to add to the build output props, which may not exist as nupkgs. - /// FOr example, this is used to pass the version of the CLI toolset archives. + /// For example, this is used to pass the version of the CLI toolset archives. /// /// %(Identity): Package identity. /// %(Version): Package version. @@ -169,6 +176,9 @@ namespace Microsoft.DotNet.UnifiedBuild.Tasks return !Log.HasLoggedErrors; } + NuGetPackages ??= Array.Empty(); + KnownPackages ??= Array.Empty(); + // First, obtain version information from the packages and additional assets that // are provided. var latestPackages = NuGetPackages @@ -179,16 +189,26 @@ namespace Microsoft.DotNet.UnifiedBuild.Tasks return reader.GetIdentity(); } }) - .GroupBy(identity => identity.Id) - .Select(g => g.OrderBy(id => id.Version).Last()) - .OrderBy(id => id.Id) .Select(identity => new VersionEntry() + { + Name = identity.Id, + Version = identity.Version + }); + + var knownPackages = KnownPackages + .Select(item => new VersionEntry() { - Name = identity.Id, - Version = identity.Version.ToString() + Name = item.GetMetadata("Identity"), + Version = new NuGetVersion(item.GetMetadata("Version")) }); - var packageElementsToWrite = latestPackages; + // We may have multiple versions of the same package. We'll keep the latest one. + // This can even happen in the KnownPackages list, as a repo (such as source-build-reference-packages) + // may have multiple versions of the same package. + IEnumerable packageElementsToWrite = latestPackages.Concat(knownPackages) + .GroupBy(identity => identity.Name) + .Select(g => g.OrderByDescending(id => id.Version).First()) + .OrderBy(id => id.Name); // Then, if version flow type is "DependenciesOnly", filter those // dependencies that do not appear in the version.details.xml file. diff --git a/src/SourceBuild/content/repo-projects/Directory.Build.props b/src/SourceBuild/content/repo-projects/Directory.Build.props index b8a93c941..8a27e0ee9 100644 --- a/src/SourceBuild/content/repo-projects/Directory.Build.props +++ b/src/SourceBuild/content/repo-projects/Directory.Build.props @@ -182,31 +182,14 @@ - - - - + + - - - - - - - + <_TransitiveRepositoryReference Include="@(RepositoryReference)" /> @@ -80,8 +80,6 @@ - - @@ -258,13 +256,10 @@ There are 3 files generated --> - - <_CurrentSourceBuiltPackages Include="@(DependentRepoPackageFile)" - Condition="!$([System.String]::Copy('%(Identity)').EndsWith('.symbols.nupkg'))" /> <_PreviouslyBuiltSourceBuiltPackages Include="$(PrebuiltSourceBuiltPackagesPath)*.nupkg" /> @@ -276,7 +271,7 @@ - - @@ -342,40 +337,45 @@ RunEachTargetSeparately="$(RunEachTargetSeparately)" /> - - - - <_ArcadeSdkName>Microsoft.DotNet.Arcade.Sdk - + - <_BuiltArcadeSdkPackage Include="@(DependentRepoPackageFile)" - Condition="!$([System.String]::new('%(Identity)').EndsWith('.symbols.nupkg')) and $([System.String]::new('%(Identity)').Contains($(_ArcadeSdkName)))" /> + - - <_BuiltArcadeSdkPackageVersion>$([System.String]::new('%(_BuiltArcadeSdkPackage.FileName)').Substring($([MSBuild]::Add($(_ArcadeSdkName.Length), 1)))) - + + + + + - - - - - - - + + + + + + + + @@ -396,7 +396,7 @@ UpdateGlobalJsonVersions; UpdateEngCommonFiles; CreateBuildInputProps; - DiscoverArcadeSourceBuiltSdkOverrides; + DiscoverBuiltSdkOverrides; SetSourceBuiltSdkOverrides"> @@ -449,14 +449,16 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + @@ -578,6 +618,9 @@ + + + Returns="$(DependencyGraphString)"> diff --git a/src/SourceBuild/content/repo-projects/arcade.proj b/src/SourceBuild/content/repo-projects/arcade.proj index 1d22ddd47..ac63070a2 100644 --- a/src/SourceBuild/content/repo-projects/arcade.proj +++ b/src/SourceBuild/content/repo-projects/arcade.proj @@ -9,14 +9,13 @@ - - - - - - + + + + + diff --git a/src/SourceBuild/content/repo-projects/source-build-reference-packages.proj b/src/SourceBuild/content/repo-projects/source-build-reference-packages.proj index 87f39652c..063856e8a 100644 --- a/src/SourceBuild/content/repo-projects/source-build-reference-packages.proj +++ b/src/SourceBuild/content/repo-projects/source-build-reference-packages.proj @@ -15,8 +15,8 @@ - - + +