VS Code CSC : error CS1617: Invalid option '7.3' for /langversion

49,656

Solution 1

Your should use the Preview version of VS for trying out Blazor, which is numbered 15.8.x

vs installer

And install the .net core 2.1 RC. 2.1.2 will not cut it.

Solution 2

Just had this and a Clean, Rebuild fixed the issue for me.

Solution 3

On VS 2019, I went to project files, changed the target framework to 4.7.2 from 4.6.2, the project build successfully. Then revert back to 4.6.2 and it still builds successfully

Solution 4

Come October 2020, and I'm on VS 2019 .. and this is my error that caused me to google my way to this post:

CS1617 Invalid option '7.3' for /langversion; must be ISO-1, ISO-2, Default, Latest or a valid version in range 1 to 7.1

FWIW - I'm just working on an old school .NET Framework / ASP.NET / Web API2 project, fwiw, not trying to do anything cool with Standards or Core...

I'm scratching my head because:

  1. It works on my workstation at work
  2. It works on my Azure CI pipeline
  3. So.. why not on my Win 10 pro workstation at home?

Solution

  • I launched the Visual Studio Installer > 2019 > More > Modify screen
  • Switched to Individual Components tab, scrolled down to Code Tools
  • and found this little checkbox needed checking NuGet targets and build tasks enter image description here This was the only thing I could readily discern as different between my 2 workstations at work and home. I presume checking the box made the difference, and not merely the fact that I was forced to close and restart Visual Studio after I had restored the nugets.. but you never know.

Solution 5

Clean and Rebuild didn't work for me until I closed Visual Studio and deleted the .vs folder then re-opened, cleaned and rebuilt.

Share:
49,656
Spydernaz
Author by

Spydernaz

Solution Engineer, background in Security / Networking and Development <3 solving problems!

Updated on July 09, 2022

Comments

  • Spydernaz
    Spydernaz almost 2 years

    I downloaded VS 2017 15.7, .NET Core 2.1.2 and Blazor to try it out. It wasn't working in VS 2017 properly and thought I would try through the dotnet cli and VS Code. Instead I was met with the following error:

    CSC : error CS1617: Invalid option '7.3' for /langversion.

    In VS, it will run the application show "Loading..." and then nothing. Not sure if the two issues are related

    dotnet --info returns the following:

    .NET Command Line Tools (2.1.300-preview1-008174)
    
    Product Information:
     Version:            2.1.300-preview1-008174
    Commit SHA-1 hash:  b8df89a54f
    
    Runtime Environment:
     OS Name:     Windows
     OS Version:  10.0.17666
     OS Platform: Windows
     RID:         win10-x64
     Base Path:   C:\Program Files\dotnet\sdk\2.1.300-preview1-008174\
    
    Microsoft .NET Core Shared Framework Host
    
      Version  : 2.1.0-preview1-26216-03
      Build    : f2c3216183d20416568a4bbf5bb7d153e826f153
    
  • Spydernaz
    Spydernaz almost 6 years
    This Blazor link seems to show that with the latest 2.1 and 15.7 is enough?
  • Flores
    Flores almost 6 years
    Okay. 15.7.x was the preview up until some days ago. This blogpost talks about 15.7 Preview, which doesn't exist. So this is confusing. I would advise to test the preview 15.8 it works for me.
  • Flores
    Flores almost 6 years
    Also, make sure that that your .net framework is on version 2.1.300-Preview2-8533 or later (which is the RC) 2.1.200 won't work.
  • Jon Skeet
    Jon Skeet almost 6 years
    Blazor works fine for me with 15.7.0. There's no need for 15.8. You do need the .NET Core 2.1 preview though. The OP's edited question shows that's already installed, although a very slightly earlier preview.
  • Spydernaz
    Spydernaz almost 6 years
    @Flores and @DaisyShipton, Thanks for your help. The preview was not enough. Works on Version: 2.1.0-rc1 Commit: eb9bc92051
  • Jon Skeet
    Jon Skeet almost 6 years
    @Spydernaz: Glad it's working - that's still a preview (as opposed to the full GA release), just a later one than you had before.
  • Sql Surfer
    Sql Surfer almost 4 years
    There is something that is in my source that got past my git ignore and this solved it for me during clean builds. Clean and Rebuild. My project recently went through a 2017 to 2019 upgrade and it looks like my Test project type is potentially one of two issues this clean and build fixed.
  • bkwdesign
    bkwdesign over 3 years
    My coworker who tried to build the solution on his company issued workstation was missing one of the .NET core runtimes (even though this wasn't a .NET core app). I exported my Visual Studio config (using the 'more' button in the Visual Studio Installer) and we compared configs to finally figure out why it worked for me and not for him
  • Dave
    Dave over 3 years
    Exact same issue as described above. This worked for me.
  • bkwdesign
    bkwdesign over 3 years
    hah.. on a new PC I just built and googled my way back to my own answer! This time I needed some of the .NET Framework targeting packs
  • Ruben9922
    Ruben9922 about 3 years
    I presume you mean you reverted to 4.7.2?
  • Ruben9922
    Ruben9922 about 3 years
    For me removing that whole line worked too. In my case it seems to have been caused by creating a new project configuration for that particular project in a newer version of Visual Studio, then attempting to rebuild it in an older one.
  • Darren S
    Darren S almost 3 years
    This fixed it for mine as well. Great job finding that.
  • Marcus.D
    Marcus.D over 2 years
    Every time I have this problem, I'm faced with the question, "What was the solution again?". And then it's "so simple". Thanks for your feedback. (worked with VS2019 / ASP.NET Solution)
  • AtLeastTheresToast
    AtLeastTheresToast over 2 years
    Give this guy a medal.
  • dev'd
    dev'd over 2 years
    It fixes the issue, but then if I Rebuild again immediately afterwards, it comes back. I can only Build/Rebuild successfully after a Clean. Any idea what could be causing that behavior?
  • Rush.2707
    Rush.2707 about 2 years
    Worked for me too
  • kevinpo
    kevinpo about 2 years
    I had to leave the Toolset uninstalled, to prevent this issue: stackoverflow.com/questions/59276192/…
  • Admin
    Admin almost 2 years
    In case of troubles with some OLD frameworks I recomend this solution. This solution also worked for me, working on some legacy project still using .NET framework 4.5.2. (don't ask....) I'm using Visual Studio 2022, solution has been building before, but after few updates (and few moths inbetween) it just did not build anymore.