Skip to content

Commit

Permalink
Added VSCode debugging (for MvcSandbox) & code analysis support (dotn…
Browse files Browse the repository at this point in the history
…et#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!
  • Loading branch information
ShreyasJejurkar authored Apr 5, 2021
1 parent 79b419c commit ae8b2c2
Show file tree
Hide file tree
Showing 21 changed files with 470 additions and 21 deletions.
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
7 changes: 0 additions & 7 deletions .vscode/extensions.json

This file was deleted.

2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
"processId": "${command:pickProcess}"
}
]
}
}
36 changes: 24 additions & 12 deletions docs/BuildFromSource.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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/>.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.

Expand All @@ -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.
Expand Down Expand Up @@ -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

Expand All @@ -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:
Expand All @@ -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.

Expand Down
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": []
}
}
3 changes: 3 additions & 0 deletions src/Antiforgery/startvscode.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@ECHO OFF

%~dp0..\..\startvscode.cmd %~dp0
22 changes: 22 additions & 0 deletions src/Azure/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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 changes: 19 additions & 0 deletions src/Azure/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -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
}
}
]
}
3 changes: 3 additions & 0 deletions src/Azure/startvscode.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@ECHO OFF

%~dp0..\..\startvscode.cmd %~dp0
3 changes: 3 additions & 0 deletions src/Caching/startvscode.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@ECHO OFF

%~dp0..\..\startvscode.cmd %~dp0
56 changes: 56 additions & 0 deletions src/Components/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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 changes: 47 additions & 0 deletions src/Components/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -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
}
}
]
}
3 changes: 3 additions & 0 deletions src/Components/startvscode.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@ECHO OFF

%~dp0..\..\startvscode.cmd %~dp0
90 changes: 90 additions & 0 deletions src/DataProtection/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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"
},
}
]
}
Loading

0 comments on commit ae8b2c2

Please sign in to comment.