Skip to content

Instantly share code, notes, and snippets.

Created April 11, 2020 01:30
What would you like to do?
Find `msbuild` using `vswhere`
use std::path::PathBuf;
use std::process::Command;
use std::str;
let mut msbuild = PathBuf::from("msbuild");
let check_msbuild = Command::new(msbuild)
if !check_msbuild {
let vswhere = {
let mut path = PathBuf::from(std::env::var("ProgramFiles(x86)").expect("failed to find `vswhere`"));
path.push("Microsoft Visual Studio");
let msbuild_paths = Command::new(vswhere)
] as &[_])
.expect("failed to run vswhere");
let found_msbuild_path = str::from_utf8(&msbuild_paths.stdout)
.expect("invalid vswhere output")
.expect("no vswhere output");
msbuild = PathBuf::from(found_msbuild_path);
} else {
panic!("on the path!");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment