Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Visual Studio 2017 not generating solution files

Discussion in 'Editor & General Support' started by GingeryBeard, Jan 26, 2018.

  1. GingeryBeard

    GingeryBeard

    Joined:
    Mar 30, 2013
    Posts:
    2
    I have a unity project I'm working on but I'm having trouble using Visual Studio 2017 for scripting. Monodevelop seems to work fine though but I would rather use Visual Studio. It's only this one project which has this error as I can use Visual Studio 2017 fine on any other project.

    Whenever I try to open a script or use Assets->Open C# Project I get this error in the console (pasted below) in the console and no sln or cproj files are created.


    Error:
    ArgumentException: Value does not fall within the expected range.
    SyntaxTree.VisualStudio.Unity.Bridge.CompilationUnit.LanguageOf (SyntaxTree.VisualStudio.Unity.Bridge.CompilationUnit unit)
    SyntaxTree.VisualStudio.Unity.Bridge.CompilationUnit.CompilationUnits (System.String method)
    SyntaxTree.VisualStudio.Unity.Bridge.CompilationUnit.CompilationUnits ()
    SyntaxTree.VisualStudio.Unity.Bridge.ProjectSystem.UnitySolutionBuilder..ctor ()
    SyntaxTree.VisualStudio.Unity.Bridge.ProjectSystem.UnitySolutionBuilder.CreateSolutionFromAssetDatabase ()
    SyntaxTree.VisualStudio.Unity.Bridge.ProjectFilesGenerator.GenerateProject ()
    SyntaxTree.VisualStudio.Unity.Bridge.ProjectFilePostprocessor.OnPreGeneratingCSProjectFiles ()
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
    Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
    System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
    UnityEditor.AssetPostprocessingInternal.OnPreGeneratingCSProjectFiles () (at C:/buildslave/unity/build/Editor/Mono/AssetPostprocessor.cs:61)
    UnityEditor.VisualStudioIntegration.SolutionSynchronizer.Sync () (at C:/buildslave/unity/build/Editor/Mono/VisualStudioIntegration/SolutionSynchronizer.cs:189)
    UnityEditor.SyncVS.CreateIfDoesntExist () (at C:/buildslave/unity/build/Editor/Mono/SyncProject.cs:147)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
     
  2. GingeryBeard

    GingeryBeard

    Joined:
    Mar 30, 2013
    Posts:
    2
    Updating Visual Studio to 15.5.5 seems to have solved the problem. For anyone else having this problem, go to Tools->Extensions and Updates and then under Updates you'll have the update if you are on an older version,
     
  3. Desoxi

    Desoxi

    Joined:
    Apr 12, 2015
    Posts:
    195
    The VS update (>= 15.5.5) helped me as well. Though you need to fix all compiler errors before you can open your projects via assets-> open c# project.
     
  4. Docboy

    Docboy

    Joined:
    Sep 11, 2013
    Posts:
    14
    SOLVED for me too
     
  5. Burljon

    Burljon

    Joined:
    Jun 28, 2017
    Posts:
    2
    I had to update to Visual studio 15.7.3 after a Windows upgrade (that broke other software, too,) AND a Unity upgrade. Not sure which did what, but it's going again. (The windows upgrade was for GDPR compliance, I'm pretty sure, so I'll blame it on that. HA!)
     
  6. trojanfoe_

    trojanfoe_

    Joined:
    May 20, 2014
    Posts:
    53
    I'm still getting this issue with Unity 2018.1 and VS 2017 15.7.4. Also I don't see "Visual Studio" in the list of External Editors in the Unity Preferences; it's set to "internal", which works when I double-click a .cs file.
     
  7. AngelGabriel

    AngelGabriel

    Joined:
    Feb 1, 2016
    Posts:
    4
    I am encountering a similar error (copied below), both with 2018.1.7f1 and the just released 2018.2.0f2, when updating from 2017.3.1f1.

    I was able to reproduce the issue in a project with no plugins or packages. A bug report has been submitted.

    ArgumentException: Value does not fall within the expected range.
    SyntaxTree.VisualStudio.Unity.Bridge.CompilationUnit.LanguageOf (SyntaxTree.VisualStudio.Unity.Bridge.CompilationUnit unit)
    SyntaxTree.VisualStudio.Unity.Bridge.CompilationUnit.CompilationUnits (System.String method)
    SyntaxTree.VisualStudio.Unity.Bridge.CompilationUnit.CompilationUnits ()
    SyntaxTree.VisualStudio.Unity.Bridge.ProjectSystem.UnitySolutionBuilder..ctor ()
    SyntaxTree.VisualStudio.Unity.Bridge.ProjectSystem.UnitySolutionBuilder.CreateSolutionFromAssetDatabase ()
    SyntaxTree.VisualStudio.Unity.Bridge.ProjectFilesGenerator.GenerateProject ()
    SyntaxTree.VisualStudio.Unity.Bridge.ProjectFilePostprocessor.OnPreGeneratingCSProjectFiles ()
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
    Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
    System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
    UnityEditor.AssetPostprocessingInternal.OnPreGeneratingCSProjectFiles () (at C:/buildslave/unity/build/Editor/Mono/AssetPostprocessor.cs:194)
    UnityEditor.VisualStudioIntegration.SolutionSynchronizer.Sync () (at C:/buildslave/unity/build/Editor/Mono/VisualStudioIntegration/SolutionSynchronizer.cs:207)
    UnityEditor.SyncVS.SyncSolution () (at C:/buildslave/unity/build/Editor/Mono/SyncProject.cs:190)
    UnityEditor.SyncVS.SyncAndOpenSolution () (at C:/buildslave/unity/build/Editor/Mono/SyncProject.cs:181)
     
  8. AngelGabriel

    AngelGabriel

    Joined:
    Feb 1, 2016
    Posts:
    4
    As others in this thread suggest, an update of Visual Studio resolved the issue for me as well.
    Old version: 15.0.26430.16
    New version: 15.7.27703.2042

    @trojanfoe123 it's odd that Visual Studio 2017 is not listed for you...
    Maybe try to manually specify the application? Unity Preferences -> External Tools -> External Script Editor -> Browse... then look for
    C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.exe
     
  9. Esperstal

    Esperstal

    Joined:
    Jun 27, 2019
    Posts:
    1
    Yep this did it for me!!
     
  10. YJack

    YJack

    Joined:
    Apr 7, 2010
    Posts:
    44
    Same issue here with VS17. Update did NOT solved for me.