/** * 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"] }, ]); });