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

Debugging with Visual Studio

Discussion in '2018.1 Beta' started by MarekM2, Jan 11, 2018.

  1. MarekM2

    MarekM2

    Joined:
    Dec 9, 2013
    Posts:
    12
    In the previous editor version I was able to connect to Unity process using VS, put some breakpoints and see what's going on. While trying to do so after the upgrade, I'm unable to. VS complains that my project is a class library and not an executable. I guess it has something to do with VS Unity tools not being up to date with the new Unity, or am I missing something?
     
  2. Schodemeiss

    Schodemeiss

    Joined:
    Jan 4, 2018
    Posts:
    43
    I appear to have the same issue. It does work if I hit "Attach to Unity Play" in Visual Studio itself, but it used to work directly from the editor.
     
  3. MarekM2

    MarekM2

    Joined:
    Dec 9, 2013
    Posts:
    12
    Not sure if we have the same problem - for me it doesn't work when I attach to unity FROM vs.
     
  4. BlackPete

    BlackPete

    Joined:
    Nov 16, 2016
    Posts:
    970
    Try the following:

    1) Delete your .csproj and .sln files. These are auto-generated by Unity, so these probably need a refresh. Delete the (possibly hidden) .vs folder as well to ensure VStudio starts from a clean slate.

    2) The Unity Tool for VS tool might have been corrupted somehow. That may need a re-install/repair to fix that.
     
  5. MarekM2

    MarekM2

    Joined:
    Dec 9, 2013
    Posts:
    12
    Actually, it's kinda funny. I've been doing a major refactor of my codebase, like splitting stuff into separate assemblies, removing unused classes etc. and during that it seems Unity has overwritten .csproj and even .sln files a couple of times and now it works. Probably by accident, but I did as you suggest in the first point and that did the trick. Thanks anyway :)
     
  6. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,136
    Thanks for reporting this issue. We have forwarded the feedback to Microsoft.
     
  7. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,364


    :D
     
    karl_jones and LeonhardP like this.
  8. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    The whole attach to Unity button stuff that was in Visual studio doesn't even show up anymore, and I haven't touch customizing VS in months.. so dunno what is up with that.. so yeah I can only debug when using the menu [Debug] >[Attach to Unity Play]> [select the Unity process] ...and only after all that, does it work.... it used to just be a button on the toolbar....
     
  9. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    That problem seems to be fixed after 2018.1.b3 was installed for me... VS shows the attach unity button again.
     
  10. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,364
    don't worry that won't last
     
  11. sailro

    sailro

    Microsoft

    Joined:
    Jul 30, 2014
    Posts:
    167
    Hi

    We investigated with Unity this case where Unity 2018 beta was not properly delegating to VSTU the generation of solution and project files. Because of this, you ended up with a regular C# solution so all VSTU features regarding debugging, wizards, reloading, etc... were disabled in VS.

    It was a registration issue, that was just fixed in Unity beta. We also patched VSTU to be more resilient about those issues.

    We expect the fix to be soon available in Unity beta.

    Regards
    Sebastien Lebreton [MSFT]