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

Question Generated .csproj source path invalid (Visual Studio Code Editor 1.2.4?)

Discussion in 'Editor & General Support' started by Lieene-Guo, Nov 2, 2021.

  1. Lieene-Guo

    Lieene-Guo

    Joined:
    Aug 20, 2013
    Posts:
    547
    I am working with Unity 2021.1.13 and vscode.
    After I upgraded vscode editor package to 1.2.4, all my generated package .csproj reference sources from
    this path:

    instead of

    This makes my vscode unable to reference the source code. And omnisharp reported missing type everywhere.
    Although unity compiles okay I am not able to use intelligence in vscode whatsoever.
    Switching external coding tools to VS 2019 and regenerating project files can fix this but I need to work in vscode.
    Please help fix the problem.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,756
    This may help you with intellisense and possibly other Visual Studio integration problems:

    Sometimes the fix is as simple as doing Assets -> Open C# Project from Unity. Other times it requires more.

    https://forum.unity.com/threads/intellisense-not-working-with-visual-studio-fix.836599/

    Also, try update the VSCode package inside of Unity: Window -> Package Manager -> Search for Visual Studio Code Editor -> Press the Update button

    Also, this: https://forum.unity.com/threads/no-suggestions-in-vscode.955197/#post-6227874
     
  3. Lieene-Guo

    Lieene-Guo

    Joined:
    Aug 20, 2013
    Posts:
    547
    Thank Kurt, for your replay.
    I have been using the solution you mentioned. But this time the problem is when I upgrade vscode editor package from 1.2.3 to 1.2.4, the csproject generation part of it works differently (when pressing "Generate all csproj files" )
    The generated csproject for unity package looks for source in a wrong path.
    upload_2021-11-3_11-23-40.png
    The Packages\com.unity.timeline part should be Library\PackageCache\com.unity.timeline@1.6.3
    The same Packages instead of Library\PackageCache happens to all unity packages.

    I'm trying to work with Unity 2021.2 now. but 2021.2 lock vscode editor package at 1.2.4
    So I can't solve the problem by downgrade vscode editor
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,756
    Try clear your package caches (google for how)... it's possible some part of it thinks it's using a different version.
     
  5. Lieene-Guo

    Lieene-Guo

    Joined:
    Aug 20, 2013
    Posts:
    547
    I started a new clean project in 2021.2 it still happens. I believe this is a vscode editor package bug.
    I'm still trying for a walkaround.
    Despite of wrong csproj file, Unity itself can compile perfectly well. So,now I turn off all of this.
    upload_2021-11-3_11-47-44.png

    But my project depends on asm reference trick
    upload_2021-11-3_11-48-52.png
    upload_2021-11-3_11-49-29.png

    which will force Unity to generate csproject package

    So I still have to fixed the Packages instead of Library\PackageCache problem manually... every time...
     
    Kurt-Dekker likes this.
  6. Lieene-Guo

    Lieene-Guo

    Joined:
    Aug 20, 2013
    Posts:
    547
    https://github.com/Unity-Technologies/com.unity.ide.vscode/issues/4