Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

launch Visual Studio Installer to install the C++ tools #1462

Closed
ctaggart opened this issue Jul 15, 2018 · 7 comments
Closed

launch Visual Studio Installer to install the C++ tools #1462

ctaggart opened this issue Jul 15, 2018 · 7 comments
Labels
O-windows Windows related

Comments

@ctaggart
Copy link

rust-init.exe does a good job at detecting for missing C++ tools. It would be even better if it detected an existing Visual Studio installation to prompt with something like: Would you like to launch Visual Studio Installer to install the C++ tools? and then do so.

The scenario is that I have Visual Studio 2017 installed and I want to install Rust. Currently you get this prompt #1114 (comment) . It would be amazing if rust-init.exe launched the Visual Studio Installer to install the missing dependencies. Here is a PowerShell script that I ran as admin to get them installed:

# start the Visual Studio Installer to install Rust dependencies
# current component names are:
#   VC++ 2017 version 15.7 v14.14 latest v141 tools
#   Windows 10 SDK (10.0.17134.0)

# get the latest Visual Studio installation path
$installationPath = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath

# launch the installer (must be admin)
& "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vs_installershell.exe" modify `
    --installPath $installationPath `
    --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 `
    --add Microsoft.VisualStudio.Component.Windows10SDK

I took notes in ctaggart#1 while making this.

@Diggsey
Copy link
Contributor

Diggsey commented Jul 28, 2018

I would be happy to accept a PR for this, although we'd need a fallback for detecting visual studio: I have VS2017 installed and vswhere is not present.

@ctaggart
Copy link
Author

To include the preview Visual Studio version, you must add -prerelease to the first command. This just worked for me on a computer with only Visual Studio Community 2019 Preview.

$installationPath = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath -prerelease
& "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vs_installershell.exe" modify `
    --installPath $installationPath `
    --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 `
    --add Microsoft.VisualStudio.Component.Windows10SDK

@ctaggart
Copy link
Author

An alternative to this is to add a .vsconfig file (based on the Terminal .vsconfig) to your project and open Visual Studio there.

{
  "version": "1.0",
  "components": [
    "Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
    "Microsoft.VisualStudio.Component.Windows10SDK"
  ]
}

@kinnison
Copy link
Contributor

Is there a safe and consistent way we can launch this from rustup-init.exe ?

@workingjubilee
Copy link
Member

@rustbot label: +O-windows

@rustbot rustbot added the O-windows Windows related label Apr 29, 2021
@cataggar
Copy link

It turns out that the Microsoft.VisualStudio.Component.Windows10SDK component is actually the "Windows Universal C Runtime`. You can see that at:
https://docs.microsoft.com/visualstudio/install/workload-component-id-vs-community

I exported my current config and I do not have the component installed. I think the required components are now:

{
  "version": "1.0",
  "components": [
    "Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
    "Microsoft.VisualStudio.Component.VC.Redist.14.Latest",
  ]
}

If I save this to a visual-cpp-build-tools.vsconfig, I can open Visual Studio Installer and import configuration to install any missing components:

image

You can see it select those two Individual components, and I already have them installed:

image

It would be great if someone could add a screenshot without them installed yet.

@rami3l
Copy link
Member

rami3l commented Jun 10, 2024

Fixed by #2954.

@rami3l rami3l closed this as completed Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-windows Windows related
Projects
None yet
Development

No branches or pull requests

7 participants