I developed a .net standard 2.1
project with the intention of publishing it as a nuget, and I published it correctly.
The only thing I wanted to know is if in my project I can add a .nuspec
file, because I tried to add it but when I do the build (which also generates the nuget package) it seems not to take the metadata information added in the .nuspec file.
On the other hand, adding a PropertyGroup
with similar properties in my project's .csproj
file, when I build the package takes the metadata I entered.
I wanted to know if there is a way that I can "include" my .nuspec configurations when I build the project.
I found a few more questions where they recommended calling the .nuspec
exactly like the project but in my case it doesn't seem to have worked.
thanks
If you've got an SDK style project then it's recommended not to use a nuspec, and to keep all the package metadata in your project file instead https://learn.microsoft.com/en-us/nuget/reference/nuspec#project-type-compatibility
You can still use one if you really want to though https://learn.microsoft.com/en-us/nuget/reference/msbuild-targets#packing-using-a-nuspec-file
Sample command lines:
dotnet pack <path to .csproj file> -p:NuspecFile=<path to nuspec file> -p:NuspecProperties=<> -p:NuspecBasePath=<Base path>
or
msbuild -t:pack <path to .csproj file> -p:NuspecFile=<path to nuspec file> -p:NuspecProperties=<> -p:NuspecBasePath=<Base path>