MSBuild use local .NET tool if available falling back to global tool if not

241 Views Asked by At

I have an MSBuild project with a target that depends on a .NET tool (let's call it do-stuff-tool).

.NET tools can be installed globally and/or locally, and developers using the MSBuild project may have the stable version of the tool installed globally and a development version installed locally. The syntax for running the tool depends on whether it's locally or globally installed (dotnet do-stuff-tool vs simply do-stuff-tool)

I want my MSBuild project to work with both local and global installs of do-stuff-tool, running the local version of the tool if it's available, and falling back to the global version if not, without the developer having to make any config changes to select which.

I could a write shell script to parse the output of dotnet tool list and dotnet tool list -g but I'd prefer an idiomatic MSBuild solution if possible.

Is there a standard way to achieve this in MSBuild?

Thanks.

0

There are 0 best solutions below