devlooped / nugetizer

A simple to understand packing model for authoring NuGet packages
https://clarius.org/nugetizer/
MIT License
254 stars 7 forks source link

Package file is always updated on a build even when there are no changes #434

Open davidhunter22 opened 11 months ago

davidhunter22 commented 11 months ago

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.

Back this issue Back this issue

kzu commented 11 months ago

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?

kzu commented 11 months ago

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 🤔