дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-05 17:47:08 +02:00
Run configuration detection and its .sln / .slnx reader only accepted .csproj, so F# and Visual Basic projects got no run configurations. .fsproj and .vbproj now follow the C# rules. Visual Basic keeps launch profiles in My Project/launchSettings.json, where dotnet run looks, so profiles and the gutter run icons in that file read it. The real dotnet CLI test is ignored by default (no SDK in CI). Closes #7631 Co-authored-by: wildcatDownstairs <[email protected]>
84 рядки
3.6 KiB
Rust
84 рядки
3.6 KiB
Rust
//! Runs the real `dotnet` CLI on F# and Visual Basic projects: the detected configurations
|
|
//! build, run with their launch profile and name the assembly the debugger launches.
|
|
//! Ignored by default (CI has no .NET SDK): `cargo test -p ide-run --test dotnet_cli -- --ignored`.
|
|
|
|
use ide_run::{
|
|
detect,
|
|
dotnet::{resolve, target_path},
|
|
};
|
|
use std::{fs, path::Path, process::Command};
|
|
|
|
fn dotnet(dir: &Path, args: &[&str]) -> String {
|
|
let out = Command::new("dotnet")
|
|
.args(args)
|
|
.current_dir(dir)
|
|
.envs([("DOTNET_CLI_UI_LANGUAGE", "en"), ("DOTNET_NOLOGO", "1"), ("DOTNET_CLI_TELEMETRY_OPTOUT", "1")])
|
|
.env("MSBUILDDISABLENODEREUSE", "1")
|
|
.output()
|
|
.unwrap();
|
|
let text = format!("{}{}", String::from_utf8_lossy(&out.stdout), String::from_utf8_lossy(&out.stderr));
|
|
assert!(out.status.success(), "dotnet {args:?}: {text}");
|
|
text
|
|
}
|
|
|
|
#[tokio::test]
|
|
#[ignore = "needs the .NET SDK"]
|
|
async fn fsharp_and_vb_configurations_build_run_and_resolve_their_assembly() {
|
|
if !Command::new("dotnet").arg("--version").output().is_ok_and(|o| o.status.success()) {
|
|
eprintln!("skipped: no dotnet SDK");
|
|
return;
|
|
}
|
|
let temp = tempfile::tempdir().unwrap();
|
|
let root = dunce::canonicalize(temp.path()).unwrap().join("sp ace é中");
|
|
fs::create_dir(&root).unwrap();
|
|
for (lang, name) in [("F#", "Fs App"), ("VB", "Vb App"), ("C#", "CsApp")] {
|
|
dotnet(&root, &["new", "console", "-lang", lang, "-o", name, "--no-restore"]);
|
|
}
|
|
for (lang, name) in [("F#", "FsLib"), ("VB", "VbLib")] {
|
|
dotnet(&root, &["new", "classlib", "-lang", lang, "-o", name, "--no-restore"]);
|
|
}
|
|
for (project, folder, source, code) in [
|
|
(
|
|
"Fs App/Fs App.fsproj",
|
|
"Properties",
|
|
"Fs App/Program.fs",
|
|
"printfn \"demo=%s\" (System.Environment.GetEnvironmentVariable \"DEMO\")\n",
|
|
),
|
|
(
|
|
"Vb App/Vb App.vbproj",
|
|
"My Project",
|
|
"Vb App/Program.vb",
|
|
"Module Program\n Sub Main()\n System.Console.WriteLine(\"demo=\" & System.Environment.GetEnvironmentVariable(\"DEMO\"))\n End Sub\nEnd Module\n",
|
|
),
|
|
] {
|
|
fs::write(root.join(source), code).unwrap();
|
|
let dir = root.join(project).parent().unwrap().join(folder);
|
|
fs::create_dir_all(&dir).unwrap();
|
|
fs::write(
|
|
dir.join("launchSettings.json"),
|
|
r#"{"profiles":{"demo":{"commandName":"Project","environmentVariables":{"DEMO":"profile"}}}}"#,
|
|
)
|
|
.unwrap();
|
|
}
|
|
|
|
let configs = detect(&root);
|
|
let mut projects: Vec<_> = configs.iter().map(|c| c.extras.params["project"].as_str()).collect();
|
|
projects.sort_unstable();
|
|
projects.dedup();
|
|
assert_eq!(projects, ["CsApp/CsApp.csproj", "Fs App/Fs App.fsproj", "Vb App/Vb App.vbproj"]);
|
|
|
|
for (project, assembly) in [("Fs App/Fs App.fsproj", "Fs App.dll"), ("Vb App/Vb App.vbproj", "Vb App.dll")] {
|
|
let config = configs
|
|
.iter()
|
|
.find(|c| c.extras.params["project"] == project && c.extras.params["launchProfile"] == "demo")
|
|
.unwrap_or_else(|| panic!("no profile configuration for {project}"));
|
|
let args: Vec<&str> = config.args.iter().map(String::as_str).collect();
|
|
let output = dotnet(&root, &args);
|
|
assert!(output.contains("demo=profile"), "{project}: {output}");
|
|
let resolved = resolve(&root, config.clone()).unwrap();
|
|
assert_eq!(resolved.env["DEMO"], "profile");
|
|
let target = target_path(&root, &resolved).await.unwrap();
|
|
assert!(target.ends_with(assembly), "{target}");
|
|
}
|
|
}
|