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

Windows MSVC: automate installing Visual Studio components #2947

Closed
ChrisDenton opened this issue Feb 10, 2022 · 10 comments
Closed

Windows MSVC: automate installing Visual Studio components #2947

ChrisDenton opened this issue Feb 10, 2022 · 10 comments

Comments

@ChrisDenton
Copy link
Member

ChrisDenton commented Feb 10, 2022

Problem you are trying to solve

Using Rust for msvc toolchains requires some components from Visual Studio to be installed: However, this requires the user to download the vs installer and select the correct components. This can be a source of friction for new users.

A good, regularly updated, install guide would help but it'd be great if rustup itself could ease the install process.

Solution you'd like

I would suggest this workflow:

  • If Visual Studio is not installed at all then offer to download and install the Community Edition with the required components.
  • If Visual Studio is installed but is missing the required components, offer to install what is needed.

Alternatively rustup could just do the second bullet point. The user would have to manually install Visual Studio but rustup would be able to fix anything missed by the user. In any case, this might be a good first step if this feature request is accepted.

Notes

Rustup already has logic to prompt the user to install Visual Studio if necessary.

The Visual Studio installer can be downloaded by using winget (if installed) or via https://aka.ms/vs/17/release/vs_community.exe.

The install can be automated using command line arguments. It can be run either with a GUI (where rustup can set the components to be installed by default) or in "quiet" mode without a GUI or user interaction. In the latter case, the license terms would need to be linked by rustup itself.

If Visual Studio is installed but components are missing then vswhere can be used to find the existing installer, which in turn can be used to install missing components. Fortunately Visual Studio installs vswhere to a stable location so this should be easy to find. Alternatively there is a COM interface that can be used to query Visual Studio directly. This is what cc-rs uses internally so perhaps features could be added to that crate to support this use case.

@ChrisDenton ChrisDenton changed the title Windows MSVC: Paritally automate installing Visual Studio components Windows MSVC: automate installing Visual Studio components Feb 10, 2022
@kinnison kinnison added help wanted O-windows Windows related labels Feb 13, 2022
@kinnison
Copy link
Contributor

This sounds like a very clever way to deal with this. If you think you can drive this functionality forward then it would be nice to have; though I don't know how easily we'd be able to CI this.

@ChrisDenton
Copy link
Member Author

A simple improvement to start with might be to update the instructions to tell the user how to run the Visual Studio Installer from the command line with the C++ workload pre-selected. For example:

Using winget:

winget install --id Microsoft.VisualStudio.2022.Community --override "--add Microsoft.VisualStudio.Workload.NativeDesktop;includeRecommended --focusedUi --wait"

If winget is not available then powershell can be used:

Invoke-WebRequest https://aka.ms/vs/17/release/vs_community.exe -OutFile "$env:TEMP\vs_community.exe"
&"$env:TEMP\vs_community.exe" install --add "Microsoft.VisualStudio.Workload.NativeDesktop;includeRecommended" --focusedUi
rm "$env:TEMP\vs_community.exe"

The availability of winget could be probed by rustup by attempting to run winget --version.

@kinnison
Copy link
Contributor

Certainly sounds like an approach - kinda hard to test for me, but perhaps someone with experience spooling up windows VMs will be able to give this a go. I'll be around here and on Discord if someone wishes to tackle this.

@ChrisDenton
Copy link
Member Author

ChrisDenton commented Jun 13, 2022

Ok, so based on feedback to #2954 the following issues were identified:

@dalance
Copy link

dalance commented Jul 12, 2022

I tried windows installation of rustup v1.25.0.
I expected BuildTools will be installed, but actually Visual Studio was installed.

How about usage of BuildTools installer?
I created #3030.

@ChrisDenton
Copy link
Member Author

The problem is the licensing. See #2867

@dalance
Copy link

dalance commented Jul 12, 2022

I understand it. Thanks.

@kinnison
Copy link
Contributor

@ChrisDenton Do you believe this can now be closed?

@ChrisDenton
Copy link
Member Author

Yep! If there are any problems it would make sense to track them as new issues.

@Menelion
Copy link

Menelion commented Sep 5, 2022

Sorry but I'm still proposed to install MSVC however I have MSVS 2022 Community. I tried all the possible versions of MSVC and Windows 10 SDK and still no dice, I'm presented with this infamous window. Any ideas please?
image

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

No branches or pull requests

4 participants