I've developed a command-line utility that takes .NET assemblies as input and generates XML as output for use by another product.
Ideally I'd have it:
The first two things I can already do, and a post-build event command as above works just fine but only if I first open the Package Manager Console (even if I don't type any commands, just have to open it) - seemingly it's doing something cool with paths when it fires up so that I don't have to specify the ..\packages\ToolName-1.0.0.0\tools\MyTool.exe.
Is it possible for my NuGet package to use an Init.ps1 script (or some other mechanism) to adjust paths so that I needn't specify the full relative path to the tool when writing a post-build event, or to otherwise include run tool as a post-build step automatically?
Note - I accept NuGet mightn't be the ideal vector for delivering this sort of tool, but it would be convenient.
Just for the folks that come across this;
I've seen people use a nuget package for this, e.g. see nswag.msbuild: https://github.com/RicoSuter/NSwag/wiki/NSwag.MSBuild
In short the nuget package contains the tool as a command line utility executable. It also defines some buildprops that define the path to this tool (something along the lines of /packages/myToolNugetPkg/mytool.exe
) Then you can use this property in an msbuild task.
Also .NET core supports 'tools', which is exactly what you needed:
https://docs.microsoft.com/en-us/dotnet/core/tools/global-tools
Chocolatey (which technically qualifies as using NuGet) has a very cool magical "shimming" facility.
In brief, any executable in your package will be available on the PATH automatically. It's very cool.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With