In our SDK we are shipping we have a project template that produces a nuget package on build. To accomplish this we take a dependency on the Nuget.CommandLine package and have this line in the csproj file
<PostBuildEvent>if exist Diagnostic.nuspec if exist "$(SolutionDir)\packages\NuGet.CommandLine.2.8.3\tools\NuGet.exe" "$(SolutionDir)\packages\NuGet.CommandLine.2.8.3\tools\NuGet.exe" pack Diagnostic.nuspec -OutputDirectory .</PostBuildEvent>
Downsides to this approach are
If the user updates the version of NuGet package then it will silently no longer build
If the user renames Diagnostic.nuspec then it will silently no longer build
If the user removes NuGet.CommandLine package then it will silently no longer build
We can remove the if-clauses so the user get a build error in these cases, but I was wondering if there is any supported way to produce a nuget package on build?
Thanks,
Jon