So, I am an old school Visual Studio user who just got migrated to Visual Studio Code and I think I am missing something here. However, I will explain what I am experiencing here:
With Visual Studio I could always right-click a solution and rebuild it and run it and it was really great. However, in Visual Studio Code, there is no rebuild (at least that I know of). So now I have to do dotnet clean followed by dotnet clean and since it is a multi-step process, I sometimes forget a step and then my code starts behaving really whimsically. For example, a code like below
Person.Name = someNameVariable
if this was just a new added line in my code then V-code would execute that line of code but when I put watch on Person.Name it is always Null. Now, This could be because it is still executing old code. However, the behavior is not very obvious and makes me feel like my code may have some issues. So I have two questions:
On the menu bar, choose Build, and then choose either Build ProjectName or Rebuild ProjectName. Choose Build ProjectName to build only those project components that have changed since the most recent build. Choose Rebuild ProjectName to "clean" the project and then build the project files and all project components.
To build, rebuild, or clean an entire solutionChoose Build All to compile the files and components within the project that have changed since the most recent build. Choose Rebuild All to "clean" the solution and then builds all project files and components. Choose Clean All to delete any intermediate and output files.
Clean Solution - deletes all compiled files (all dll's and exe's ). Build Solution - compiles code files (dll and exe) that have changed. Rebuild Solution - Deletes all compiled files and Compiles them again regardless of whether or not the code has changed.
Try a custom build
task in your tasks.json
.
Open VSCode settings and search for "terminal.integrated.shell"
.
If you are using PowerShell as your integrated terminal, then use the following build
task in your tasks.json
file.
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "dotnet clean; dotnet build",
"args": [
]
}
]
}
If you are using cmd or bash as your integrated termininal, then change the command to this:
"command": "dotnet clean && dotnet build",
Then hit your VS Code debug button.
That assume you already have the default launch.json file with "preLaunchTask": "build"
in it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With