Fixes dotnet if dotnet tool is not available (#229)
* Fixes dotnet if dotnet tool si not available * dotnet: multi-lang support * Fixes dotnet for non-english terminals
This commit is contained in:
@@ -488,31 +488,34 @@ pub fn run_composer_update(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
pub fn run_dotnet_upgrade(ctx: &ExecutionContext) -> Result<()> {
|
pub fn run_dotnet_upgrade(ctx: &ExecutionContext) -> Result<()> {
|
||||||
let dotnet = utils::require("dotnet")?;
|
let dotnet = utils::require("dotnet")?;
|
||||||
|
|
||||||
let output = Command::new(dotnet)
|
let dotnet_help_output = ctx.run_type().execute(&dotnet).arg("-h").output().err().unwrap();
|
||||||
.args(["tool", "list", "--global"])
|
|
||||||
.output_checked_utf8()?;
|
|
||||||
|
|
||||||
if !output.stdout.starts_with("Package Id") {
|
if dotnet_help_output.to_string().contains("tool") {
|
||||||
return Err(SkipStep(String::from("dotnet did not output packages")).into());
|
let output = Command::new(dotnet)
|
||||||
|
.args(["tool", "list", "--global"])
|
||||||
|
.output_checked_utf8()?;
|
||||||
|
|
||||||
|
if !output.stdout.starts_with("Package Id") {
|
||||||
|
return Err(SkipStep(String::from("dotnet did not output packages")).into());
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut packages = output.stdout.lines().skip(2).filter(|line| !line.is_empty()).peekable();
|
||||||
|
|
||||||
|
if packages.peek().is_none() {
|
||||||
|
return Err(SkipStep(String::from("No dotnet global tools installed")).into());
|
||||||
|
}
|
||||||
|
|
||||||
|
print_separator(".NET");
|
||||||
|
|
||||||
|
for package in packages {
|
||||||
|
let package_name = package.split_whitespace().next().unwrap();
|
||||||
|
ctx.run_type()
|
||||||
|
.execute("dotnet")
|
||||||
|
.args(["tool", "update", package_name, "--global"])
|
||||||
|
.status_checked()
|
||||||
|
.with_context(|| format!("Failed to update .NET package {package_name}"))?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut packages = output.stdout.lines().skip(2).filter(|line| !line.is_empty()).peekable();
|
|
||||||
|
|
||||||
if packages.peek().is_none() {
|
|
||||||
return Err(SkipStep(String::from("No dotnet global tools installed")).into());
|
|
||||||
}
|
|
||||||
|
|
||||||
print_separator(".NET");
|
|
||||||
|
|
||||||
for package in packages {
|
|
||||||
let package_name = package.split_whitespace().next().unwrap();
|
|
||||||
ctx.run_type()
|
|
||||||
.execute("dotnet")
|
|
||||||
.args(["tool", "update", package_name, "--global"])
|
|
||||||
.status_checked()
|
|
||||||
.with_context(|| format!("Failed to update .NET package {package_name}"))?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user