What I've been strugling with for some time:
I have a "traditional" (i.e. non-SDK) csproj file. I want to create a nuget package. That's easy but devil hides in the details and I end up in the following catch-22
- I can manually call
nuget pack .\Foo.csproj
, with or without a nuspec file, but then I get the dreaded NU5128 error. The chosen answer suggests to simply ignore the error. I would happily do that, but after publishing the package locally, I noticed that the dependencies are not included. Though there is one dependency to JSON.net that I added for the sake of testing. The same error appears in AppVeyor if I configure myyml
to create the package.
- I can specify all the packaging related properties in the .csproj file by setting
GeneratePackageOnBuild
to true. It works and takes the dependencies right but then I can't patch the version like I could do with the replacement tokens of nuspec. The version defaults to1.0.0.0
even if I change it in theAssemblyInfo.cs
to1.2.3.4
.
Notes
- This answer suggests that nuspec and csproj configuration can coexist and they are merged. The question is from 2013 so I guess it's not referring to SDK projects. Unfortunately that's not the case for me.
- I tried adding a
<NuspecFile>
in the csproj but then it seems that replacement tokens don't work and I get the error described here. Probably because this instructed nuget to run pack on the nuspec instead of running it on csproj and merge the nuspec. I can't know for sure though as setting the build verbosity toDetailed
didn't help to understand what nuget pack tried to do. - Getting the
AssemblyInformationalVersion
in msbuild and use it straight to the<Version>
property isn't as straightforward as one might think and it also defeats the purpose as$version$
is doing exactly that according to the documentation:
AssemblyInformationalVersion if present, otherwise AssemblyVersion
Is there a way to really "merge" .csproj
and .nuspec
with $version$
patching and get the dependencies in the nuspec right?