From 58128944c24cf4214b8d7569bd5a8991c7a7c863 Mon Sep 17 00:00:00 2001 From: Peter Collins Date: Tue, 14 Sep 2021 12:32:56 -0400 Subject: [PATCH] [workloads] Add ProjectUrl to msi packs We ran into some publishing issues today due to a missing ProjectUrl: Policy violations: The package metadata is missing required ProjectUrl. Fix this by reading and including any existing ProjectUrl content from the .nupkg that the .msi was originally generated from. --- .../src/GenerateManifestMsi.cs | 5 +++++ .../src/GenerateMsiBase.cs | 5 +++++ .../src/NuGetPackage.cs | 6 ++++++ 3 files changed, 16 insertions(+) diff --git a/src/Microsoft.DotNet.Build.Tasks.Workloads/src/GenerateManifestMsi.cs b/src/Microsoft.DotNet.Build.Tasks.Workloads/src/GenerateManifestMsi.cs index d5178ef9bd5..88091936c61 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Workloads/src/GenerateManifestMsi.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Workloads/src/GenerateManifestMsi.cs @@ -376,6 +376,11 @@ private string GeneratePackageProject(string msiPath, string msiJsonPath, string writer.WriteElementString("Copyright", nupkg.Copyright); } + if (!string.IsNullOrWhiteSpace(nupkg.ProjectUrl)) + { + writer.WriteElementString("PackageProjectUrl", nupkg.ProjectUrl); + } + writer.WriteElementString("PackageLicenseExpression", "MIT"); writer.WriteEndElement(); diff --git a/src/Microsoft.DotNet.Build.Tasks.Workloads/src/GenerateMsiBase.cs b/src/Microsoft.DotNet.Build.Tasks.Workloads/src/GenerateMsiBase.cs index c9a4bf14510..05ed00167a2 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Workloads/src/GenerateMsiBase.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Workloads/src/GenerateMsiBase.cs @@ -369,6 +369,11 @@ private string GeneratePackageProject(string msiPath, string msiJsonPath, string writer.WriteElementString("Copyright", nupkg.Copyright); } + if (!string.IsNullOrWhiteSpace(nupkg.ProjectUrl)) + { + writer.WriteElementString("PackageProjectUrl", nupkg.ProjectUrl); + } + writer.WriteElementString("PackageLicenseExpression", "MIT"); writer.WriteEndElement(); diff --git a/src/Microsoft.DotNet.Build.Tasks.Workloads/src/NuGetPackage.cs b/src/Microsoft.DotNet.Build.Tasks.Workloads/src/NuGetPackage.cs index 8a7cacb015c..20f4c8ba06a 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Workloads/src/NuGetPackage.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Workloads/src/NuGetPackage.cs @@ -72,6 +72,11 @@ public string Title get; } + public string ProjectUrl + { + get; + } + /// /// The version of the NuGet package. /// @@ -96,6 +101,7 @@ public NugetPackage(string packagePath, TaskLoggingHelper log) Description = nuspecReader.GetDescription(); Copyright = nuspecReader.GetCopyright(); LicenseData = nuspecReader.GetLicenseMetadata(); + ProjectUrl = nuspecReader.GetProjectUrl(); } ///