Home > Enterprise >  Azure DevOps "NuGet pack" task ignores/overwrites package metadata
Azure DevOps "NuGet pack" task ignores/overwrites package metadata

Time:01-26

I have setup a simple CI pipeline in Azure DevOps for building a .NET5 NuGet package, which looks like this

The pipeline is able to successfully pack and release the project as intended, but when I go to inspect the NuGet package, I find that all of the package metadata is missing (except for the version, which is correct, and the author(s), which is incorrectly showing the name of the ADO build agent as the author). I currently have all of the package metadata located in the .csproj file.

A screenshot showing the incorrect metadata, which is also what is shown when I look at the .nuspec in the NuGet package that is generated by the pipeline. Of course, when I pack the project on my local machine, all of the metadata generates the way it should.

Here

I've seen enter image description here

enter image description here

Or you could add below argument in the .csproj file, which will create the package when you build the project with VS build task:

<GeneratePackageOnBuild>true</GeneratePackageOnBuild>

CodePudding user response:

The solution to this problem ended up being somewhat simple. The 'NuGet pack' task uses the nuget.exe CLI, which ignores metadata defined in the .csproj file. You have to create a .nuspec file, put all of your metadata in it, and add that file to the same directory that the .csproj file resides. As soon as I did this, my NuGet package was generated with the correct metadata.

  •  Tags:  
  • Related