Skip to content

Commit cdab890

Browse files
committed
Try to fix github ci
1 parent 519af48 commit cdab890

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

tests/environment_info.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,21 @@ use netcorehost::{
22
hostfxr::{EnvironmentInfo, FrameworkInfo, SdkInfo},
33
nethost,
44
};
5-
use std::{collections::HashMap, path::PathBuf, process::Command};
5+
use std::{collections::HashMap, path::{Path, PathBuf}, process::Command, str::FromStr};
66

77
#[path = "common.rs"]
88
mod common;
99

1010
#[test]
1111
#[cfg(feature = "net6_0")]
1212
fn get_dotnet_environment_info() {
13-
let hostfxr = nethost::load_hostfxr().unwrap();
13+
use netcorehost::pdcstring::PdCString;
14+
15+
let hostfxr = if let Some(dotnet_root) = option_env!("DOTNET_ROOT") {
16+
nethost::load_hostfxr_with_dotnet_root(PdCString::from_str(dotnet_root).unwrap())
17+
} else {
18+
nethost::load_hostfxr()
19+
}.unwrap();
1420

1521
let actual_env = hostfxr.get_dotnet_environment_info().unwrap();
1622
let expected_env = get_expected_environment_info();
@@ -21,7 +27,10 @@ fn get_dotnet_environment_info() {
2127
}
2228

2329
fn get_expected_environment_info() -> EnvironmentInfo {
24-
let output = Command::new("dotnet").arg("--info").output().unwrap();
30+
let dotnet_path = option_env!("DOTNET_ROOT")
31+
.map(|root| Path::new(root).join("dotnet"))
32+
.unwrap_or_else(|| PathBuf::from_str("dotnet").unwrap());
33+
let output = Command::new(dotnet_path).arg("--info").output().unwrap();
2534
assert!(output.status.success());
2635
let output = String::from_utf8_lossy(&output.stdout);
2736

0 commit comments

Comments
 (0)