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

Fix VS Code launcher and tasks for dotnet watch #10881

Merged
merged 8 commits into from
Mar 8, 2022
Merged
52 changes: 17 additions & 35 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console) - net6.0",
"name": ".NET Core Launch (console debug) - net6.0",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "Web App: Dotnet Build Debug - net6.0",
"preLaunchTask": "dotnet build (debug) - net6.0",
"program": "${workspaceRoot}/src/OrchardCore.Cms.Web/bin/Debug/net6.0/OrchardCore.Cms.Web.dll",
"args": [],
"cwd": "${workspaceRoot}/src/OrchardCore.Cms.Web",
Expand All @@ -19,7 +19,7 @@
"type": "coreclr",
"request": "launch",
"internalConsoleOptions": "openOnSessionStart",
"preLaunchTask": "Web App: Dotnet Build Debug - net6.0",
"preLaunchTask": "dotnet build (debug) - net6.0",
"program": "${workspaceRoot}/src/OrchardCore.Cms.Web/bin/Debug/net6.0/OrchardCore.Cms.Web.dll",
"args": [],
"cwd": "${workspaceRoot}/src/OrchardCore.Cms.Web",
Expand All @@ -36,7 +36,7 @@
"name": ".NET Core Launch (web release) - net6.0",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "Web App: Dotnet Build Release - net6.0",
"preLaunchTask": "dotnet build (release) - net6.0",
"program": "${workspaceRoot}/src/OrchardCore.Cms.Web/bin/Release/net6.0/OrchardCore.Cms.Web.dll",
"args": [],
"cwd": "${workspaceRoot}/src/OrchardCore.Cms.Web",
Expand All @@ -50,46 +50,28 @@
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
},
{
"name": ".NET Core Launch (publish framework dependent) - net6.0",
"type": "coreclr",
"name": ".NET Core Launch (web debug) - dotnet watch - net6.0",
"type": "dotnetwatchattach",
"request": "launch",
"internalConsoleOptions": "openOnSessionStart",
"preLaunchTask": "Web App: Dotnet Publish (framework dependent) - net6.0",
"program": "${workspaceRoot}/.build/release/OrchardCore.Cms.Web.dll",
"args": [],
"cwd": "${workspaceRoot}/.build/release",
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
"task": "dotnet watch - net6.0",
"program": "OrchardCore.Cms.Web.exe",
"args": {
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"cwd": "${workspaceRoot}/src/OrchardCore.Cms.Web",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
}
},
{
"name": ".NET Core Launch (publish self-contained) - net6.0",
"type": "coreclr",
"request": "launch",
"internalConsoleOptions": "openOnSessionStart",
"preLaunchTask": "Web App: Dotnet Publish (self-contained) - net6.0",
"program": "${workspaceRoot}/.build/release/OrchardCore.Cms.Web.dll",
"args": [],
"cwd": "${workspaceRoot}/.build/release",
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
}
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
},
{
"name": "Gulp Debug",
Expand Down
87 changes: 63 additions & 24 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,43 @@
},
"tasks": [
{
"label": "Dotnet Restore",
"label": "dotnet watch - net6.0",
"type": "process",
"command": "dotnet",
"args": [
"watch",
"run",
"${workspaceRoot}/src/OrchardCore.Cms.Web",
"-f",
"net6.0"
],
"options": {
"cwd": "${workspaceRoot}/src/OrchardCore.Cms.Web"
},
"problemMatcher": "$msCompile"
},
{
"label": "dotnet run",
"type": "shell",
"command": "dotnet",
"args": [
"run",
"--project",
"${workspaceRoot}\\src\\OrchardCore.Cms.Web\\OrchardCore.Cms.Web.csproj",
"-f",
"net6.0"
]
},
{
"label": "dotnet restore",
"type": "shell",
"command": "dotnet",
"args": [
"restore"
]
},
{
"label": "Dotnet Restore Force",
"label": "dotnet restore force",
"type": "shell",
"command": "dotnet",
"args": [
Expand All @@ -41,7 +69,7 @@
]
},
{
"label": "Dotnet clean (debug)",
"label": "dotnet clean (debug)",
"type": "shell",
"command": "dotnet",
"args": [
Expand All @@ -51,7 +79,7 @@
]
},
{
"label": "Dotnet clean (release)",
"label": "dotnet clean (release)",
"type": "shell",
"command": "dotnet",
"args": [
Expand All @@ -61,7 +89,7 @@
]
},
{
"label": "Web App: Dotnet Build Debug - net6.0",
"label": "dotnet build (debug) - net6.0",
"type": "shell",
"command": "dotnet",
"args": [
Expand All @@ -75,42 +103,51 @@
"problemMatcher": "$msCompile"
},
{
"label": "Web App: Dotnet Rebuild Debug - net6.0",
"label": "dotnet build (release) - net6.0",
"type": "shell",
"command": "dotnet",
"args": [
"build",
"${workspaceRoot}/src/OrchardCore.Cms.Web",
"--no-incremental",
"-c",
"Debug",
"Release",
"-f",
"net6.0"
],
"problemMatcher": "$msCompile"
},
{
"label": "Web App: Dotnet Build Release - net6.0",
"label": "dotnet rebuild (debug) - net6.0",
"type": "shell",
"command": "dotnet",
"args": [
"build",
"${workspaceRoot}/src/OrchardCore.Cms.Web",
"--no-incremental",
"-c",
"Release",
"Debug",
"-f",
"net6.0"
],
"problemMatcher": "$msCompile"
},
{
"label": "Web App: Dotnet Run",
"label": "dotnet rebuild (release) - net6.0",
"type": "shell",
"command": "dotnet",
"args": [
"cd ${workspaceRoot}/src/OrchardCore.Cms.Web & dotnet run"
]
"build",
"${workspaceRoot}/src/OrchardCore.Cms.Web",
"--no-incremental",
"-c",
"Release",
"-f",
"net6.0"
],
"problemMatcher": "$msCompile"
},
{
"label": "Cleanup build folder",
"label": "cleanup publish folder",
"type": "shell",
"command": "rm",
"windows": {
Expand All @@ -126,7 +163,7 @@
]
},
{
"label": "Dotnet Publish (self-contained) - net6.0",
"label": "dotnet publish (self-contained) - release - net6.0",
"type": "shell",
"command": "dotnet",
"windows": {
Expand Down Expand Up @@ -161,7 +198,7 @@
"problemMatcher": "$msCompile"
},
{
"label": "Dotnet Publish (framework dependent) - net6.0",
"label": "dotnet publish (framework dependent) - release - net6.0",
"type": "shell",
"command": "dotnet",
"windows": {
Expand Down Expand Up @@ -198,23 +235,25 @@
"problemMatcher": "$msCompile"
},
{
"label": "Web App: Dotnet Publish (self-contained) - net6.0",
"label": "tasks: dotnet publish release (self-contained) - net6.0",
"dependsOn": [
"Cleanup build folder",
"Dotnet Publish (self-contained) - net6.0"
"cleanup publish folder",
"dotnet publish (self-contained) - net6.0"
]
},
{
"label": "Web App: Dotnet Publish (framework dependent) - net6.0",
"label": "tasks: dotnet publish release (framework dependent) - net6.0",
"dependsOn": [
"Cleanup build folder",
"Dotnet Publish (framework dependent) - net6.0"
"cleanup publish folder",
"dotnet publish (framework dependent) - net6.0"
]
},
{
"label": "Gulp Build",
"label": "gulp build",
"type": "shell",
"command": "gulp",
"args": [
"gulp build"
Copy link
Member

Choose a reason for hiding this comment

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

Should this be npm run build instead ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

never tried but that's for debugging the gulpfile.js

Copy link
Member

Choose a reason for hiding this comment

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

Yes, but this required gulp to be installed globally. npm run build does not as it uses gulp from node_modules.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's the default task suggested. npm run build will try to install it if not found every time whereas this will just execute what is needed knowing that it is already installed globally or locally. I don't mind changing it, but need to test it first.

Copy link
Member

Choose a reason for hiding this comment

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

Npm run build does not install first as far as I know. It simply runs a script as defined in the package.json script section.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. But then it will do the same if the gulp package is not installed. So, here it is just a task that executes the gulp build command to debug it without knowing if it's installed or not. What you suggest is to run the gulp pipeline by passing through npm which could lead to executing also something else than gulp.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be honest, we keep it there because it was there and I updated the task to comply with the latest VS Code tasks implementation details; but it's not something that we use much. Also, it is looking like we might need to move to WebPack or something else at some point.

Copy link
Contributor Author

@Skrypt Skrypt Mar 7, 2022

Choose a reason for hiding this comment

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

More on this. The actual VS Code launcher is expecting to get the gulp.js file from the local node_modules folder. The package.json file standing in the root folder of the project imports gulp ^4.0.2 so it is required to do an npm install before running this launcher for this to work else it will fail to find gulp.js.

    {
      "name": "Gulp Debug",
      "type": "node",
      "request": "launch",
      "program": "${workspaceRoot}/node_modules/gulp/bin/gulp.js",
      "stopOnEntry": false,
      "args": [],
      "cwd": "${workspaceRoot}",
      "runtimeArgs": [
        "--nolazy"
      ],
      "console": "internalConsole"
    }

"build"
],
"problemMatcher": "$gulp-tsc"
}
Expand Down