дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-05 17:47:08 +02:00
fix(build): build the run configuration's .NET project, not the folder's first (#8223)
The toolbar hammer and the Build .NET project before-launch task pass the configuration's project file to Build Module, but the .NET build was planned from its folder and took the first solution or project by name. dotnet_steps now builds a given solution or project file in the module folder as is; other files still build the folder's solution or project. Fixes #8179
Цей коміт міститься в:
1 джерело
f160d60a7a
коміт
b228d31ff9
1 file changed
+48
-4
@@ -294,7 +294,7 @@ pub fn plan(
|
||||
}
|
||||
BuildSystem::TypeScript => ts_steps(&dir, kind),
|
||||
BuildSystem::CMake => cmake_steps(&dir, kind, cmake.and_then(<[_]>::first)),
|
||||
BuildSystem::Dotnet => dotnet_steps(&dir, kind)?,
|
||||
BuildSystem::Dotnet => dotnet_steps(&dir, kind, file)?,
|
||||
// Never detected from a folder: it comes from the Project Structure (`structure_plan`).
|
||||
BuildSystem::Javac => return Err(IdeError::invalid("no build tool to run")),
|
||||
}
|
||||
@@ -553,10 +553,24 @@ fn dotnet_target(dir: &Path) -> Option<PathBuf> {
|
||||
solution.or_else(|| files.iter().find(|p| matches!(ext(p).as_str(), "csproj" | "fsproj" | "vbproj"))).cloned()
|
||||
}
|
||||
|
||||
/// `dotnet build` of the directory's solution or project; Rebuild skips incremental builds,
|
||||
/// `dotnet build` of `file` when it is a solution or project in `dir` (a run configuration's
|
||||
/// project), else of the directory's solution or project; Rebuild skips incremental builds,
|
||||
/// Build Artifacts publishes. The summary that repeats every message is left out.
|
||||
fn dotnet_steps(dir: &Path, kind: BuildKind) -> IdeResult<Vec<BuildStep>> {
|
||||
let target = dotnet_target(dir).ok_or_else(|| IdeError::not_found("no .NET solution or project found"))?;
|
||||
fn dotnet_steps(dir: &Path, kind: BuildKind, file: Option<&Path>) -> IdeResult<Vec<BuildStep>> {
|
||||
let given = file.filter(|f| {
|
||||
f.parent() == Some(dir)
|
||||
&& f.is_file()
|
||||
&& f.extension().is_some_and(|e| {
|
||||
matches!(
|
||||
e.to_string_lossy().to_ascii_lowercase().as_str(),
|
||||
"sln" | "slnx" | "csproj" | "fsproj" | "vbproj"
|
||||
)
|
||||
})
|
||||
});
|
||||
let target = given
|
||||
.map(Path::to_path_buf)
|
||||
.or_else(|| dotnet_target(dir))
|
||||
.ok_or_else(|| IdeError::not_found("no .NET solution or project found"))?;
|
||||
let target = target.file_name().map_or_else(String::new, |n| n.to_string_lossy().into_owned());
|
||||
let verb = if kind == BuildKind::Artifacts { "publish" } else { "build" };
|
||||
let mut step = BuildStep::new("dotnet", &[verb, &target, "-nologo", "-clp:NoSummary"], dir, Format::Msbuild);
|
||||
@@ -1734,6 +1748,36 @@ mod tests {
|
||||
let p = plan(&net, &BuildModel::default(), BuildKind::Artifacts, None, None, None, &CancellationToken::new())
|
||||
.unwrap();
|
||||
assert_eq!(p.steps[0].args[0], "publish");
|
||||
// A run configuration's project is built even when its folder holds other projects or a
|
||||
// solution that sort first (#8179).
|
||||
write(&net, "src/Host/Legacy.csproj", "<Project/>");
|
||||
write(&net, "src/Host/Main.csproj", "<Project/>");
|
||||
write(&net, "src/Host/All.sln", "");
|
||||
for name in ["Main.csproj", "All.sln", "Legacy.csproj"] {
|
||||
let file = net.join("src/Host").join(name);
|
||||
let p = plan(
|
||||
&net,
|
||||
&BuildModel::default(),
|
||||
BuildKind::Build,
|
||||
Some(&file),
|
||||
None,
|
||||
None,
|
||||
&CancellationToken::new(),
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(p.steps[0].args[1], name);
|
||||
}
|
||||
let p = plan(
|
||||
&net,
|
||||
&BuildModel::default(),
|
||||
BuildKind::Build,
|
||||
Some(&net.join("src/Host/Program.cs")),
|
||||
None,
|
||||
None,
|
||||
&CancellationToken::new(),
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(p.steps[0].args[1], "All.sln");
|
||||
|
||||
let cm = tmp.path().join("cm");
|
||||
write(&cm, "CMakeLists.txt", "project(app)");
|
||||
|
||||
Reference in new issue
Заблокувати користувача