Skip to content

Commit b989062

Browse files
authored
Merge pull request #2053 from janaka/config-default-sln
Add support for configuring default startup *.sln in settings.json
2 parents 891f8c2 + e34bf5a commit b989062

32 files changed

+392
-1057
lines changed

.gitignore

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ install.*
1010

1111
*.vsix
1212

13-
obj/
14-
bin/
15-
test/**/.vscode
13+
14+
test/**/.vscode/launch.json
15+
test/**/.vscode/tasks.json
16+
1617
.logs/
1718
.nyc_output/
1819
coverage/

.vscode/tasks.json

+11-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
"taskName": "build",
66
"command": "npm",
77
"isShellCommand": true,
8-
"args": ["run", "compile"],
8+
"args": [
9+
"run",
10+
"compile"
11+
],
912
"showOutput": "always",
1013
"isBuildCommand": true
1114
},
@@ -14,19 +17,23 @@
1417
"command": "echo",
1518
"showOutput": "always",
1619
"isShellCommand": true,
17-
"args": ["Run tests in VS Code by launching the debugger with the 'Launch Tests' configuration."],
20+
"args": [
21+
"Run tests in VS Code by launching the debugger with the 'Launch Tests' configuration."
22+
],
1823
"isTestCommand": true
1924
},
2025
{
2126
"taskName": "tslint",
2227
"command": "gulp",
2328
"isShellCommand": true,
24-
"args": ["tslint"],
29+
"args": [
30+
"tslint"
31+
],
2532
"problemMatcher": {
2633
"owner": "tslint",
2734
"fileLocation": [
2835
"relative",
29-
"${workspaceRoot}"
36+
"${workspaceFolder}"
3037
],
3138
"severity": "warning",
3239
"pattern": {

CHANGELOG.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@
1111
* "Restore Project" - Displays a drop-down that shows all the available projects in the solution or in the workspace. Selecting one of them would trigger a dotnet restore for the particular project.
1212
* "Restore All Projects" - Triggers a dotnet restore for all projects in the current solution or workspace.
1313

14-
* Modified the "Unresolved dependencies" prompt to restore the all the projects in the currently selected solution or workspace. (PR: [#2323] https://github.com/OmniSharp/omnisharp-vscode/pull/2323)
14+
* Modified the "Unresolved dependencies" prompt to restore the all the projects in the currently selected solution or workspace. (PR: [#2323](https://github.com/OmniSharp/omnisharp-vscode/pull/2323))
15+
16+
* Added support to configure the default *.sln file loaded when opening a project with multiple *.sln files in the root. _(Contributed by [@janaka](https://github.com/janaka))_ (PR: [#2053](https://github.com/OmniSharp/omnisharp-vscode/pull/2053))
17+
1518

1619
#### Misc
1720

18-
* Added a prompt to "Restart OmniSharp" when there is a change in omnisharp "path", "useGlobalMono" or "waitForDebugger" settings.(PR: [#2316] https://github.com/OmniSharp/omnisharp-vscode/pull/2316)
21+
* Added a prompt to "Restart OmniSharp" when there is a change in omnisharp "path", "useGlobalMono" or "waitForDebugger" settings.(PR: [#2316](https://github.com/OmniSharp/omnisharp-vscode/pull/2316))
1922

2023
#### Editor
2124

package.json

+14-9
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,11 @@
568568
"default": 250,
569569
"description": "The maximum number of projects to be shown in the 'Select Project' dropdown (maximum 250)."
570570
},
571+
"omnisharp.defaultLaunchSolution": {
572+
"type": "string",
573+
"default": null,
574+
"description": "The name of the default solution used at start up if the repo has multiple solutions. e.g.'MyAwesomeSolution.sln'. Default value is `null` which will cause the first in alphabetical order to be chosen."
575+
},
571576
"omnisharp.useEditorFormattingSettings": {
572577
"type": "boolean",
573578
"default": true,
@@ -1618,9 +1623,9 @@
16181623
"type": "coreclr",
16191624
"request": "launch",
16201625
"preLaunchTask": "build",
1621-
"program": "^\"\\${workspaceRoot}/bin/Debug/${1:<target-framework>}/${2:<project-name.dll>}\"",
1626+
"program": "^\"\\${workspaceFolder}/bin/Debug/${1:<target-framework>}/${2:<project-name.dll>}\"",
16221627
"args": [],
1623-
"cwd": "^\"\\${workspaceRoot}\"",
1628+
"cwd": "^\"\\${workspaceFolder}\"",
16241629
"stopAtEntry": false,
16251630
"console": "internalConsole"
16261631
}
@@ -1643,9 +1648,9 @@
16431648
"type": "coreclr",
16441649
"request": "launch",
16451650
"preLaunchTask": "build",
1646-
"program": "^\"\\${workspaceRoot}/bin/Debug/${1:<target-framework>}/${2:<project-name.dll>}\"",
1651+
"program": "^\"\\${workspaceFolder}/bin/Debug/${1:<target-framework>}/${2:<project-name.dll>}\"",
16471652
"args": [],
1648-
"cwd": "^\"\\${workspaceRoot}\"",
1653+
"cwd": "^\"\\${workspaceFolder}\"",
16491654
"stopAtEntry": false,
16501655
"launchBrowser": {
16511656
"enabled": true,
@@ -1665,7 +1670,7 @@
16651670
"ASPNETCORE_ENVIRONMENT": "Development"
16661671
},
16671672
"sourceFileMap": {
1668-
"/Views": "^\"\\${workspaceRoot}/Views\""
1673+
"/Views": "^\"\\${workspaceFolder}/Views\""
16691674
}
16701675
}
16711676
},
@@ -1677,13 +1682,13 @@
16771682
"type": "coreclr",
16781683
"request": "launch",
16791684
"preLaunchTask": "build",
1680-
"program": "^\"\\${workspaceRoot}/bin/Debug/${1:<target-framework>}/${2:<project-name.dll>}\"",
1685+
"program": "^\"\\${workspaceFolder}/bin/Debug/${1:<target-framework>}/${2:<project-name.dll>}\"",
16811686
"args": [],
1682-
"cwd": "^\"\\${workspaceRoot}\"",
1687+
"cwd": "^\"\\${workspaceFolder}\"",
16831688
"stopAtEntry": false,
16841689
"console": "internalConsole",
16851690
"pipeTransport": {
1686-
"pipeCwd": "^\"\\${workspaceRoot}\"",
1691+
"pipeCwd": "^\"\\${workspaceFolder}\"",
16871692
"pipeProgram": "^\"${3:enter the fully qualified path for the pipe program name, for example '/usr/bin/ssh'}\"",
16881693
"pipeArgs": [],
16891694
"debuggerPath": "^\"${4:enter the path for the debugger on the target machine, for example ~/vsdbg/vsdbg}\""
@@ -1699,7 +1704,7 @@
16991704
"request": "attach",
17001705
"processId": "^\"\\${command:pickRemoteProcess}\"",
17011706
"pipeTransport": {
1702-
"pipeCwd": "^\"\\${workspaceRoot}\"",
1707+
"pipeCwd": "^\"\\${workspaceFolder}\"",
17031708
"pipeProgram": "^\"${1:enter the fully qualified path for the pipe program name, for example '/usr/bin/ssh'}\"",
17041709
"pipeArgs": [],
17051710
"debuggerPath": "^\"${2:enter the path for the debugger on the target machine, for example ~/vsdbg/vsdbg}\""

src/omnisharp/launcher.ts

-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ function resourcesToLaunchTargets(resources: vscode.Uri[]): LaunchTarget[] {
101101
// Add .sln files if there are .csproj files
102102
if (hasCsProjFiles && isSolution(resource)) {
103103
hasSlnFile = true;
104-
105104
targets.push({
106105
label: path.basename(resource.fsPath),
107106
description: vscode.workspace.asRelativePath(path.dirname(resource.fsPath)),

src/omnisharp/options.ts

+11-7
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ export class Options {
1919
public showReferencesCodeLens: boolean,
2020
public showTestsCodeLens: boolean,
2121
public disableCodeActions: boolean,
22-
public disableMSBuildDiagnosticWarning: boolean) { }
22+
public disableMSBuildDiagnosticWarning: boolean,
23+
public defaultLaunchSolution?: string) { }
24+
2325

2426
public static Read(vscode: vscode): Options {
2527
// Extra effort is taken below to ensure that legacy versions of options
@@ -47,6 +49,7 @@ export class Options {
4749

4850
const projectLoadTimeout = omnisharpConfig.get<number>('projectLoadTimeout', 60);
4951
const maxProjectResults = omnisharpConfig.get<number>('maxProjectResults', 250);
52+
const defaultLaunchSolution = omnisharpConfig.get<string>('defaultLaunchSolution', undefined);
5053
const useEditorFormattingSettings = omnisharpConfig.get<boolean>('useEditorFormattingSettings', true);
5154

5255
const useFormatting = csharpConfig.get<boolean>('format.enable', true);
@@ -62,16 +65,17 @@ export class Options {
6265
path,
6366
useGlobalMono,
6467
waitForDebugger,
65-
loggingLevel,
66-
autoStart,
67-
projectLoadTimeout,
68-
maxProjectResults,
69-
useEditorFormattingSettings,
68+
loggingLevel,
69+
autoStart,
70+
projectLoadTimeout,
71+
maxProjectResults,
72+
useEditorFormattingSettings,
7073
useFormatting,
7174
showReferencesCodeLens,
7275
showTestsCodeLens,
7376
disableCodeActions,
74-
disableMSBuildDiagnosticWarning);
77+
disableMSBuildDiagnosticWarning,
78+
defaultLaunchSolution);
7579
}
7680

7781
private static readPathOption(csharpConfig: WorkspaceConfiguration, omnisharpConfig: WorkspaceConfiguration): string | null {

src/omnisharp/server.ts

+8
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,14 @@ export class OmniSharpServer {
445445
});
446446
}
447447

448+
const defaultLaunchSolutionConfigValue = this.optionProvider.GetLatestOptions().defaultLaunchSolution;
449+
450+
// First, try to launch against something that matches the user's preferred target
451+
const defaultLaunchSolutionTarget = launchTargets.find((a) => (path.basename(a.target) === defaultLaunchSolutionConfigValue));
452+
if (defaultLaunchSolutionTarget) {
453+
return this.restart(defaultLaunchSolutionTarget);
454+
}
455+
448456
// If there's more than one launch target, we start the server if one of the targets
449457
// matches the preferred path. Otherwise, we fire the "MultipleLaunchTargets" event,
450458
// which is handled in status.ts to display the launch target selector.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
**/obj/
2+
**/bin/

test/integrationTests/testAssets/singleCsproj/obj/Debug/netcoreapp2.0/singleCsproj.AssemblyInfo.cs

Whitespace-only changes.

test/integrationTests/testAssets/singleCsproj/obj/Debug/netcoreapp2.0/singleCsproj.AssemblyInfoInputs.cache

-1
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ffcdec535c6ed9f5449ad17c7f1a870da5e60671
1+
a3678bb80f266957ba73795e6cd519aa5ad43bf2

0 commit comments

Comments
 (0)