Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added VSCode debugging (for MvcSandbox) & code analysis support #29486

Merged
merged 8 commits into from
Apr 5, 2021
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ obj/
.packages/
.tools/
.vs/
.vscode/
node_modules/
BenchmarkDotNet.Artifacts/
.gradle/
Expand Down
25 changes: 15 additions & 10 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "PowerShell",
"request": "launch",
"name": "ps: Interactive Session",
"cwd": "${workspaceRoot}"
{
ShreyasJejurkar marked this conversation as resolved.
Show resolved Hide resolved
"name": "MvcSandbox",
"type": "coreclr",
"preLaunchTask": "MvcSandbox-build",
"request": "launch",
"program": "${workspaceFolder}/artifacts/bin/MvcSandbox/Debug/net6.0/MvcSandbox.dll",
ShreyasJejurkar marked this conversation as resolved.
Show resolved Hide resolved
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
]
}
15 changes: 15 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "MvcSandbox-build",
ShreyasJejurkar marked this conversation as resolved.
Show resolved Hide resolved
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/src/Mvc/samples/MvcSandbox/MvcSandbox.csproj"
],
"problemMatcher": "$msCompile"
}
]
}
27 changes: 27 additions & 0 deletions omnisharp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"RoslynExtensionsOptions": {
"enableAnalyzersSupport": true
},
"FormattingOptions": {
"enableEditorConfigSupport": true
},
"RenameOptions": {
"RenameInComments": true,
"RenameOverloads": true,
"RenameInStrings": true
},
"msbuild": {
"MSBuildSDKsPath": ".\\.dotnet",
"EnablePackageAutoRestore": true,
"loadProjectsOnDemand": true
},
"fileOptions": {
"systemExcludeSearchPatterns": [
"**/node_modules/**/*",
"**/bin/**/*",
"**/obj/**/*",
"**/node_modules/**/*"
],
"excludeSearchPatterns": []
}
}
7 changes: 7 additions & 0 deletions src/Mvc/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
ShreyasJejurkar marked this conversation as resolved.
Show resolved Hide resolved
"recommendations": [
"ms-dotnettools.csharp",
"ms-vscode.PowerShell",
"EditorConfig.EditorConfig"
]
}
22 changes: 22 additions & 0 deletions src/Mvc/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "MvcSandbox",
"type": "coreclr",
"preLaunchTask": "MvcSandbox-build",
"request": "launch",
"program": "${workspaceFolder}/../../artifacts/bin/MvcSandbox/Debug/net6.0/MvcSandbox.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
},
]
}
9 changes: 9 additions & 0 deletions src/Mvc/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
ShreyasJejurkar marked this conversation as resolved.
Show resolved Hide resolved
"files.trimTrailingWhitespace": true,
"files.associations": {
"*.*proj": "xml",
"*.props": "xml",
"*.targets": "xml",
"*.tasks": "xml"
}
}
19 changes: 19 additions & 0 deletions src/Mvc/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "MvcSandbox-build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/samples/MvcSandbox/MvcSandbox.csproj"
],
"problemMatcher": "$msCompile",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
18 changes: 18 additions & 0 deletions src/Mvc/omnisharp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"RoslynExtensionsOptions": {
"enableAnalyzersSupport": true
},
"FormattingOptions": {
"enableEditorConfigSupport": true
},
"RenameOptions": {
"RenameInComments": true,
"RenameOverloads": true,
"RenameInStrings": true
},
"msbuild": {
"MSBuildSDKsPath": "..\\..\\.dotnet",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually expect to use the dotnet in the path. Can we not specify this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This points to preview SDK that has been downloaded in the root .dotnet folder!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but with VS you assume you've launched it with startvs or run activate so that the dotnet that's in the path is the right one. We should do the same here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, just like we have instructed people to use startvs.cmd in the same way we will ask people to open repo in VSCode using startvscode.cmd which I have included in the PR as well!

"EnablePackageAutoRestore": true,
"loadProjectsOnDemand": true
}
}
3 changes: 3 additions & 0 deletions src/Mvc/startvscode.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@ECHO OFF

%~dp0..\..\startvscode.cmd %~dp0
29 changes: 29 additions & 0 deletions startvscode.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
@ECHO OFF
captainsafia marked this conversation as resolved.
Show resolved Hide resolved
SETLOCAL
ShreyasJejurkar marked this conversation as resolved.
Show resolved Hide resolved

:: This command launches a Visual Studio code with environment variables required to use a local version of the .NET Core SDK.

:: This tells .NET Core to use the same dotnet.exe that build scripts use
SET DOTNET_ROOT=%~dp0.dotnet
SET DOTNET_ROOT(x86)=%~dp0.dotnet\x86

:: This tells .NET Core not to go looking for .NET Core in other places
SET DOTNET_MULTILEVEL_LOOKUP=0

:: Put our local dotnet.exe on PATH first so Visual Studio knows which one to use
SET PATH=%DOTNET_ROOT%;%PATH%

SET folder=%~1

IF NOT EXIST "%DOTNET_ROOT%\dotnet.exe" (
echo .NET Core has not yet been installed. Run `%~dp0restore.cmd` to install tools
exit /b 1
)

IF "%folder%"=="" (
code .
) else (
code "%folder%"
)

exit /b 1