imagine the following situation:
Project A has some NuGet dependencies (ie Project Z, Project Y and Project X). It uses PackageReferences.
Now I want to pack Project A as a .nupkg using a .nuspec file. In a .nuspec file you can declare other NuGet dependencies and they will automatically resolved upon installation.
But is that necessary? I thought the PackageReferences would already resolve them.
When you use
PackageReferenceitems in your project, you no longer need a.nuspecfile to pack a project. You should be able to pack it withdotnet pack -c Releaseormsbuild.exe -t:Pack -p:Configuration=Release. (Depending on the project type, you may need to install theNuGet.Build.Tasks.Packfor non-SDK-based .NET Framework projects. .NET Standard, Core, .NET 5+ projects should not need this)You can still use a .nuspec file though, by specifying a
NuspecFileproperty inside the csproj to instruct the pack task to use it. However, it will override all the settings that NuGet would autogenerate - that's the tradeoff for getting complete control over the.nuspec.If you pack a project using
PackageReferenceyou can have a look at the generated.nuspecfile in e.g.obj\Release\FooLib.1.0.0.nuspec.