diff --git a/src/features/status.ts b/src/features/status.ts index 718a31dc22..6f072b9908 100644 --- a/src/features/status.ts +++ b/src/features/status.ts @@ -26,7 +26,8 @@ let defaultSelector: vscode.DocumentSelector = [ 'csharp', // c#-files OR { pattern: '**/project.json' }, // project.json-files OR { pattern: '**/*.sln' }, // any solution file OR - { pattern: '**/*.csproj' } // an csproj file + { pattern: '**/*.csproj' }, // an csproj file + { pattern: '**/*.csx' } // C# script ]; class Status { diff --git a/src/omnisharp/launcher.ts b/src/omnisharp/launcher.ts index e1bebc9747..670299bd98 100644 --- a/src/omnisharp/launcher.ts +++ b/src/omnisharp/launcher.ts @@ -16,7 +16,8 @@ import { Options } from './options'; export enum LaunchTargetKind { Solution, ProjectJson, - Folder + Folder, + Csx } /** @@ -44,7 +45,7 @@ export function findLaunchTargets(): Thenable { const options = Options.Read(); return vscode.workspace.findFiles( - /*include*/ '{**/*.sln,**/*.csproj,**/project.json}', + /*include*/ '{**/*.sln,**/*.csproj,**/project.json,**/*.csx}', /*exclude*/ '{**/node_modules/**,**/.git/**,**/bower_components/**}', /*maxResults*/ options.maxProjectResults) .then(resources => { @@ -72,7 +73,8 @@ function select(resources: vscode.Uri[], rootPath: string): LaunchTarget[] { hasCsProjFiles = false, hasSlnFile = false, hasProjectJson = false, - hasProjectJsonAtRoot = false; + hasProjectJsonAtRoot = false, + hasCSX = false; hasCsProjFiles = resources.some(isCSharpProject); @@ -104,6 +106,11 @@ function select(resources: vscode.Uri[], rootPath: string): LaunchTarget[] { kind: LaunchTargetKind.ProjectJson }); } + + // Discover if there is any CSX file + if (!hasCSX && isCsx(resource)) { + hasCSX = true; + } }); // Add the root folder under the following circumstances: @@ -119,6 +126,17 @@ function select(resources: vscode.Uri[], rootPath: string): LaunchTarget[] { }); } + // if we noticed any CSX file(s), add a single CSX-specific target pointing at the root folder + if (hasCSX) { + targets.push({ + label: "CSX", + description: path.basename(rootPath), + target: rootPath, + directory: rootPath, + kind: LaunchTargetKind.Csx + }); + } + return targets.sort((a, b) => a.directory.localeCompare(b.directory)); } @@ -134,6 +152,10 @@ function isProjectJson(resource: vscode.Uri): boolean { return /\project.json$/i.test(resource.fsPath); } +function isCsx(resource: vscode.Uri): boolean { + return /\.csx$/i.test(resource.fsPath); +} + export interface LaunchResult { process: ChildProcess; command: string; diff --git a/src/omnisharp/server.ts b/src/omnisharp/server.ts index 80174e7f42..e8c8f9f67f 100644 --- a/src/omnisharp/server.ts +++ b/src/omnisharp/server.ts @@ -350,11 +350,11 @@ export class OmniSharpServer { public autoStart(preferredPath: string): Thenable { return findLaunchTargets().then(launchTargets => { // If there aren't any potential launch targets, we create file watcher and try to - // start the server again once a *.sln, *.csproj or project.json file is created. + // start the server again once a *.sln, *.csproj, project.json or CSX file is created. if (launchTargets.length === 0) { return new Promise((resolve, reject) => { // 1st watch for files - let watcher = vscode.workspace.createFileSystemWatcher('{**/*.sln,**/*.csproj,**/project.json}', + let watcher = vscode.workspace.createFileSystemWatcher('{**/*.sln,**/*.csproj,**/project.json,**/*.csx}', /*ignoreCreateEvents*/ false, /*ignoreChangeEvents*/ true, /*ignoreDeleteEvents*/ true);