Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Issues with Visual Studio + Unity

Discussion in '2018.2 Beta' started by LeonhardP, Jan 25, 2018.

  1. sailro

    sailro

    Microsoft

    Joined:
    Jul 30, 2014
    Posts:
    167
    And you should be able to use Command ⌘-Shift-M for the unity messages wizard :p
     
    f1chris likes this.
  2. jbevain

    jbevain

    Microsoft

    Joined:
    Feb 22, 2012
    Posts:
    141
    No worries, glad to hear you're all set!
     
  3. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hey, @jbevain and @sailro

    Sometimes I'm getting weird issue - I can't attach to the Unity from the VS for debug.
    I see Unity instance at the Attach to Unity dialog:
    upload_2018-3-3_1-29-9.png

    But when I select it and press OK this dialogue closes and I can see nothing literally happens.
    It doesn't enter debug mode and doesn't attach Unity,
    Same for the Attach to Unity button at the VS toolbar (except it compiles things).

    I was on latest official release of VSTU and Unity 5.6 + VS 2017. 15.5.7 and updated VSTU to the latest version you posted on the previous page but it didn't helped.

    Are there any kind of logs anywhere where I could check what could be wrong?

    Thanks!
     
  4. jbevain

    jbevain

    Microsoft

    Joined:
    Feb 22, 2012
    Posts:
    141
    This usually means that the VSTU debugger can not open a connection to the TCP server in Unity's scripting runtime.

    Sometimes it means that the «Allow Editor Attaching» setting in Unity is set to false.
    Most of the times it means that the debugger server in Unity's scripting engine has crashed, and that you'll need to restart Unity.

    I'll make a note to add some logging to the VS output window when we fail there.
     
    codestage likes this.
  5. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Thanks for your quick reply, @jbevain !

    Though I have Editor Attaching enabled and did tried to restart Unity, restart VS, restart both of them, clean all VS files in the project directory, clean Library folder and reimport project in Unity - all without any luck.

    The interesting thing it worked once today, then I changed some code and it stopped to work.

    It happened before too on other projects with other Unity versions (including 2017.*) but usually clean reimport and / or restart of all helped, but not today =\

    Will try to reboot PC, it should help I believe.

    That would be very helpful!

    ---

    PC reboot fixed the issue, debugger can attach again.
     
    Last edited: Mar 2, 2018
  6. sailro

    sailro

    Microsoft

    Joined:
    Jul 30, 2014
    Posts:
    167
    Pasting here
    Perhaps you tried the following, but just in case:

    Unable to attach
    • Try to temporarily disable your antivirus or create exclusion rules for both VS and Unity.
    • Try to temporarily disable your firewall or create rules for allowing TCP/UDP networking between VS and Unity.
    • We identified that programs like Team Viewer are interfering with process detection; perhaps you can try to stop temporarily any extra software to see if it changes something.
    • Do not rename the main Unity executable, as VSTU is only monitoring "Unity.exe" processes.
     
    codestage likes this.
  7. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Thanks, @sailro

    I'm using only Windows Firewall (with Windows Firewall Control wrapper) and it doesn't block Unity and VS connections (they are added to the allowed) and I have no AV (even disabled the built-in Windows Defender antivirus).
    Also I'm not using anything like TeamViewer, and didn't renamed Unity executables.

    Strange part it works initially and then suddenly stops to work.

    I've rebooted PC and it works again (didn't removed or added any other software, just rebooted a PC).
    For now I'm safe, though would be nice to know a bit more about possible causes of the issue in the feature (e.g. see the crash message on the Unity side, in Editor log or as a message box, see some information on the VS side - why it was not able to connect) to be able somehow troubleshoot it or at least make a good bug report with more details for you guys.

    Thank you both @sailro and @jbevain for the quick reaction and great support, as always!
     
  8. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,550
    Are you still using the script you posted or mine? He explained why the reloading still happens with your method, since it triggers changed csproj files on all of them I guess. The script I posted does what yours did and more, and my project isn't full reloading anymore on 15.6. I also made sure to remove or change any other "OnGeneratedCSProjFiles" scripts in my project.
     
  9. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,550
    @sailro Came upon a slight issue as a result of your recommendation, the script will throw an exception for team members who do not have visual studio installed since the code to interface with that comes from VS I guess and not Unity? So do you know if there is a pre-processor macro for if VS-Unity-Bridge is installed so we can prevent this?
    (which also brings up another point about how VS doesn't give you a list of macros when you type #if, a feature I sorely miss from Monodevelop).
     
    Last edited: Mar 3, 2018
  10. jbevain

    jbevain

    Microsoft

    Joined:
    Feb 22, 2012
    Posts:
    141
    You can wrap the script in a:

    #if ENABLE_VSTU
    #endif


    Let me check with my Intellisense people about code completion for compilation symbols.
     
    Invertex likes this.
  11. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,364
    While you talk to them, can you also ask where those fixes are at?
    990484
    996279
    988274
    988867
    989527
    990484
     
  12. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hey all,

    After installing latest VSTU 3.6.0.5 from this thread, I started to see new kind of issue: duplicate tabs

    upload_2018-3-4_23-12-38.png

    Steps to reproduce:
    - open Unity project in Unity
    - double-click any class in the Project view, so VS starts, opens solution of your project and opens double-clicked class
    - close VS
    - double-click on the same class in Unity's Project view, VS stats again, opens solution and opens double-clicked file in new tab, with name:2, like on the screenshot above.

    Unity 5.6, VS 15.5.7
     
  13. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,550
    Been noticing this issue for some weeks, not sure it's recent but definitely an issue.
     
    codestage likes this.
  14. rahuxx

    rahuxx

    Joined:
    May 8, 2009
    Posts:
    537
    In beta 9 why Unity force me to install visual studio? I don't want to install it. What option do I have to deselect it?
    Waiting for solution.
     
  15. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    @rahuxx make sure you've deselected this option

    upload_2018-3-5_16-24-5.png
     
  16. rahuxx

    rahuxx

    Joined:
    May 8, 2009
    Posts:
    537
    Sorry to mention, I am using Unity Hub and in that I am not able to deselect Visual Studio.
     

    Attached Files:

  17. jbevain

    jbevain

    Microsoft

    Joined:
    Feb 22, 2012
    Posts:
    141
    I'm not exactly sure what I'm looking at. Are those Unity bug numbers? If so, I don't have access to those.

    Are those bugs related to Visual Studio or code completion? If so, they'd be better reported over at:

    https://developercommunity.visualstudio.com/spaces/8/index.html
     
  18. jbevain

    jbevain

    Microsoft

    Joined:
    Feb 22, 2012
    Posts:
    141
    We've heard about this, but we've never been able to find a consistent repro. Do you folks have a project + method to consistently reproduce this?
     
  19. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,136
    It should only be greyed out if you already have VS installed. It's supposed to indicate that it won't be downloaded again, although I agree that it's confusing. I passed the feedback on to the Hub team.
     
    antoripa and rahuxx like this.
  20. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,364
    You def should have access to those. I clicked on that link and there was no entry field to copy paste the bug reports, I don't feel like exploring yet another web site because quite frankly I'm saturated with reporting bugs so I'll let Unity help me with that, @LeonhardP could you please send this man a copy of these bug numbers?

    Note: VS is now an integral part of unity but different companies mean no access to unity fogbugz, which I understand, but what can be done is add a VS category to the reporter and give microsoft access to those.
     
  21. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Happening again =( Maybe I can help in catching this up somehow?


    I've just tried to reproduce and have no luck with it. It seems to happen accidentally and I still can't figure out how to reproduce it in 100% cases.
     
  22. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,550
    Hi, I seem to be able to do it consistently, here is a simple project with a blank script.

    -Open the project in Unity
    -Double click the TestScript file from within Unity editor to have it launch VS.
    -Make an edit, save it, click on Unity so that it recompiles, and then close VS.
    -Double click the TestScript file again, it should open with a duplicate tab of the script.

    Even just simply opening the script, closing VS with the tab still there, and double-click opening it again to launch VS would make more and more tabs.
     

    Attached Files:

  23. jbevain

    jbevain

    Microsoft

    Joined:
    Feb 22, 2012
    Posts:
    141
    And of course I can't repro :(

    Which version of Unity + VS are you using?
     
  24. jbevain

    jbevain

    Microsoft

    Joined:
    Feb 22, 2012
    Posts:
    141
    Quick question: are you starting the debugger without a project loaded?
     
  25. jbevain

    jbevain

    Microsoft

    Joined:
    Feb 22, 2012
    Posts:
    141
    I'm afraid filing Visual Studio bugs at Unity is completely unproductive for everyone involved.
    1. For Unity it increases their QA workload instead of focusing on Unity.
    2. For Visual Studio it means not being to track properly the issue.
    3. For the user who's negatively impacted by the bug, it means there's a significant chance the bug will be either not fixed, not understood by Unity's QA, not well dispatched, and in the end, you have the live with the bug longer than you could have by filing it at the right place.
    (At that point that's just common sense)

    You can file Visual Studio bugs either from Visual Studio itself (the send feedback icon in the top right corner) or on:

    https://developercommunity.visualstudio.com/

    Better yet, if your issue is related to C# code completion / code coloration, this part is open-source and you can interact directly with the developers at:

    https://github.com/dotnet/roslyn/

    Here's an example of a bug report there:

    https://github.com/dotnet/roslyn/issues/24432
     
  26. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Both Unity and VS projects are properly loaded at that moment.
    Unity is not in the Play Mode.
     
  27. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Looks like I managed to reproduce that double tabs, as @Invertex described.
    Just closing VS with any class opened in a tab and double-clicking same class in Unity opens VS with duplicate tab for that class.

    Interesting thing, now it even doesn't show ":1" or ":2", just two tabs with same name:

    upload_2018-3-7_0-23-37.png
     
  28. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,550
    VS preview 15.6 p6 and Unity 2017.3.1p1

    Just tried latest update for the preview (p7) and also just updated regular VS Community to the new 15.6 release. Issue still seems to happen with both.

    VSTU shows version 3.6.0.4
     
    Last edited: Mar 6, 2018
  29. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,364
    So you're asking unity users to file reports themselves to microsoft and in your post you show me one that was filed by one of yours guys on behalf of a Unity QA guy and it is fixed, proving that if a bug gets reported to unity it follows the right channel and gets fixed.
    :D
     
  30. jbevain

    jbevain

    Microsoft

    Joined:
    Feb 22, 2012
    Posts:
    141
    At this point I can’t even. We’re just trying to help users and be productive.

    What’s with the attitude, Laurent?
     
    Prodigga likes this.
  31. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,550
    You're starting to be kinda rude. You especially should understand by now how backed up Unity's Feedback system already is. Are you saying you'd actually want it to go through Unity's system and then to the VS team instead of simply directly to them? Why? You're getting mad at them for Unity's inability to direct all the VS related bug reports to them... Yeah exceptions to the norm happen like the situation you pointed out, but that isn't the report chain we should expect or want.
     
  32. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,364
    Don't get overly sensitive, I am just pointing out that your link is proving exactly my point: that MS and Unity QA talking is super efficient and should be the way it's done.

    Also I am sure you are aware that individuals don't get much pull at MS, I remember going through Azure UX fiasco and seeing so many complaints on the forum met by the most polite replies, but a year pass and the UX swapped to default, almost unchanged.

    I have good experience with microsoft in many many ways but bug reporting is not one of them. This is why I don't want to go through another Azure and be yet another unheard voice by the microsoft juggernaut.

    (now to temper this, I followed your advise and logged a few of the autocomplete bugs through that interface, I'd love to be proven wrong)
     
  33. jbevain

    jbevain

    Microsoft

    Joined:
    Feb 22, 2012
    Posts:
    141
    Thanks folks. I'll need to reach out to my core team to help investigate this, and I'll get back to you.
     
    Aurelinator and codestage like this.
  34. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    @jbevain do you think there's a chance it'll move away from full project regeneration ever? It would be nice to be able to support things like assembly binding redirects and make manual csproj changes.
     
    AdamQ and codestage like this.
  35. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,053
    And nuget support...
     
    AdamQ likes this.
  36. jbevain

    jbevain

    Microsoft

    Joined:
    Feb 22, 2012
    Posts:
    141
    I sure would like bi-directional support for csprojs, but it also sounds like a lot of work for Unity.

    You should let them know, wink wink.
     
    Peter77 likes this.
  37. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Already started that process as well. ;)
     
    codestage likes this.
  38. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Will there be a solution for the excessive amount of reloads required with Unity 2018.1 beta 10? I have deleted the solution and the rebuilt one still stresses me so. What can be done? I even tried Rider out which doesn't have this issue.
     
  39. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,550
    Have you made sure there are no OnGeneratedCSProjectFiles() scripts in your project? That was the source of the issue for us. Now the only time it does a full reload is when a new assembly is added/removed.

    Also you can greatly speed up the load time using my script here that cleans up Unity's junk filled csproj files.:

    https://forum.unity.com/threads/issues-with-visual-studio-unity.514304/#post-3409933
     
  40. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I updated VS and the reload nagging went away but now checking VS's blue status bar I see it is reloading automatically and often - but taking an awfully long time about it... I have to wait ages when double clicking a file from within Unity. It appears to be reloading constantly except the only change is it is hiding the dialog boxes.

    I tried your script but it's still taking forever to open files from within Unity. Sad, version 15.6.1
     
    Last edited: Mar 11, 2018
  41. slime73

    slime73

    Joined:
    May 14, 2017
    Posts:
    107
    VOTRUBEC and Dustin-Horne like this.
  42. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    That was it. Thank you, not sure how I missed it! Thanks everyone.
     
    Dustin-Horne likes this.
  43. jbevain

    jbevain

    Microsoft

    Joined:
    Feb 22, 2012
    Posts:
    141
    FYI, the support for the project generator in Unity 2018.1 is scheduled to be released in Visual Studio 15.6.2, on or about this week.
     
  44. pahe

    pahe

    Joined:
    May 10, 2011
    Posts:
    543
    Hey guys. I'm recently using 2018.1.0b10 and noticed the broken VS Tools for Unity. Sadly the 3.6.0.5 aren't available for VS 2012 which I'm using. Will it be available for VS 2012 later or do I have to switch my IDE too?
     
  45. jbevain

    jbevain

    Microsoft

    Joined:
    Feb 22, 2012
    Posts:
    141
    3.6.0.5 will be available for Visual Studio 2015 and Visual Studio 2017.
     
    Dustin-Horne likes this.
  46. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,550
    Dunno where suggestions would go for the addon so just leaving it here, but wondering if it would be possible to have the Solution Explorer not show all the folders that lead up to the location of the Assembly Definition? It's pointless to show those folders, since an asmdef folder only has access to its children. Would go a long way towards cleaning up the solution explorer.

    Normally this isn't a problem for the usual VS project, but with this asmdef system, the csproj file is often located many parent folders up, completely disconnected from where the assembly's files are.

    I imagine the simplest solution to this without having to deal with relocating a bunch of stuff and generating proper references would be to simply support an attribute on <Compile> elements in the csproj which would be something like :

    <Compile StripPath="Assets\Plugins\" Include="Assets\Plugins\MyPlugin\Script.cs" />

    Or even just have it as a top level attribute that can be referenced.
    Then have the Solution Explorer strip that portion from being displayed in the hierarchy.

    Even better would be for VS to simply support a relative-source-root parameter.
     
    Last edited: Mar 13, 2018
    JesOb and codestage like this.
  47. jbevain

    jbevain

    Microsoft

    Joined:
    Feb 22, 2012
    Posts:
    141
    Why don't you simply use the Unity project viewer in VS? (View -> Unity Project Explorer). That will give you the project using the Unity folder structure?
     
  48. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,550
    While that works for simple interaction and it's nice it exists, it lacks nearly all the right-click options that Solution Explorer offers (and that installed extensions may add). The SE also allows you to know for sure which scripts are part of what assembly and focus on specific assemblies (once you've cleaned out the junk includes that are currently being added). If Unity is going to be pushing this Assembly Definition workflow, then it seems silly to not properly represent the assemblies in the solution explorer. But since there's no way as far as I know yet to define a deeper folder as the root of your source files in VS, it makes it fairly messy right now.
     
  49. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Just for the records, I've submitted a Case 1014650 to the Unity about my problem with VS connection to the Unity socket with as much info as possible (Bug Reporter has a limitations on report characters count, so I tried to shrink report a bit without loosing important information to fit there).
     
    jbevain likes this.
  50. jbevain

    jbevain

    Microsoft

    Joined:
    Feb 22, 2012
    Posts:
    141
    Ah I see what you mean.

    Yeah we're currently working on revamping our project system based on the modern C# project system (we're currently using the legacy one in VS). This should give us more control over how we can display the Solution Explorer, including possibly cleaning the folder hierarchy when using asmdefs. It's still a little bit down the line though.
     
    Invertex likes this.