Launch .Net Core with VSCode for starters
To use VSCode for .net core you would need Omnisharp extension so that we can debug our application just like as in Visual Studio.
dotnet new webapp appname.web
dotnet new webapi appname.api
dotnet new webapi appname.api
Create a solution so that it wraps all the projects in one place
dotnet new sln appname
dotnet sln add appname.web appname.api
dotnet sln add appname.web appname.api
After building the Web and the API projects we need to create the launch.json which VScode refers to build and debug the application. For a complete reference on doing these projects consider this great resource.
You can always use VSCode terminal to run these above commands as well, also note you can open multiple terminals the same VSCode instance like this.
Setup the launch.json by clicking on add configuration and select .Net core web app. we will need to add two such configurations one for web and another for web api.
For web api you need to launch the browser on running the app, disable
launchBrowser.enabled: false
we need to update the Url’s for both our applications with different ports
env.ASPNETCORE_URLS: “https://localhost:5001”
The build task for the project is defined in tasks.json to which the preLaunchTask references. In below example launch.json I have created two tasks to be executed before running the application. This is how we execute multiple tasks we need to chain each task with the first task name mentioned in preLaunchTask and the rest in tasks.json dependsOn property.
F5 and launch with debug mode on!
Below are the complete launch.json and tasks.json
Comments
Post a Comment