-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to compile C# 7.1 code on VSTS build agents #21783
Comments
I noticed there is a GitHub project for agents at https://github.com/Microsoft/vsts-agent/issues - not sure if we should cross-post the issue there, or leave it here? |
Leave it here for now. I'm reached out to get contacts. I'll move the issue if needed. |
OK thanks |
@conficient, VSTS team confirmed that all of the public hosted machines have been updated with VS 15.3 and .NET Core 2.0. This prompted me to read your repro in more details and it looks like the C# 7.1 compiler is indeed used, but it is using LangVersion 7.0. One more way to troubleshoot this issue is to include a |
I just checked and But as I did so I notice ( fx: forehead hitting desk ) it was in the Sorry for the oversight! |
I did this too, the easiest way to do it for all project configurations:
|
Also confirmed this behavior in Visual Studio for Mac (version 7.2.2 (build 11). To fix it in this IDE:
|
Why on earth is language version a build configuration-specific setting, anyway? For 99.9999 (few more nines)% of the cases you are compiling the same code for the different configurations, so why would we ever want different language features? Pretty silly mistaken to be able to get caught on. |
@bojingo There is an issue tracking this (LangVersion injected into project file by UI or API should not be configuration-specific): dotnet/project-system#2732 |
In fact there is a real architecture bug which is not fixed:
Build on the command line configuration Release => works fine Build on the command line configuration Staging => fails Because the "Staging" configuration does not exist in project A, msbuild fails. Either "C# latest" should be the default, or msbuild should know how to handle this situation better. |
"C# latest" being the default can be problematic because as soon as a new version of C# comes out doesn't mean all your build agents and such are immediately updated accordingly. The intent of the setting is to prevent people from using new features before they are ready for it. It just should be at the project level instead of specific build configuration level. (think of the settings in the project property pages that can't be changed independently based on build configuration). Then again...at least it would be a more predictable and intuitive error, so maybe that would be much preferred! 👍 @softlion |
My problem was that, when I changed lang level via interface, it just update the debug build configuration in csproj, not the release. |
Wow, been struggling with this. My build server wasn't picking up 7.2 and I didn't realize I needed it for the release configuration. Thanks! |
The interface should update both configurations, the error is not clear and takes time to find out what's happening in the first time. |
@paulohenriquesi Thanks, i made the same mistake, now i will use the « All Configuration » for thing like that. |
How to fix this in DOTNETCore Project? I mean change the LangVersion |
@vnextcoder Here's some information on setting the |
This does not work if you just want to set it to latest. The solution is to provide the msbuild argument as shown here: https://stackoverflow.com/questions/48050676/how-do-i-set-csc-langversion-when-building-in-vsts |
Yes and that does not work. Mine was already set similar to that. |
Still a problem with VS2017 15.9.24, which is suppose to support C#7.2 and it doesn't by "default" Some team members are using VS2019 which by "default" for language settings has NO XML verbose specifications for the solution, nor any projects in that solution. This is also true in VS2017. If while using VS2019, and you have a public/private protected class defined... and you open this in VS2017, you get the this works fine in VS2019, but not VS2017. you cannot simply configure the "All Configurations > Advanced..." property for the language in VS2019, it simply will not allow you to do so. And in VS2017, you have to configure it specificaly for C#7.2, at EACH project level. It does not work at the solution level using Directory.Build.props (as stated here: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/configure-language-version ) to do it as a 'global' solution language specification.... you still MUST do this at each individual project level. so... the "default" in VS2017 is C#7.0 and nothing greater.... to share the same code between VS2017 and VS2019, you either need to stick with C#7.0 convention (by not using the secured private protected method and just protected) or manual slap all that verbose XML into every single project. very irritating. |
Visual Studio Enterprise 2017 v15.3.2
.NET framework 4.7.02046
VSTS Build Agent: 2.120.2 (running on Server 2008, latest patches)
Steps to Reproduce:
void Main()
toasync Task Main()
CSharp7_1_Test.zip
Expected Behavior:
Build completes and recognises
async Task Main
as valid C# 7.1Actual Behavior:
Build fails with error:
Adding Roslyn compilers package does not fix this. Same error.
Notes:
First attempt on build server as 4.7 failed as the SDK was not installed (odd, since I'd installed VS 2017 on the machine earlier). Downloaded and ran
NDP47-DevPack-KB3186612-ENU.exe
on the build server to fix this.Second build failed as expected (log below):
[edit] I also tested by using the "Hosted VS2017" build agent queue - this failed with the same error.
Thanks to @jcouv for taking a look at this.
The text was updated successfully, but these errors were encountered: