Skip to content

Added support for Visual Studio Community, Professional, Enterprise - 2017 (v15.2^), 2019, 2022 on Windows 64-bit - #14664

Closed
Nico-Connor-Personal wants to merge 4 commits into
desktop:developmentfrom
Nico-Connor-Personal:nconnor/visual-studio-method#2
Closed

Nico-Connor-Personal wants to merge 4 commits into
desktop:developmentfrom
Nico-Connor-Personal:nconnor/visual-studio-method#2

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 unique registry of their IDE.

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 Windows 64 bit installations of:

  • 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 explore what the root path of Visual Studio is on 32 bit computers.

It would be nice to have someone test this code with any version of visual studio 2017 15.2 and up and have someone test this with any supported version of visual studio enterprise.

A different implementation approach that I tried:

@Nico-Connor-Personal Nico-Connor-Personal changed the title Added Win 64 bit support for Visual Studio Community, Professional, Enterprise 2017 (v15.2^), 2019, 2022 WIP Added Win 64 bit support for Visual Studio Community, Professional, Enterprise 2017 (v15.2^), 2019, 2022 May 23, 2022
@Nico-Connor-Personal Nico-Connor-Personal changed the title WIP Added Win 64 bit support for Visual Studio Community, Professional, Enterprise 2017 (v15.2^), 2019, 2022 WIP Added support for Visual Studio Community, Professional, Enterprise 2017 (v15.2^), 2019, 2022 for win 64 May 23, 2022
@Nico-Connor-Personal Nico-Connor-Personal changed the title WIP Added support for Visual Studio Community, Professional, Enterprise 2017 (v15.2^), 2019, 2022 for win 64 Added support for Visual Studio Community, Professional, Enterprise 2017 (v15.2^), 2019, 2022 for Windows 64 bit May 23, 2022
@Nico-Connor-Personal Nico-Connor-Personal changed the title Added support for Visual Studio Community, Professional, Enterprise 2017 (v15.2^), 2019, 2022 for Windows 64 bit Added support for Visual Studio Community, Professional, Enterprise 2017 (v15.2^), 2019, 2022 for Windows 64-bit May 23, 2022
@Nico-Connor-Personal
Nico-Connor-Personal marked this pull request as ready for review May 23, 2022 06:59
@Nico-Connor-Personal Nico-Connor-Personal changed the title Added support for Visual Studio Community, Professional, Enterprise 2017 (v15.2^), 2019, 2022 for Windows 64-bit Added support for Visual Studio Community, Professional, Enterprise 2017 (v15.2^), 2019, 2022 on Windows 64-bit May 23, 2022
@Nico-Connor-Personal Nico-Connor-Personal changed the title Added support for Visual Studio Community, Professional, Enterprise 2017 (v15.2^), 2019, 2022 on Windows 64-bit Added support for Visual Studio Community, Professional, Enterprise - 2017 (v15.2^), 2019, 2022 on Windows 64-bit May 23, 2022
@tsvetilian-ty

tsvetilian-ty commented May 23, 2022 •

Copy link
Copy Markdown
Member

@Nico-Connor nice to see someone tackling the unstable keys of Visual Studio 🥳 I tested the branch, and it works like a charm 🎉

I have a few suggestions on how to improve the PR:

if(process.env['ProgramFiles(x86)']){
vswherePath = Path.join(process.env['ProgramFiles(x86)'], 'Microsoft Visual Studio', 'Installer', 'vswhere.exe');
}
if(vswherePath !== undefined && existsSync(vswherePath)){

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use pathExists instead of existsSync.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also on x86 I believe Program Files (x86) does not exist as it is named Program Files if I remember from my 32 bit windows days.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AraHaan that shouldn't be a problem since we only offer 64bit builds, right?

}
if(vswherePath !== undefined && existsSync(vswherePath)){
try {
const vswhereStdOut = execFileSync(vswherePath, ['-version', '['+String(version)+','+String(version+1)+')', '-products', productId, '-property', 'instanceId'],{timeout: 2000, killSignal: 'SIGKILL'});

@tsvetilian-ty tsvetilian-ty May 23, 2022 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Instead of execFileSync you can utilize execFile from ../exec-file (it returns a Promise). It will make it consistent with other usages across GitHub Desktop
  • Perhaps you can use template literal for ['+String(version)+','+String(version+1)+')
  • I'm not sure that's a problem, but the format of ['+String(version)+','+String(version+1)+') look a bit odd... it opens with square brackets, and it ends with closing parenthesis?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sergiou87

Copy link
Copy Markdown
Member

Hey @Nico-Connor 👋

Thank you very much for your contribution ❤️ However, there is a major issue with it, related to how Desktop creates that list of editors. Right now, that list of editors is built when the app starts, which is kind of ok as long as that happens very quick. However, your PR requires running external processes to determine the location/existence of Visual Studio installations, which will definitely slow down the app start.

We've been discussing about it and we think it's time to refactor all this code so that Desktop does all this work asynchronously and on-demand when the app needs it (i.e. when the user wants to open the repo on their selected editor, or when the user opens Settings -> Integrations to select a new one). I'll file a new issue with that. And we could also take that chance to make it a bit more flexible, instead of depending exclusively on the registry. For example, we could use vswhere directly to get the location of the VS executable, instead of using it to build the registry keys…

Because of all of this, I'm afraid we cannot merge your PR without having that refactor first, sorry 😞

@Nico-Connor-Personal

Copy link
Copy Markdown
Author

That is very sensible reasoning! I look forward to the completion of the refactoring. Would you be able to link the new issue when it's up? I wouldn't mind following the progress of the new issue 😉.

@sergiou87

Copy link
Copy Markdown
Member

Here it is: #14666

Thank you for being so understanding 🙇‍♂️ ❤️

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

4 participants