Do MSBuild versions use different LangVersions when using <LangVersion>latest</LangVersion>? #8243
-
I have a
I noticed a strange behaviour when running my console application via command line and using Visual Studio 17.4.1. The problem is that the code from the bug I linked will have a different output when the I then added a build target to print My question is if different MSBuild versions (in this case 17.0 and 17.4) will interpret |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Yes, sort of, for now. This is an artifact of some details of how Visual Studio and the .NET SDK are each packaged and how they interact. When have a In Visual Studio/ This can be quite confusing, and we're expecting to change this so that you always get a compiler that matches the SDK's in this situation--our tracking issue for that is #7832 (it will require changes in MSBuild, the SDK, and Roslyn, but that's a good place to follow along). The best bet for now is probably to specify an explicit LangVersion, rather than |
Beta Was this translation helpful? Give feedback.
Yes, sort of, for now.
This is an artifact of some details of how Visual Studio and the .NET SDK are each packaged and how they interact.
When have a
global.json
locking you to an SDK version and use .NET SDK (dotnet build
/dotnet run
) to build, every part of the build toolchain uses that version--you get the MSBuild that's packaged in that SDK, the SDK tasks and targets from that SDK, and the Roslyn tasks and targets from that SDK.In Visual Studio/
MSBuild.exe
, it's not the same--you always get the MSBuild that is packaged with Visual Studio, import the SDK tasks and targets from the SDK mentioned inglobal.json
, and get Roslyn tasks and targets from Visual Studio.This can be quite confu…