简体   繁体   中英

Force MSBuild to include the Owners element in the nuget .nuspec file

In my NuGet package creation, I am using the builtin Visual Studio (2019) functionality to create the package. I have included the both the Authors and Owners elements in my .csproj file, but only the Authors tag gets copied to the final package. I realize the Owners element has been deprecated , but Visual Studio still displays that line in the NuGet Package Manager Description, and it would be preferable to have that information be complete (if it's not there, it looks like the package owner was sloppy and left info out that should have been added). I can add it back in manually after the package is generated, but that is a hassle. Can I force that Owners element to be added to the NuGet package automatically?

Unfortunately not only MSBuild does not support Owners element but in .nuspec file the owners element is also deprecated :

Important

owners is deprecated. Use authors instead.

A comma-separated list of the package creators using profile names on nuget.org. This is often the same list as in authors, and is ignored when uploading the package to nuget.org .

What is more, nuget.org ignores authors element as well :

Although each NuGet package's.nuspec file defines the package's authors, the nuget.org gallery does not use that metadata to define ownership . Instead, nuget.org assigns initial ownership to the person who publishes the package. This is either the logged-in user who uploaded the package through the nuget.org UI, or the users whose API key was used with nuget SetApiKey or nuget push .

I also checked the source code of PackTask and although it gets the value of NuspecProperties MSBuild property but it is used only if NuspecFile MSBuild property is also set. But in this case all package properties will be read from the specified .nuspec file and the related MSBuild properties will be ignored.

So it seems that currently there is no way to force putting an owners element into the dynamically generated .nuspec file automatically.

What can be done?

  • Extract the .nuspec file from the generated .nupkg file.
  • Update the .nuspec file as needed.
  • Replace the .nuspec file in the .nupkg file with the updated one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM