Файли
openidea/e2e/dotnetBuild.spec.ts
T
l0ng-ai 2b0cc6b733 fix(dotnet): build, clean and restore .NET projects in the Build window (#7922)
Build, Restore and Clean .NET Project ran dotnet as a background task of the .NET tool window, with no Build window output, no status bar progress and no notification; the output appeared only in the NuGet Packages window afterwards. They now run through a new build_dotnet_command host command on the shared .NET build runner, so output and errors stream into the Build window, Stop Build cancels, Rerun repeats, and a notification reports the result. The selected project is re-evaluated (and audited after a restore) only when the command succeeds.

Fixes #7853
2026-12-04 10:38:02 +08:00

68 рядки
2.6 KiB
TypeScript

/**
* Build a .NET solution from the Project view (#7853). The host is stubbed at the IPC layer (no
* `dotnet` runs; the `ide-build` test checks the command line): the spec checks that the build
* streams into the Build window and ends with a notification, as Build Project does.
*/
import { expect, ipcCalls, stubDesktop, test } from "./fixtures";
const SHOTS = process.env.E2E_SHOTS;
const FILE = "/dev/acme-api/App/Program.cs";
test("Build .NET Project on a solution runs in the Build window", async ({ workbench: page }) => {
await stubDesktop(page);
await page.evaluate(async (file) => {
window.__ipc.handlers.build_dotnet_command = (args) => {
const title = `dotnet ${args.command as string} Acme.sln`;
const messages = [
{
severity: "error",
text: "; expected",
path: file,
range: { start: { line: 0, col: 12 }, end: { line: 0, col: 12 } },
code: "CS1002",
},
];
window.__ipc.send(args.onEvent, { kind: "started", system: "dotnet", title });
window.__ipc.send(args.onEvent, {
kind: "step",
command: `dotnet ${args.command as string} Acme.sln -nologo -clp:NoSummary`,
cwd: "/dev/acme-api",
});
return { system: "dotnet", title, success: false, errors: 1, warnings: 0, durationMs: 1200, messages };
};
const storeModule = "/src/features/dotnet/store.ts";
const { useDotnet } = await import(/* @vite-ignore */ storeModule);
const project = "/dev/acme-api/App/App.csproj";
useDotnet.setState({
configuration: "Release",
model: {
projects: [
{
path: project,
name: "App",
frameworks: ["net9.0"],
configurations: ["Debug", "Release"],
references: [],
packages: [],
test: false,
runner: "vstest",
adapter: "mstest",
trx: false,
},
],
solutions: [{ path: "/dev/acme-api/Acme.sln", projects: [project] }],
},
});
}, FILE);
await page.getByRole("treeitem", { name: /Solution 'Acme'/ }).click({ button: "right" });
await page.getByRole("menuitem", { name: "Build .NET Project" }).click();
await expect(page.getByText("; expected").first()).toBeVisible();
await expect(page.getByText("Build failed: 1 error").first()).toBeVisible();
if (SHOTS) await page.screenshot({ path: `${SHOTS}/dotnet-build-window.png`, animations: "disabled" });
expect(await ipcCalls(page, "build_dotnet_command")).toMatchObject([
{ file: "/dev/acme-api/Acme.sln", command: "build", options: ["--configuration", "Release"] },
]);
});