Search Unity

Bug CS1061: 'ScriptCompilerOptions' does not contain a definition for 'LanguageVersion'

Discussion in 'Scripting' started by AxyC, Jun 1, 2023.

  1. AxyC

    AxyC

    Joined:
    Sep 9, 2021
    Posts:
    4
    Hello, when I open my Unity Project it gives these errors, and I can't load my scripts nor I can enter playmode.
    Any help would be appreciated.

    Library\PackageCache\com.unity.ide.visualstudio@2.0.18\Editor\UnityInstallation.cs(55,87): error CS1061: 'ScriptCompilerOptions' does not contain a definition for 'LanguageVersion' and no accessible extension method 'LanguageVersion' accepting a first argument of type 'ScriptCompilerOptions' could be found (are you missing a using directive or an assembly reference?)

    Library\PackageCache\com.unity.ide.vscode@1.2.5\Editor\ProjectGeneration\ProjectGeneration.cs(561,45): error CS1061: 'ScriptCompilerOptions' does not contain a definition for 'LanguageVersion' and no accessible extension method 'LanguageVersion' accepting a first argument of type 'ScriptCompilerOptions' could be found (are you missing a using directive or an assembly reference?)
     
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,188
    Both of those are targeting your package cache. Packages that are downloaded using the package manager are usually installed in a central location where all projects using those packages can pull from. This avoids having the same package pushed out with every project as part of your repo and instead, the package manifest just references what package it should use.
    So, check your package manager in Unity and remove/update those packages and see if that helps. If you remove them, you can reinstall only the one you need for whatever ide you use.
     
    AxyC likes this.
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,735
    Extra unwanted packages in new projects (collab, testing, rider and other junk):

    https://forum.unity.com/threads/temp-unityengine-testrunner-dll-error.1133938/#post-7287748

    About the fastest way I have found to make a project and avoid all this noise is to create the project, then as soon as you see the files appear, FORCE-STOP (hard-kill) Unity (with the Activity Manager or Task Manager), then go hand-edit the Packages/manifest.json file as outlined in the above post, then reopen Unity.

    Sometimes the package system gets borked from all this unnecessary churn and requires the package cache to be cleared:

    https://stackoverflow.com/questions/53145919/unity3d-package-cache-errors/69779122
     
    AxyC likes this.
  4. AxyC

    AxyC

    Joined:
    Sep 9, 2021
    Posts:
    4
    It didn't work, but thanks to your post I had an insight. I think that, since I've got 2 unity versions, (2022.1.20f1 and 2020.2.a21), by migrating the project to 2022.1.20f1 will solve it.

    By the way, I couldn't delete any packages because the ones that caused the problems are the ones I need the most.