添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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?

I'm pretty sure every .NET Projects needs to define what version of the MSBuild Toolset it uses to build and compile. But ome project types use the sdk attribute instead of ToolsVersion as this microsoft docs article points out MindSwipe Mar 19, 2019 at 8:05

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.

If that project would be run on different VS versions, wouldn't that be cause inconsistencies? yuvalm2 Mar 22, 2019 at 8:49 Depends on the project type. There are VS 2010 web projects for example that would case an updated to be performed when a newer VS sees an old ToolsVersion. For new projects in VS 2017+ it shouldn't matter anymore Martin Ullrich Mar 22, 2019 at 15:00 Nice to know. Loaded an older (unmanaged) project with ToolsVersion="14.0" and replaced it with ToolsVersion="16.0" . No warnings in either case, and seems to build the same. Laurie Stearn Feb 2, 2020 at 14:32

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question . Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers .