Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 16 additions & 54 deletions doc/user-guide/src/installation/windows-msvc.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,70 +5,32 @@ For `msvc` targets these can be acquired through Visual Studio.

## Automatic install

If you don't have Visual Studio already installed then [rustup-init] will offer to automatically install the prerequisites.
Doing so means you can skip the rest of this page.
However, it installs Visual Studio Community edition which may not be appropriate for all users.
It is free for individuals, academic and open source use, but not for other uses, such as in proprietary enterprise software.
Users should ask their organisation which edition is right for them.
See [licensing terms][vs licences] for more details.
If you don't have Visual Studio already installed then the [rustup-init.exe][rustinstall] installer will offer to automatically install the prerequisites.

## Manual install

[Download Visual Studio][vs downloads].
Rust supports Visual Studio 2017 and later but it is recommended that you use the latest version (currently 2022) for new projects.
You can opt to download only the Build Tools for Visual Studio, which does not include the IDE.
However this requires you already have a license to the Community, Professional or Enterprise edition.
If you chose the automatic install this winget command will run in the background:
```Batchfile
winget install --id Microsoft.VisualStudio.BuildTools --force --interactive --custom "--focusedUi --addProductLang En-us --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Windows11SDK.26100"
Copy link
Member

Choose a reason for hiding this comment

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

Question regarding #4543: will the wrong --add params causing the whole command to fail?

The thing is that Microsoft, as it turned out, can remove any of those components from its server, meaning that these versions might no longer be valid a while later. However, if this is not a fatal error (meaning the GUI launches correctly and the user can tick the missing boxes manually) then this would be less of a problem.

Copy link
Member

Choose a reason for hiding this comment

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

It will appear to succeed but the component will be missing from the UI. There's nothing to indicate to the user that there is a missing component.

Image

Copy link
Author

@pino1536 pino1536 Jan 11, 2026

Choose a reason for hiding this comment

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

but this was also a problem before (the vs installer is the same) and it only affects Windows 11 sdk. the "Microsoft.VisualStudio.Component.VC.Tools.x86.x64" is always the lasted version.
The best way would be to simple update the "Windows 11 SDK" it in the tool periodical.

Copy link
Member

Choose a reason for hiding this comment

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

Yes this is a problem currently which is why we're looking into mitigations.

Copy link
Author

Choose a reason for hiding this comment

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

Yes this is a problem currently which is why we're looking into mitigations.

There are another 2 options:

  1. We could get the SDK via winget (its not a part of the Visual Studio licens):
winget install --id Microsoft.WindowsSDK.10.0.26100
  1. We could export a json file with all available components to parse the last version:
Microsoft Visual Studio\Installer\setup.exe export --productId Microsoft.VisualStudio.Product.BuildTools --channelId VisualStudio.18.Release --config "%UserProfile%\Desktop\temp.vsconfig" --all --quiet```

Copy link
Member

Choose a reason for hiding this comment

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

If we use winget then doing a search for the latest would be best (we can use the version field to filter it).

Using the json from the VS installer would be better in a sense because then we can be sure the it will show up labelled as installed when someone is attempting to debug issues. But I do worry that the json may not be stable between Visual Studio versions. That could be mitigated by ensuring we use a defined version.

```

Once you've downloaded and started the installer, the easiest way to get everything installed is to select "Desktop Development with C++".
This will include the necessary components.
On the "Language Packs" tab, make sure the English language pack is installed in addition to your preferred language.
But you could [download the Microsoft Build Tools for Visual Studio][vs download] Installer yourself and do the same steps manually.

If you want more details on the installation process or want to further customize the install then follow the walkthrough below.
Otherwise complete the Visual Studio install and continue with installing Rust.

## Walkthrough: Installing Visual Studio 2022
Copy link
Member

Choose a reason for hiding this comment

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

I do not think we should remove the GUI instructions, especially as it's the main user interface for the Visual Studio installer. If it's confusing we should improve that. If other installation methods are better then we should add those.

Copy link
Author

@pino1536 pino1536 Jan 11, 2026

Choose a reason for hiding this comment

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

But to be honest if someone cant use the installer and find the, in text form described, components he is on the level of my grandma using a computer 😬

I even would remove the license part... somehow there isn't even a way around other then to accept them.

And somehow I wanted to clarify that it would be better to use the new auto installer because unlike other examples it does the exact same (but guided) as you would do manual.

For me as a complete newcomer to rust (one week), the documentation only to get rustup ready, splatted over 3 documentations was a bit too much for these little requirements.

Copy link
Member

Choose a reason for hiding this comment

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

You don't need to read it all. We can add a command line section before the full GUI instructions. The reason it was added in the first place is because people do indeed struggle with it.


This walkthrough uses the Community edition of Visual Studio but the Professional, Enterprise and the Build Tools all work the same way.

The installer will start by linking to the [license][vs licences] and for your edition of Visual Studio and then preparing the installer.
The installer will start by linking to the [Build Tools license][vs licences] and will install the "Visual Studio Installer", a tool to manage Visual Studio components.

![Accept the license](images/step1.png)
![Installing the installer](images/step2.png)

Once this finishes, you can then select the components to be installed.
Here we use the "Workload" tab to select the "Desktop Development with C++" workload.
This will includes all needed components for Rust:
![Select the C++ Workload](images/step3.png)

### Installing only the required components (optional)

If you'd like a more minimal install (and won't be doing C++ development) then you can use the "Individual Components" tab to select just the essentials, which are:

* MSVC v143 - VS 2022 C++ x64/x86 build tools (Latest)
* Windows 11 SDK (10.0.22621.0)

Note that the specific version of the Windows SDK doesn't matter for pure Rust code but if using C++ as well you'll likely want either the latest or whichever version is required by the C++ project (or both).

![Select the latest MSVC component](images/component-msvc.png)
![Select the Windows 11 SDK component](images/component-sdk.png)

### Adding Language Packs (optional)

After choosing the components, you may also want to select the language packs to install.
Switch to the "Language Packs" tab and add the languages.
It is recommended that you add the English language pack in addition to your preferred language.
This will provide English language error messages, which may help when reporting errors.

![Add the English language](images/step4.png)

### Completing the install
Then you need to install the "Individual components":
* MSVC Build Tools for x64/x86 (Latest)
* Windows 11 SDK (10.0.26100.XXXX)

Finally click the install button and wait for everything to be installed.
And the "Language pack":
* English

![Wait for the install to complete](images/step5.png)

Once finished, you can continue on to installing Rust.
Once finished, you can continue on to installing Rust and the installer should detect MSVC.

[rustup-init]: https://rustup.rs
[vs downloads]: https://visualstudio.microsoft.com/downloads/
[vs licences]: https://visualstudio.microsoft.com/license-terms/
[vs licences]: https://visualstudio.microsoft.com/license-terms/vs2026-ga-diagnostic-buildtools
[vs download]: https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2026
[rustinstall]: https://rust-lang.org/tools/install/
75 changes: 29 additions & 46 deletions src/cli/self_update/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ use super::{InstallOpts, install_bins, report_error};
use crate::cli::markdown::md;
use crate::config::Cfg;
use crate::dist::TargetTriple;
use crate::dist::download::DownloadCfg;
use crate::download::download_file;
use crate::process::{ColorableTerminal, Process};
use crate::utils;

Expand Down Expand Up @@ -52,7 +50,7 @@ fn choice(max: u8, process: &Process) -> Result<Option<u8>> {
pub(crate) fn choose_vs_install(process: &Process) -> Result<Option<VsInstallPlan>> {
writeln!(
process.stdout().lock(),
"\n1) Quick install via the Visual Studio Community installer"
"\n1) Quick install via the Visual Studio Installer"
)?;
writeln!(
process.stdout().lock(),
Expand Down Expand Up @@ -145,13 +143,14 @@ later, but they don't seem to be installed.
"#;

static MSVC_MANUAL_INSTALL_MESSAGE: &str = r#"
You can acquire the build tools by installing Microsoft Visual Studio.
You can acquire the build tools by installing the Build Tools for Microsoft Visual Studio:

https://visualstudio.microsoft.com/downloads/
https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2026

Check the box for "Desktop development with C++" which will ensure that the
needed components are installed. If your locale language is not English,
then additionally check the box for English under Language packs.
You will need the following components to be installed:
MSVC Build Tools for x64/x86 (Latest)
Windows 11 SDK (10.0.26100.XXXX)
Language pack: English

For more details see:

Expand Down Expand Up @@ -199,9 +198,8 @@ pub(crate) fn do_msvc_check(opts: &InstallOpts<'_>, process: &Process) -> Option
// If the user does not have Visual Studio installed and their host
// machine is i686 or x86_64 then it's OK to try an auto install.
// Otherwise a manual install will be required.
let has_any_vs = windows_registry::find_vs_version().is_ok();
let is_x86 = host_triple.contains("i686") || host_triple.contains("x86_64");
if is_x86 && !has_any_vs {
if is_x86 {
Some(VsInstallPlan::Automatic)
} else {
Some(VsInstallPlan::Manual)
Expand Down Expand Up @@ -262,47 +260,32 @@ pub(crate) async fn try_install_msvc(
opts: &InstallOpts<'_>,
cfg: &Cfg<'_>,
) -> Result<ContinueInstall> {
// download the installer
let visual_studio_url = utils::parse_url("https://aka.ms/vs/17/release/vs_community.exe")?;

let tempdir = tempfile::Builder::new()
.prefix("rustup-visualstudio")
.tempdir()
.context("error creating temp directory")?;

let visual_studio = tempdir.path().join("vs_setup.exe");
let dl_cfg = DownloadCfg::new(cfg);
info!("downloading Visual Studio installer");
download_file(
&visual_studio_url,
&visual_studio,
None,
None,
dl_cfg.process,
)
.await?;

// Run the installer. Arguments are documented at:
// https://docs.microsoft.com/en-us/visualstudio/install/use-command-line-parameters-to-install-visual-studio
let mut cmd = Command::new(visual_studio);
cmd.arg("--wait")
// Display an interactive GUI focused on installing just the selected components.
.arg("--focusedUi")
// Add the English language pack
.args(["--addProductLang", "En-us"])
// Add the linker and C runtime libraries.
.args(["--add", "Microsoft.VisualStudio.Component.VC.Tools.x86.x64"]);
info!("running the Visual Studio Installer\n");
info!("Follow the Installation and Close the Window to continue with rustup!\n");

let mut vsi_args = String::from(
"--focusedUi --addProductLang En-us --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
);
// It's possible an earlier or later version of the Windows SDK has been
// installed separately from Visual Studio so installing it can be skipped.
if !has_windows_sdk_libs(cfg.process) {
cmd.args([
"--add",
"Microsoft.VisualStudio.Component.Windows11SDK.26100",
]);
vsi_args.push_str(" --add Microsoft.VisualStudio.Component.Windows11SDK.26100");
}
info!("running the Visual Studio install");
info!("rustup will continue once Visual Studio installation is complete\n");

// Run the installer. Arguments are documented at:
// https://docs.microsoft.com/en-us/visualstudio/install/use-command-line-parameters-to-install-visual-studio
let mut cmd = Command::new("winget");
Copy link
Member

Choose a reason for hiding this comment

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

Is winget a component that comes with all supported Windows installations? Please note that we are currently stating support for Windows 10/2026 or later.

If this is not the case, maybe we should notify the user and provide an installation hint?

Copy link
Author

@pino1536 pino1536 Jan 11, 2026

Choose a reason for hiding this comment

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

yes it comes with every Windows 10 and 11 pre installed. In many cases Microsoft uses it itself for many things. (you can see it because many auto installed stuff comes with the install source winget) and you can find everything official through winget.

Copy link
Member

Choose a reason for hiding this comment

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

Not with every SKU. E.g. Windows Sandbox does not have it installed by default. I'm not entirely against using winget here but I also don't think it get us anything useful. The aka.ms links always work.

cmd.arg("install")
.args(["--id", "Microsoft.VisualStudio.BuildTools"])
// Simple force update the Installer
.arg("--force")
// Overide winget silent mode
.arg("--interactive")
// Add custom arguments to the installer
.arg("--custom")
// Has all to be an argument value of --custom
.arg(vsi_args);

let exit_status = cmd
.spawn()
.and_then(|mut child| child.wait())
Expand Down