5

While building this open source C# project in AppVeyor, I get the error:

CSC : error CS1617: Invalid option '10' for /langversion. Use '/langversion:?' to list supported values.

See the build log.

In build settings, Visual Studio 2022 is selected as the build worker image and the Preinstalled Software page lists both .NET 5 and 6 SDKs for that image.

What am I missing? Why is it using MSBuild 16 and not 17?

Sergey Slepov
  • 1,861
  • 13
  • 33
  • [The `langversion` option documentation](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/language#langversion) might help. You should probably tell the author of the project you're using as well, to help them. – Some programmer dude Aug 02 '22 at 13:14
  • @HansPassant What do you mean? The build is still failing as evident from the build history: https://ci.appveyor.com/project/morpher/dawgsharp/history – Sergey Slepov Aug 02 '22 at 13:50
  • @HansPassant I am the author of this project and I added 10 just so it errors out early. – Sergey Slepov Aug 02 '22 at 14:42
  • @HansPassant What's interesting, one of my other projects (which also uses C# 10) builds fine with the same image: https://ci.appveyor.com/project/morpher/enumerabletostream – Sergey Slepov Aug 02 '22 at 14:43
  • @HansPassant I tried removing Visual Studio version information from the sln file, just like the other project, but AppVeyor still picks MSBuild 16 (as seen from the top of the build log): https://ci.appveyor.com/project/morpher/dawgsharp – Sergey Slepov Aug 02 '22 at 14:48
  • The documentation I linked to says that the value should be `10.0`. Have you tried that instead of just plain `10`? – Some programmer dude Aug 03 '22 at 13:01

3 Answers3

4

lanch the solution with VS2022 and that resolve the problem

mariobot
  • 49
  • 1
  • 5
1

According to your description, the error: CSC : error CS1617: Invalid option '10' for /langversion. Use '/langversion:?' to list supported values. is caused by not using C#10 in vs2022 and .NET6.0 environment.

We can see from the build log you provided that the build is using MSBuild16 in VS2019. enter image description here

We can find the MSBuild.exe installed with Visual Studio 2022 Community from C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe.

We have not used AppVeyor. Maybe you can try specifying the path for MSBuild(17) in command line(not sure whether AppVeyor uses command line to build?) to compile it or just select VS2022 and .NET6.0 when you choose build settings.

Jingmiao Xu-MSFT
  • 2,076
  • 1
  • 3
  • 10
1

The problem was that appveyor.yml in the repo had Visual Studio 2019 in it as the worker image. The way AppVeyor works, the yml file takes precedence over UI settings.

Sergey Slepov
  • 1,861
  • 13
  • 33
  • I am glad to hear that your problem has been solved, you can consider accepting it as answer. It will also help others to solve the similar issue. – Jingmiao Xu-MSFT Aug 19 '22 at 09:28