Search Unity

Searching code in Package Manager from Visual Studio

Discussion in 'Package Manager' started by DougRichardson, Aug 17, 2018.

  1. DougRichardson

    DougRichardson

    Joined:
    Oct 7, 2017
    Posts:
    74
    I've been experimenting with the Package Manager, specifically with the PostProcessing package.

    Previously, my generated Visual Studio projects contained source code for PostProcessing (since it was in my Assets folder). This allowed me to use the Visual Studio text search tools to find code in PostProcessing another packages I'd installed in my Assets folder.

    However, using PostProcessing from Package Manager, I noticed that Visual Studio text search tools no longer work. It appears that Unity Package Manager packages do not appear in the Visual Studio project at all anymore.

    Is there anyway to include the packages in my project like before? If not, is there another project that I can open to at least search each package individually?
     
  2. okcompute_unity

    okcompute_unity

    Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    575
  3. DougRichardson

    DougRichardson

    Joined:
    Oct 7, 2017
    Posts:
    74
    I have VSTU 3.8.0.3 installed.

    If I press F12 on a symbol, I jump to the definition in a Temp folder. For example, if I F12 on PostProcessVolume in my code, it jumps to:

    C:\Users\doug\AppData\Local\Temp\MetadataAsSource\6b16eb2592df43308294c28d5ea28df4\9769368ebf3543a885e48baa2f6220a7\PostProcessVolume.cs

    At that point, if I do a Find All on "PostProcessVolume" it will appear in the search results. However, other post processing file results do not appear, only the ones I've done an F12 lookup on.
     
  4. sailro

    sailro

    Microsoft

    Joined:
    Jul 30, 2014
    Posts:
    73
    Hi,

    Adding @lukaszunity to the thread.

    Previously VSTU was in charge of generating project files and solution file. Starting with 2018.1, VSTU is now using Unity's generated files. So probably the different generation logic introduced this behavior.

    Could you try to provide a working project (like when using an older Unity version < 2018.1), and your current project so that @lukaszunity will be able to diff generated files and find the potential issue ?

    Thanks!
    Sebastien Lebreton [MSFT]
     
  5. DougRichardson

    DougRichardson

    Joined:
    Oct 7, 2017
    Posts:
    74
    Hi Sebastien. The difference isn't between older versions of Unity and newer versions of Unity. The difference is between using the new package system and not using the new package system.

    Previously, you brought packages into your Assets folder, which meant they were included in the Visual Studio project.

    Now with the Package Manager, when you import a package it's source files are no longer included directly in the Visual Studio project (so the Find in Files tool doesn't work for files in the package).

    I don't think this is a Visual Studio bug, I think it's just due to how the Package Manager works.

    The reason I started this thread is because, while I like the new Package Manager, it does make understanding your games code base more difficult since it's harder to search all files in your game from a single place.
     
  6. LaurensMMonk

    LaurensMMonk

    Joined:
    Jun 6, 2018
    Posts:
    6
    While trying to understand the lightweight render pipeline I encountered this same problem; Visual Studio doesn't know where definitions are because the packages aren't in the same solution.

    My work-around was to clone the scriptable render pipeline code from github (though I suppose you could also grab the packages from the cache) and add it to a Packages subfolder under assets. This can result in conflicts with the version compiled via package manager, which I haven't figured out how to solve yet, so the work-around only really works in clean Unity projects. You might then still run into issues with shader includes, so you might have to change those to relative paths.

    Once I worked through all those error messages, I managed to get the lightweight scriptable pipeline working this way. Maybe you can do the same for the post processing package.



    That said, it seems to me that Unity should add the packages to the same solution file, so that Visual Studio's functionality just works. (Before trying this work around, I made sure that I was using the latest Unity plugin for Visual Studio 2017, using Microsoft's updater.)
     
  7. fherbst

    fherbst

    Joined:
    Jun 24, 2012
    Posts:
    268
    I would like to bring this up again @okcompute_unity as this is super annoying.
    • Packages in the project don't show up in Visual Studio project
    • after double-clicking on a file in a package Visual Studio can't find any references in it (due to nothing being loaded)
    • compare this to the behaviour in Rider, where packages can be navigated "as usual"
     
  8. okcompute_unity

    okcompute_unity

    Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    575
    @fherbst , do you have the latest version of VSTU installed?
     
  9. fherbst

    fherbst

    Joined:
    Jun 24, 2012
    Posts:
    268
    How do I find out what the latest is?
    Visual Studio tells me: "Visual Studio 2017 Tools for Unity", version 3.9.0.3
    Unity Package Manager tells me: "Visual Studio Editor", version 1.0.11
    Unity version is 2019.3.0b1, but I've seen this since package manager got introduced

    The behaviours I'm seeing:
    • Visual Studio opens many many instances - sometimes after double clicking on a newly created script, sometimes if some scripts were already open in VS (from the same project but inside different asmdef)
    • in some projects I'm getting csproj files for Packages in some not (on the same Unity version), this seems to depend on whether the project was updated or newly created (works better in newly created ones)
    • in some projects I had to manually delete sln+csproj files that existed before new ones were generated for different packages (in one case I had a sln file that Unity created back in 4.7, in a project that I continuously updated, and that sln file seemed to have prevented generation of package csproj files)
    • I can't navigate code inside of packages when opening them in visual studio, also I can see that there is no csproj for them
    • the magical button "open C# project" only creates csproj files for things in Assets and for packages that are editable, but not for regular packages
     
  10. okcompute_unity

    okcompute_unity

    Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    575
  11. fherbst

    fherbst

    Joined:
    Jun 24, 2012
    Posts:
    268
    It says "Added support for Unity packages in the UPE. Only Referenced packages (using manifest.json in the Packages folder) and Local packages (embedded in the Packages folder) are visible." Version 4.1.0.0, released May 21, 2019.

    However, the latest available version according to the Extensions marketplace is 3.9.0.3. Visual Studio 2017 has all the latest updates, the machine has all the latest Windows updates. Are you seeing a different version?

    upload_2019-9-9_23-39-55.png
     
  12. okcompute_unity

    okcompute_unity

    Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    575
    I'm not seeing anything. I'm not using Visual Studio and VSTU! :p
     
  13. fherbst

    fherbst

    Joined:
    Jun 24, 2012
    Posts:
    268
    How helpful!

    (seriously...?!)
     
  14. okcompute_unity

    okcompute_unity

    Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    575
    Yes, I'm serious. I don't use VSTU. I'm sorry I cannot be of help here. This is the community forum, so maybe a user or one the VS plugin authors/maintainers can respond (One of them is on this thread). You can also fill a bug to Microsoft.