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
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 my yml
to create the package.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 to 1.0.0.0
even if I change it in the AssemblyInfo.cs
to 1.2.3.4
.Notes
<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 to Detailed
didn't help to understand what nuget pack tried to do.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?
So far the best course of action was to convert the project to SDK format. It has several advantages. Less configuration, no need for .nuspec
file, no need for AssemblyInfo.cs
or VersionInfo.cs
files, .nupkg
dependencies are correct and AppVeyor can patch directly the .csproj
file if it's an SDK project file.
Not a solution per se if one wants to keep the legacy format, but it gets you going with the CI/CD instead of having you fighting with tools.