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

* Added VSCode debugging support for MvcSandbox

* Added ignored vscode folders

* 1. Convered some more projects.
2. Added env variable for TargetFramework and used it in launch.json file rather than
hardcoding TFW.

* Addressed PR feedback.
1. Removed extensions.json
2. Updated BuildFromSource.md for Vscode instructions.
3. Added launch settings for BasicTestApp.

* Addressed PR feedback!
This commit is contained in:
Shreyas Jejurkar 2021-04-06 05:26:05 +05:30 коммит произвёл GitHub
Родитель 79b419c40c
Коммит ae8b2c2e36
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
21 изменённых файлов: 470 добавлений и 21 удалений

1
.gitignore поставляемый
Просмотреть файл

@ -7,7 +7,6 @@ obj/
.packages/
.tools/
.vs/
.vscode/
node_modules/
BenchmarkDotNet.Artifacts/
.gradle/

7
.vscode/extensions.json поставляемый
Просмотреть файл

@ -1,7 +0,0 @@
{
"recommendations": [
"ms-dotnettools.csharp",
"ms-vscode.PowerShell",
"EditorConfig.EditorConfig"
]
}

2
.vscode/launch.json поставляемый
Просмотреть файл

@ -14,4 +14,4 @@
"processId": "${command:pickProcess}"
}
]
}
}

Просмотреть файл

@ -53,7 +53,7 @@ Visual Studio 2019 (16.8) is required to build the repo locally. If you don't ha
> You can do so by running the `Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser` command
> in PowerShell. For more information on execution policies, you can read the [execution policy docs](https://docs.microsoft.com/powershell/module/microsoft.powershell.security/set-executionpolicy).
The [global.json](/global.json) file specifies the minimum requirements needed to build using `msbuild`. The [eng/scripts/vs.json](/eng/scripts/vs.json) file provides a description of the components needed to build within VS. If you plan on developing in Visual Studio, you will need to have these components installed.
The [global.json](/global.json) file specifies the minimum requirements needed to build using `msbuild`. The [eng/scripts/vs.json](/eng/scripts/vs.json) file provides a description of the components needed to build within VS. If you plan on developing in Visual Studio, you will need to have these components installed.
> :bulb: The `InstallVisualStudio.ps1` script mentioned above reads from the `vs.json` file to determine what components to install.
@ -95,6 +95,14 @@ The build should find any JDK 11 or newer installation on the machine as long as
This repo contains a Selenium-based tests require a version of Chrome to be installed. Download and install it from <https://www.google.com/chrome>.
#### Visual Studio Code Extension
The following extensions are recommended when developing in the ASP.NET Core repository with Visual Studio Code.
- [C# extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp)
- [EditorConfig](https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig)
#### WiX (Optional)
If you plan on working with the Windows installers defined in [src/Installers/Windows](../src/Installers/Windows), you will need to install the WiX toolkit from <https://wixtoolset.org/releases/>.
@ -155,9 +163,11 @@ Studio because those projects are not listed in AspNetCore.sln.
This will download the required tools and restore all projects inside the repository. At that point, you should be able
to open the .sln file or one of the project specific .slnf files to work on the projects you care about.
> :bulb: Pro tip: you will also want to run this command after pulling large sets of changes. On the main
> branch, we regularly update the versions of .NET Core SDK required to build the repo.
> You will need to restart Visual Studio every time we update the .NET Core SDK.
> :bulb: Pro tip: you will also want to run this command after pulling large sets of changes. On the main
> branch, we regularly update the versions of .NET Core SDK required to build the repo.
> You will need to restart Visual Studio every time we update the .NET Core SDK.
> :bulb: Rerunning the above command or, perhaps, the quicker `.\build.cmd -noBuildNative -noBuildManaged` may be
> necessary after switching branches, especially if the `$(DefaultNetCoreTargetFramework)` value changes.
@ -195,6 +205,8 @@ These principles guide how we create and manage .slnf files:
Before opening the project in Visual Studio Code, you will need to make sure that you have built the project.
You can find more info on this in the "Building on command-line" section below.
To open specific folder inside Visual studio code, you have to open it with `startvscode.cmd` file. Ths will setup neccessary environment variables and will open given directory in Visual Studio Code.
Using Visual Studio Code with this repo requires setting environment variables on command line first.
Use these command to launch VS Code with the right settings.
@ -216,7 +228,7 @@ code .
```
> :bulb: Note that if you are using the "Remote-WSL" extension in VSCode, the environment is not supplied
> to the process in WSL. You can workaround this by explicitly setting the environment variables
> to the process in WSL. You can workaround this by explicitly setting the environment variables
> in `~/.vscode-server/server-env-setup`.
> See <https://code.visualstudio.com/docs/remote/wsl#_advanced-environment-setup-script> for details.
@ -302,11 +314,11 @@ Additional properties can be added as an argument in the form `/property:$name=$
Common properties include:
Property | Description
-------------------------|-------------------------------------------------------------------------------------------------------------
Configuration | `Debug` or `Release`. Default = `Debug`.
TargetArchitecture | The CPU architecture to build for (x64, x86, arm, arm64).
TargetOsName | The base runtime identifier to build for (win, linux, osx, linux-musl).
| Property | Description |
| ------------------ | ----------------------------------------------------------------------- |
| Configuration | `Debug` or `Release`. Default = `Debug`. |
| TargetArchitecture | The CPU architecture to build for (x64, x86, arm, arm64). |
| TargetOsName | The base runtime identifier to build for (win, linux, osx, linux-musl). |
### Resx files
@ -325,7 +337,7 @@ Building installers does not run as part of `build.cmd` run without parameters,
.\build.cmd -buildInstallers
```
*Note*: Additional build steps listed above aren't necessary on Linux or macOS.
_Note_: Additional build steps listed above aren't necessary on Linux or macOS.
- Run the installers produced in `artifacts/installers/{Debug, Release}/` for your platform.
- Add a NuGet.Config to your project directory with the following content:
@ -341,7 +353,7 @@ Building installers does not run as part of `build.cmd` run without parameters,
</configuration>
```
*NOTE: This NuGet.Config should be with your application unless you want nightly packages to potentially start being restored for other apps on the machine.*
_NOTE: This NuGet.Config should be with your application unless you want nightly packages to potentially start being restored for other apps on the machine._
- Update the versions on `PackageReference` items in your .csproj project file to point to the version from your local build.

27
omnisharp.json Normal file
Просмотреть файл

@ -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": []
}
}

Просмотреть файл

@ -0,0 +1,3 @@
@ECHO OFF
%~dp0..\..\startvscode.cmd %~dp0

22
src/Azure/.vscode/launch.json поставляемый Normal file
Просмотреть файл

@ -0,0 +1,22 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "AzureAppServicesHostingStartupSample",
"type": "coreclr",
"preLaunchTask": "AzureAppServicesHostingStartupSample-build",
"request": "launch",
"program": "${workspaceFolder}/../../artifacts/bin/AzureAppServicesHostingStartupSample/Debug/${env:TARGET}/AzureAppServicesHostingStartupSample.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
},
]
}

19
src/Azure/.vscode/tasks.json поставляемый Normal file
Просмотреть файл

@ -0,0 +1,19 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "AzureAppServicesHostingStartupSample-build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/samples/AzureAppServicesHostingStartupSample/AzureAppServicesHostingStartupSample.csproj"
],
"problemMatcher": "$msCompile",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}

Просмотреть файл

@ -0,0 +1,3 @@
@ECHO OFF
%~dp0..\..\startvscode.cmd %~dp0

Просмотреть файл

@ -0,0 +1,3 @@
@ECHO OFF
%~dp0..\..\startvscode.cmd %~dp0

56
src/Components/.vscode/launch.json поставляемый Normal file
Просмотреть файл

@ -0,0 +1,56 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "BlazorServerApp",
"type": "coreclr",
"preLaunchTask": "BlazorServerApp-build",
"request": "launch",
"program": "${workspaceFolder}/../../artifacts/bin/BlazorServerApp/Debug/${env:TARGET}/BlazorServerApp.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
},
{
"name": "IgnitorSample",
"type": "coreclr",
"preLaunchTask": "IgnitorSample-build",
"request": "launch",
"program": "${workspaceFolder}/../../artifacts/bin/IgnitorSample/Debug/${env:TARGET}/IgnitorSample.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
},
{
"name": "BasicTestApp",
"type": "coreclr",
"preLaunchTask": "BasicTestApp-build",
"request": "launch",
"program": "${workspaceFolder}/../../artifacts/bin/BasicTestApp/Debug/${env:TARGET}/BasicTestApp.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
}
]
}

47
src/Components/.vscode/tasks.json поставляемый Normal file
Просмотреть файл

@ -0,0 +1,47 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "BlazorServerApp-build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/Samples/BlazorServerApp/BlazorServerApp.csproj"
],
"problemMatcher": "$msCompile",
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "IgnitorSample-build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/Samples/IgnitorSample/IgnitorSample.csproj"
],
"problemMatcher": "$msCompile",
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "BasicTestApp-build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/test/testassets/BasicTestApp/BasicTestApp.csproj"
],
"problemMatcher": "$msCompile",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}

Просмотреть файл

@ -0,0 +1,3 @@
@ECHO OFF
%~dp0..\..\startvscode.cmd %~dp0

90
src/DataProtection/.vscode/launch.json поставляемый Normal file
Просмотреть файл

@ -0,0 +1,90 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "CustomEncryptorSample",
"type": "coreclr",
"preLaunchTask": "CustomEncryptorSample-build",
"request": "launch",
"program": "${workspaceFolder}/../../artifacts/bin/CustomEncryptorSample/Debug/${env:TARGET}/CustomEncryptorSample.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
},
{
"name": "EntityFrameworkCoreSample",
"type": "coreclr",
"preLaunchTask": "EntityFrameworkCoreSample-build",
"request": "launch",
"program": "${workspaceFolder}/../../artifacts/bin/EntityFrameworkCoreSample/Debug/${env:TARGET}/EntityFrameworkCoreSample.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
},
{
"name": "KeyManagementSample",
"type": "coreclr",
"preLaunchTask": "KeyManagementSample-build",
"request": "launch",
"program": "${workspaceFolder}/../../artifacts/bin/KeyManagementSample/Debug/${env:TARGET}/KeyManagementSample.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
},
{
"name": "NonDISample",
"type": "coreclr",
"preLaunchTask": "NonDISample-build",
"request": "launch",
"program": "${workspaceFolder}/../../artifacts/bin/NonDISample/Debug/${env:TARGET}/NonDISample.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
},
{
"name": "Redis",
"type": "coreclr",
"preLaunchTask": "Redis-build",
"request": "launch",
"program": "${workspaceFolder}/../../artifacts/bin/Redis/Debug/${env:TARGET}/Redis.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
}
]
}

75
src/DataProtection/.vscode/tasks.json поставляемый Normal file
Просмотреть файл

@ -0,0 +1,75 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "CustomEncryptorSample-build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/samples/CustomEncryptorSample/CustomEncryptorSample.csproj"
],
"problemMatcher": "$msCompile",
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "EntityFrameworkCoreSample-build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/samples/EntityFrameworkCoreSample/EntityFrameworkCoreSample.csproj"
],
"problemMatcher": "$msCompile",
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "KeyManagementSample-build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/samples/KeyManagementSample/KeyManagementSample.csproj"
],
"problemMatcher": "$msCompile",
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "NonDISample-build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/samples/NonDISample/NonDISample.csproj"
],
"problemMatcher": "$msCompile",
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Redis-build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/samples/Redis/Redis.csproj"
],
"problemMatcher": "$msCompile",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}

Просмотреть файл

@ -0,0 +1,3 @@
@ECHO OFF
%~dp0..\..\startvscode.cmd %~dp0

22
src/Mvc/.vscode/launch.json поставляемый Normal file
Просмотреть файл

@ -0,0 +1,22 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "MvcSandbox",
"type": "coreclr",
"preLaunchTask": "MvcSandbox-build",
"request": "launch",
"program": "${workspaceFolder}/../../artifacts/bin/MvcSandbox/Debug/${env:TARGET}/MvcSandbox.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
},
]
}

19
src/Mvc/.vscode/tasks.json поставляемый Normal file
Просмотреть файл

@ -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
src/Mvc/omnisharp.json Normal file
Просмотреть файл

@ -0,0 +1,18 @@
{
"RoslynExtensionsOptions": {
"enableAnalyzersSupport": true
},
"FormattingOptions": {
"enableEditorConfigSupport": true
},
"RenameOptions": {
"RenameInComments": true,
"RenameOverloads": true,
"RenameInStrings": true
},
"msbuild": {
"MSBuildSDKsPath": "..\\..\\.dotnet",
"EnablePackageAutoRestore": true,
"loadProjectsOnDemand": true
}
}

3
src/Mvc/startvscode.cmd Normal file
Просмотреть файл

@ -0,0 +1,3 @@
@ECHO OFF
%~dp0..\..\startvscode.cmd %~dp0

32
startvscode.cmd Normal file
Просмотреть файл

@ -0,0 +1,32 @@
@ECHO OFF
SETLOCAL
:: 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%
:: Sets TFW for Visual Studio Code usage
SET TARGET=net6.0
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