Search code examples
c#.netcsproj

ToolsVersion specification in .NET projects


I see that some C# projects note their ToolsVersion and other do not. (e.g. ToolsVersion="15.0")

What is the best practice? Is this too a case where explicit is better than implicit?


Solution

  • The "ToolsVersion" property was most useful for distinguishing between versions of tooling installed side-by-side in a global MSBuild installation.

    Since beginning with VS 2017, there no longer is a global MSBuild installation, the importance of ToolsVersion is lower.

    In VS 2019, they introduced a Current version that aims to replace the need for an actual version number without breaking too much of its usage (e.g. you'll see paths containing folders named Current) and making sure that projects and extensions will update to newer versions more easily without breaking.

    So as long as you use recent versions of VS (2017, 2019) you shouldn't need to specify ToolsVersion, especially if you are writing projects for .NET Core or .NET Standard.