Skip to content

Commit 9b7c7c2

Browse files
committed
- update Visual Studio Installer dowload via winget
- remove the extra check if Visual Studio Installer is installed (the download is only 4mb and it will try update the the VS Installer.) - update manual download link and infos
1 parent 734de17 commit 9b7c7c2

File tree

1 file changed

+27
-45
lines changed

1 file changed

+27
-45
lines changed

src/cli/self_update/windows.rs

Lines changed: 27 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ use super::{InstallOpts, install_bins, report_error};
2222
use crate::cli::markdown::md;
2323
use crate::config::Cfg;
2424
use crate::dist::TargetTriple;
25-
use crate::dist::download::DownloadCfg;
26-
use crate::download::download_file;
2725
use crate::process::{ColorableTerminal, Process};
2826
use crate::utils;
2927

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

147145
static MSVC_MANUAL_INSTALL_MESSAGE: &str = r#"
148-
You can acquire the build tools by installing Microsoft Visual Studio.
146+
You can acquire the build tools by installing the Build Tools for Microsoft Visual Studio:
149147
150-
https://visualstudio.microsoft.com/downloads/
148+
https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2026
151149
152-
Check the box for "Desktop development with C++" which will ensure that the
153-
needed components are installed. If your locale language is not English,
154-
then additionally check the box for English under Language packs.
150+
You will need the following components to be installed:
151+
MSVC Build Tools for x64/x86 (Latest)
152+
Windows 11 SDK (10.0.26100.XXXX)
153+
Language pack: English
155154
156155
For more details see:
157156
@@ -199,9 +198,8 @@ pub(crate) fn do_msvc_check(opts: &InstallOpts<'_>, process: &Process) -> Option
199198
// If the user does not have Visual Studio installed and their host
200199
// machine is i686 or x86_64 then it's OK to try an auto install.
201200
// Otherwise a manual install will be required.
202-
let has_any_vs = windows_registry::find_vs_version().is_ok();
203201
let is_x86 = host_triple.contains("i686") || host_triple.contains("x86_64");
204-
if is_x86 && !has_any_vs {
202+
if is_x86 {
205203
Some(VsInstallPlan::Automatic)
206204
} else {
207205
Some(VsInstallPlan::Manual)
@@ -262,47 +260,31 @@ pub(crate) async fn try_install_msvc(
262260
opts: &InstallOpts<'_>,
263261
cfg: &Cfg<'_>,
264262
) -> Result<ContinueInstall> {
265-
// download the installer
266-
let visual_studio_url = utils::parse_url("https://aka.ms/vs/17/release/vs_community.exe")?;
267-
268-
let tempdir = tempfile::Builder::new()
269-
.prefix("rustup-visualstudio")
270-
.tempdir()
271-
.context("error creating temp directory")?;
272-
273-
let visual_studio = tempdir.path().join("vs_setup.exe");
274-
let dl_cfg = DownloadCfg::new(cfg);
275-
info!("downloading Visual Studio installer");
276-
download_file(
277-
&visual_studio_url,
278-
&visual_studio,
279-
None,
280-
None,
281-
dl_cfg.process,
282-
)
283-
.await?;
284263

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

267+
let mut vsi_args = String::from("--focusedUi --addProductLang En-us --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64");
296268
// It's possible an earlier or later version of the Windows SDK has been
297269
// installed separately from Visual Studio so installing it can be skipped.
298270
if !has_windows_sdk_libs(cfg.process) {
299-
cmd.args([
300-
"--add",
301-
"Microsoft.VisualStudio.Component.Windows11SDK.26100",
302-
]);
271+
vsi_args.push_str(" --add Microsoft.VisualStudio.Component.Windows11SDK.26100");
303272
}
304-
info!("running the Visual Studio install");
305-
info!("rustup will continue once Visual Studio installation is complete\n");
273+
274+
// Run the installer. Arguments are documented at:
275+
// https://docs.microsoft.com/en-us/visualstudio/install/use-command-line-parameters-to-install-visual-studio
276+
let mut cmd = Command::new("winget");
277+
cmd.arg("install")
278+
.args(["--id", "Microsoft.VisualStudio.BuildTools"])
279+
// Simple force update the Installer
280+
.arg("--force")
281+
// Overide winget silent mode
282+
.arg("--interactive")
283+
// Add custom arguments to the installer
284+
.arg("--custom")
285+
// Has all to be an argument value of --custom
286+
.arg(vsi_args);
287+
306288
let exit_status = cmd
307289
.spawn()
308290
.and_then(|mut child| child.wait())

0 commit comments

Comments
 (0)