Search code examples
.net-corenuget

Modify dotnet pack auto generated nuspec


I am using the csproj property <GeneratePackageOnBuild> to generate a NuGet package from my netstandard2.0 C# project.

I would like to make 2 modifications to the generated package

  1. Change the id to rename the package
  2. Add an additional .dll to the .nupkg

The only way I could figure out to accomplish that was to add a custom .nuspec file to my project, and add <NuspecFile> to the .csproj.

This works fine, but I'm missing some features from the auto-generated NuGet package, like repository binding to my git commit. It also feels less resilient to change.

Is there any way I can modify the SDK build process to get the auto-generated NuGet package, but with my 2 changes?


Solution

  • Thanks to @Pieterjan, I found the right answer.

    Including referenced project DLLs in nuget package [.Net Core RC3 *.csproj file]

    pointed me to

    https://github.com/nuget/home/issues/3891#issuecomment-377319939

    so I was able to

    1. Rename the PackageId property in a <Target Name="MyProj_RenamePackageId" BeforeTargets="GenerateNuspec"
    2. Follow the steps of issue 3891 above to add the referenced project .dll to the produced .nupkg