updeps: update your nuspec references

Image you have a couple C# projects and you use a custom nuspec file to generate NuGet packages. You do it by yourself because the automated generation of nuspec files in Visual Studio actually sucks, they have all the crap in it that you don't want to ship, so in most cases you end up creating your own nuspec file.
But now you you always forgetting to update your dependencies in your nuspec file every time you update them in your csproj file. So, I got annoyed and wrote this little tool, it's more Mc'Giver style than sophisticated engineering but hey it works, so far.

With updeps you can update your nuspec file with just one following command.

updeps Foo.csproj Foo.nuspec

Or in case you want to combine multiple project in one nuspec file then run following.

updeps Foo.csproj Bar.csproj Foo.nuspec

It will output something like this.

Reading C:\Projects\Foo.csproj
  Added 2.0.1 Microsoft.AspNetCore.Authorization
  Added 2.0.1 Microsoft.AspNetCore.Hosting.Abstractions
  Added 2.0.1 Microsoft.AspNetCore.WebUtilities
  Added 2.0.0 Microsoft.Extensions.Configuration
  Added 2.0.0 Microsoft.Extensions.Configuration.Binder
  Added 2.0.0 Microsoft.Extensions.Configuration.CommandLine
  Added 2.0.0 Microsoft.Extensions.Configuration.EnvironmentVariables
  Added 2.0.0 Microsoft.Extensions.Configuration.FileExtensions
  Added 2.0.0 Microsoft.Extensions.Configuration.Json

It also ignores duplicate references and will throw an error in case you have same dependencies with different versions.

And if you hook it up to MSBuild then Visual Studio will do it automatically for you on every build. But for me, I hooked it into my NuGet publishing script.

You can find the source code on GitHub updeps

Show comments