Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ You can press F5 without creating `launch.json` first: WinApp contributes a defa
4. It launches your app via `winapp run` to give it package identity, using the manifest specified via `manifest` in `launch.json` or auto-detected by the CLI.
5. A child debug session attaches to the running process using the debugger you specified.

> **Point `input` at a project to get builds for free.** When `input` is a `.csproj`, `.sln`, or `.slnx`, `winapp run` restores and builds before launching, so your code changes are always reflected. When `input` is a build output folder, WinApp **does not** build; you must rebuild yourself (or use a `preLaunchTask`) after making code changes.
> **Point `input` at a project to get builds for free.** When `input` is a `.csproj`, `.vcxproj`, `.sln`, or `.slnx`, `winapp run` restores and builds before launching, so your code changes are always reflected. When `input` is a build output folder, WinApp **does not** build; you must rebuild yourself (or use a `preLaunchTask`) after making code changes.

> When `input` is a build output folder, you can automate the build step by adding a `preLaunchTask` to your `launch.json` configuration. This tells VS Code to run a build task before every debug session, so your changes are always compiled before launch. Apps without a project file, such as Electron, Rust, and C++ apps, always run this way, so a `preLaunchTask` is the way to keep their builds current.
> When `input` is a build output folder, you can automate the build step by adding a `preLaunchTask` to your `launch.json` configuration. This tells VS Code to run a build task before every debug session, so your changes are always compiled before launch. Apps without a project file, such as Electron, Rust, and CMake-based C++ apps, always run this way, so a `preLaunchTask` is the way to keep their builds current.
>
> 1. Define a build task in `.vscode/tasks.json`. Any build command works; this example uses .NET, but `npm run build`, `cargo build`, or an MSBuild invocation work the same way:
> ```jsonc
Expand Down Expand Up @@ -180,7 +180,7 @@ You can press F5 without creating `launch.json` first: WinApp contributes a defa

| Property | Type | Default | Description |
|----------|------|---------|-------------|
| `input` | string | | What to run: a project (`.csproj`), a solution (`.sln`/`.slnx`), a directory containing one, or a build output folder (e.g., `${workspaceFolder}/bin/Debug/net8.0-windows10.0.22621`). If not set, you will be prompted to select a target. |
| `input` | string | | What to run: a project (`.csproj` or C++ `.vcxproj`), a solution (`.sln`/`.slnx`), a directory containing one, or a build output folder (e.g., `${workspaceFolder}/bin/Debug/net8.0-windows10.0.22621`). If not set, you will be prompted to select a target. |
| `inputFolder` | string | | **Deprecated.** Use `input`, which also accepts projects and solutions. Still honored for existing configurations; if both are set, `input` wins. |
| `project` | string | | *Project mode only.* Selects which project to launch, by name or path, when `input` is a solution or a directory containing more than one runnable app project. |
| `configuration` | string | `Debug` | *Project mode only.* Build configuration to use. |
Expand Down
2 changes: 1 addition & 1 deletion cli-version.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"releaseTag": "v0.7.1"
"releaseTag": "v0.8.0"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@
"properties": {
"input": {
"type": "string",
"description": "What to run: a project file (.csproj), a solution (.sln/.slnx), a directory containing one, or a build output folder containing your app binaries (e.g., '${workspaceFolder}/bin/Debug/net8.0-windows10.0.22621'). If not set, you will be prompted to select a target."
"description": "What to run: a project file (.csproj or C++ .vcxproj), a solution (.sln/.slnx), a directory containing one, or a build output folder containing your app binaries (e.g., '${workspaceFolder}/bin/Debug/net8.0-windows10.0.22621'). If not set, you will be prompted to select a target."
},
"inputFolder": {
"type": "string",
Expand Down
2 changes: 1 addition & 1 deletion src/pack-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ async function pickPackProject(
if (candidates.length === 0) {
vscode.window.showWarningMessage(
unsupportedSolutionsFound
? 'Solutions were found, but none contained .NET projects supported by the bundled WinApp CLI. Browse to the project or solution you want to package.'
? 'Solutions were found, but none contained .NET projects. Browse to the .NET project or solution you want to package.'
: onlyUnrunnableProjects
? 'Only library and test projects were found. Browse to the application project or solution you want to package.'
: 'No projects or solutions were found. Browse to the project or solution you want to package.'
Expand Down
2 changes: 1 addition & 1 deletion src/run-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { extractJsonObject } from './winapp-cli-utils';

/** Shared `winapp run` option shape for palette and debug invocations. */
export interface WinAppRunOptions {
/** Positional `input`: a build-output folder, `.csproj`, `.sln`/`.slnx`, or a directory containing one. */
/** Positional `input`: a build-output folder, `.csproj`, `.vcxproj`, `.sln`/`.slnx`, or a directory containing one. */
input: string;

// --- Project mode only (silently ignored by the CLI in folder mode) ---
Expand Down
19 changes: 14 additions & 5 deletions src/run-target.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ import type { WorkspaceRoot } from './workspace';
/** The extension-only target classification is never passed to the CLI. */
export type RunTargetKind = 'project' | 'solution' | 'folder' | 'unknown';

/** Project file extensions the CLI can build in project mode. */
/** .NET project file extensions the extension discovers and the CLI builds in project mode. */
export const PROJECT_FILE_EXTENSIONS = ['.csproj'] as const;

/**
* C++ projects the CLI builds in project mode since winapp 0.8.0. Accepted when
* named explicitly but not yet discovered: runnability detection reads only .NET markers.
*/
export const NATIVE_PROJECT_FILE_EXTENSIONS = ['.vcxproj'] as const;

/**
* .NET file-based apps run in project mode but are deliberately excluded from
* discovery, from the Browse dialog's filters, and from the `--project` list:
Expand Down Expand Up @@ -59,6 +65,9 @@ export function classifyRunTargetFile(filePath: string): RunTargetKind | undefin
if ((PROJECT_FILE_EXTENSIONS as readonly string[]).includes(extension)) {
return 'project';
}
if ((NATIVE_PROJECT_FILE_EXTENSIONS as readonly string[]).includes(extension)) {
return 'project';
}
if ((FILE_BASED_APP_EXTENSIONS as readonly string[]).includes(extension)) {
return 'project';
}
Expand All @@ -75,7 +84,8 @@ export function classifyRunTargetEntries(entryNames: readonly string[]): RunTarg
if ((SOLUTION_FILE_EXTENSIONS as readonly string[]).includes(extension)) {
return 'solution';
}
if ((PROJECT_FILE_EXTENSIONS as readonly string[]).includes(extension)) {
if ((PROJECT_FILE_EXTENSIONS as readonly string[]).includes(extension)
|| (NATIVE_PROJECT_FILE_EXTENSIONS as readonly string[]).includes(extension)) {
hasProject = true;
} else if (extension === '.exe') {
hasExecutable = true;
Expand Down Expand Up @@ -354,9 +364,8 @@ export function dedupeSolutionMembers(
}

/**
* The bundled CLI accepts only .NET projects in solution mode. A native-only
* solution therefore cannot run as a solution, but its built output can still
* run in folder mode. Dropping it here keeps that fallback reachable.
* Discovery reads only .NET solution members, so a native-only solution has no
* project to prompt for. Dropping it keeps its built output reachable in folder mode.
*/
export function filterSolutionsWithoutMembers(
candidates: readonly RunTargetCandidate[],
Expand Down
2 changes: 1 addition & 1 deletion src/run-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ export async function pickRunTarget(
// unbidden — the user asked to run, not to browse.
vscode.window.showWarningMessage(
unsupportedSolutionsFound
? 'Solutions were found, but none contained .NET projects supported by the bundled WinApp CLI, and no build output folders were found. Build the app first, then browse to its output folder.'
? 'Solutions were found, but none contained .NET projects, and no build output folders were found. Build the app first, or browse to the solution to let WinApp build it.'
: onlyUnrunnableProjects
? 'Only library and test projects were found in this workspace, and winapp run needs an executable app project. Browse to the project or folder you want to run.'
: 'No projects, solutions, or build output folders were found in this workspace. Browse to the project or folder you want to run.'
Expand Down
2 changes: 1 addition & 1 deletion src/test/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ Covers run-target discovery for `winapp.run` / `winapp.runWithOptions`, which de
|---|------|-----------|
| 1 | hides class libraries and test projects | Non-runnable projects are filtered out rather than offered as targets the CLI would reject |
| 2 | falls back to build output when the only project is a library | With nothing runnable found, the build-output scan still supplies targets |
| 3 | explains why an unbuilt native-only solution is not offered | A `.sln` containing only unsupported `.vcxproj` members and no built output reports that the solution was found and tells the user to build before browsing, rather than claiming no solution exists |
| 3 | explains why an unbuilt native-only solution is not offered | A `.sln` containing only `.vcxproj` members, which discovery cannot list yet, and no built output reports that the solution was found and suggests building first or browsing to it, rather than claiming no solution exists |
| 4 | falls back to native build output when a solution has no supported members | A `.sln` containing only `.vcxproj` members does not hide runnable `.exe` output from the bundled CLI's folder mode |
| 5 | prefers the project over its own build output folder | A project and its `bin` output collapse to the project entry |
| 6 | finds output for a project-less app without surfacing node_modules | Electron/Rust-shaped workspaces reach the `.exe` scan, and excluded directories stay excluded |
Expand Down
4 changes: 2 additions & 2 deletions src/test/e2e/run-target-picker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,8 @@ test.describe('run target picker', () => {
}
});

// CLI v0.7.1 cannot build a .vcxproj through solution mode. Keeping the
// solution would auto-select an input that always fails and hide the
// Discovery cannot yet list a .vcxproj solution member. Keeping the
// solution would auto-select it with nothing to prompt for and hide the
// folder-mode path the released extension used for native apps.
test('falls back to native build output when a solution has no supported members', async () => {
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'run-target-native-e2e-'));
Expand Down
11 changes: 11 additions & 0 deletions src/test/run-target.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ describe('classifyRunTargetFile', () => {
assert.strictEqual(classifyRunTargetFile('C:/ws/App.CS'), 'project');
});

// winapp 0.8.0 builds C++ projects in project mode, so launch.json must accept them.
it('treats a C++ .vcxproj as project mode', () => {
assert.strictEqual(classifyRunTargetFile('C:/ws/App.vcxproj'), 'project');
assert.strictEqual(classifyRunTargetFile('C:/ws/App.VCXPROJ'), 'project');
});

it('is case-insensitive', () => {
assert.strictEqual(classifyRunTargetFile('C:/ws/MyApp.CSPROJ'), 'project');
assert.strictEqual(classifyRunTargetFile('C:/ws/MyApp.SLN'), 'solution');
Expand All @@ -70,6 +76,11 @@ describe('classifyRunTargetEntries', () => {
assert.strictEqual(classifyRunTargetEntries(['MyApp.csproj', 'MyApp.exe']), 'project');
});

it('treats a directory holding a C++ project as project mode', () => {
assert.strictEqual(classifyRunTargetEntries(['App.vcxproj', 'App.cpp']), 'project');
assert.strictEqual(classifyRunTargetEntries(['App.vcxproj', 'App.sln']), 'solution');
});

// The CLI reaches single-file mode only from an explicitly typed `.cs`
// path, never from directory inference, so `winapp run <dir>` here would
// run folder mode and fail with "Manifest file not found".
Expand Down
Loading