Skip to content

Added support for Visual Studio Community, Professional, Enterprise 2017 (v15.2^), 2019, 2022 - #14662

Closed
Nico-Connor-Personal wants to merge 6 commits into
desktop:developmentfrom
Nico-Connor-Personal:development
Closed

Nico-Connor-Personal wants to merge 6 commits into
desktop:developmentfrom
Nico-Connor-Personal:development

Conversation

@Nico-Connor-Personal

@Nico-Connor-Personal Nico-Connor-Personal commented May 23, 2022 •

Copy link
Copy Markdown

Closes #12946

Description

Implementing Visual Studio support required an unconventional approach since Visual Studio doesn't use a unique registry key like most other IDEs.

Thankfully as of Visual Studio 2017 v15.2, Microsoft includes a CLI tool called vswhere with the visual studio installer to help locate the path to their IDE. The installer has a unique registry key that we can use to locate its install path which will then allow us to query VSWhere and find the install paths for various visual studio installs.

Screenshots

Workstation 1

Windows 11 64 bit - Visual Studio Community 2022

VS Github

Workstation 2

Windows 10 64 bit - Visual Studio Professional 2019, 2022

image

Release notes

Added IDE support for:

  • Visual Studio Community 2022
  • Visual Studio Professional 2022
  • Visual Studio Enterprise 2022
  • Visual Studio Community 2019
  • Visual Studio Professional 2019
  • Visual Studio Enterprise 2019
  • Visual Studio Community 2017 (only version 15.2 and up)
  • Visual Studio Professional 2017 (only version 15.2 and up)
  • Visual Studio Enterprise 2017 (only version 15.2 and up)

Notes:

I don't have access to a 32 bit computer and therefore couldn't test my change on a 32 bit computer. The registry location for the Visual Studio Installer might be different on a 32 bit computer.

@AraHaan

AraHaan commented May 23, 2022 •

Copy link
Copy Markdown

32 bit computers are about 3% or less of modern developers nowadays so it’s a minor issue on not being able to test 32 bit.

@Nico-Connor-Personal

Nico-Connor-Personal commented May 23, 2022 •

Copy link
Copy Markdown
Author

Turns out, according to the VSWhere documentation:

vswhere.exe is installed in %ProgramFiles(x86)%\Microsoft Visual Studio\Installer (use %ProgramFiles% in a 32-bit program prior to Windows 10). This is a fixed location that will be maintained.

This means we don't need to do a registry search to get the visual studio installer path. We can safely assume the installer will always be located at %ProgramFiles(x86)%\Microsoft Visual Studio\Installer.

vswhere provides us the ability to get the unique visual studio registry key. As such, we can use use a more conventional approach to adding Visual Studio support with github desktop.

I started working on a second implementation here: #14664 , let me know if you would I prefer to focus on the new PR instead of this one.

The only downside about the new PR is that I have to make use of execFileSync to call vswhere. The problem with execFileSync(vswhere) is that when we call vswhere, it creates a new process and won't return until the new process exits. If the new process hangs, execFileSync won't return and will make github desktop hang. If we decide to go with the new PR, I'll need to figure out how to more safely use execFileSync so it doesn't hang github desktop.

@Nico-Connor-Personal

Copy link
Copy Markdown
Author

I think the second implementation will be preferred: #14664

@AraHaan

AraHaan commented May 23, 2022 •

Copy link
Copy Markdown

The only downside about the new PR is that I have to make use of execFileSync to call vswhere. The problem with execFileSync(vswhere) is that when we call vswhere, it creates a new process and won't return until the new process exits. If the new process hangs, execFileSync won't return and will make github desktop hang. If we decide to go with the new PR, I'll need to figure out how to more safely use execFileSync so it doesn't hang github desktop.

In the .NET World we would offload that into an task then use Task.Run for an fire-and-forget call that will not hang.

If all else fails, one can make an .NET 6 wrapper program (would require the .NET 6 runtime to be installed) to execute the program in a much safer way (also System.Diagnostics.Process is a good friend there).

Also a good thing about .NET is that it would also require the .NET SDK be installed so one can use dotnet run <dll path of the program to run> to run it however it should not be much of an issue I think (.NET 6 also is in the registry too I believe, however can be probed for in Program Files(x86), Program Files, and w/e Program Files is for arm64 as well).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Visual Studio Community Integration Needed

2 participants