Package file is always updated on a build even when there are no changes
I have a project that creates a NuGet package and it all works as expected.
However I did just notice that the .nupkg file gets overwritten every time I do a build even if it has not changed. Is there some way, perhaps using CopyToOutputDirectory that will only overwrite the file if it has changed.
I am tempted to build into a temporary location and then do the copy manually in the MSBuild project but I am wondering if this is already build in and I don't understand how to get it to work.
Typically, you should not be building the package on build. NuGet API itself (for package creation, which is what we use) doesn't provide incrementality checks of any kind.
Perhaps this could be added as an inputs/outputs on the final package contents to be packed. But even that might not be precise, since many manifest properties come from the project properties, and not files, so the MSBuild incrementality wouldn't work in that case.
May I ask why you pack on build?
On second thought: so you're not trying to avoid the overhead of packing the .nupkg, just that the final file is not overwritten if it hasn't changed? Perhaps this could be added 🤔
Due to lack of recent activity, this issue has been labeled as 'stale'. It will be closed if no further activity occurs within 30 more days. Any new comment will remove the label.
This issue will now be closed since it has been labeled 'stale' without activity for 30 days.
