Visual Studio 2019 doesn't have "Attach to Unity" but only in a new project.

I have a new Unity project that for whatever reason I can only manually connect the debugger in Visual Studio. Up at the top where all of my older projects say “Attach to Unity” next to the green “Run arrow” this new project has just “Start” like it’s a regular C# solution. If I attempt to debug and click start it I get the error “A project with an output Type of Class Library cannot be started directly.”

I can manually attached to unity by going Debug → Attach Unity Debugger → Selecting Unity. So I know that Visual Studio has all the pieces it needs. But that’s a tedious way to get the debugger working. All of the forum posts I’ve found are assuming that Visual Studio is missing a component, but it’s my project that’s configured wrong and I’m not sure what’s wrong.

My old project shows an icon of the Unity Debugger in front of a Win form. (I tried to post an image, but the spam catcher nuked it)

My new project shows “C#” in a box with a green border.

The Icons are different, so my solution is set wrong, but I’m not sure how to fix it. Every setting I compare on the two solutions are identical.

Any ideas?

Thank you

See the images for the two Icons I’m getting.

4768136--453623--right.PNG
4768136--453626--wrong.PNG

Delete the sln visual studio project file in your unity project Directory.
Restart Unity, then go to Edit > Preferences > External Tools and re-select VS as your external editor.
Unity re-generate the sln file in your project directory.
Then go to Assets > Open C# Project.

5 Likes

worked for me

Awesome, this worked me also. Thank you!