As a .NET Core developer using VS Code on Windows, optimizing your workflow with the right commands can boost productivity and streamline development. Whether you are coding, debugging, building, or deploying, these essential VS Code commands and .NET CLI commands will make your life easier.
1. Setting Up Your .NET Core Project
Create a New .NET Core Project
Use the following command to create a new .NET Core project:
dotnet new console -o MyApp
cd MyApp
If you are creating ASP.NET Core MVC app:
dotnet new mvc -o MyWebApp
cd MyWebApp
2. Essential Commands for Development
Run the Application
Run your app using:
dotnet run
Restore Dependencies
If you clone a project, restore NuGet dependencies:
dotnet restore
Install a New NuGet Package
To install a package (e.g., Newtonsoft.Json):
dotnet add package Newtonsoft.Json
List Installed Packages
dotnet list package
3. Debugging & Testing
Start Debugging in VS Code
Press F5
or run:
dotnet watch run
This enables hot reload and automatically restarts the app when you make changes.
Run Unit Tests
If you are using xUnit, NUnit, or MSTest, run:
dotnet test
4. Building & Publishing the App
Build the Project
dotnet build
This compiles the application and checks for errors.
Publish for Deployment
For self-contained deployment:
dotnet publish -c Release -r win-x64 --self-contained true -o ./publish
For Azure App Service deployment:
dotnet publish -c Release -o ./publish
5. Deploying to Azure from VS Code
Login to Azure
az login
Deploy to Azure App Service
- Open the Command Palette in VS Code (
Ctrl+Shift+P
). - Select “Azure App Service: Deploy to Web App…”.
- Choose your app and deploy.
Alternatively, you can install Azure widget to connect and deploy the web to Azure App service. Follow this link –
6. Git Commands for Source Control
Initialize Git in the Project
git init
Add Files and Commit
git add .
git commit -m "Initial commit"
Push Code to GitHub
git remote add origin https://github.com/your-repo.git
git push -u origin main
Conclusion
These commands will boost your efficiency as a .NET Core developer in VS Code. Whether you’re writing code, debugging, building, or deploying, these shortcuts will help you work smarter, not harder.
🚀 Do you have other favorite VS Code or .NET CLI commands? Share them in the comments!
Keep Following- SharePointCafe.NET