Aliq Qim
Aliq Qim

Reputation: 136

How to prevent Visual Studio from starting debug session in case of errors

When I press F5, Visual Studio builds my project and runs it (under debugger). It does so even if there are typescript of razor/cshtml errors in the errors window.

I would like Visual Studio to skip the run just like it does in case of C# compiler errors.

Upvotes: 2

Views: 1535

Answers (1)

Md Rahatur Rahman
Md Rahatur Rahman

Reputation: 3244

Edit the .Web.csproj project file with an editor and add the following to the <PropertyGroup> tag:

<MvcBuildViews>true</MvcBuildViews>

The end result should look like this:

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    ...
    <MvcBuildViews>true</MvcBuildViews>
</PropertyGroup>

You will need to reload the project\visual studio. This will compile the views now. Remember compilation of the View files will increase your overall compilation time for the project.

Update:

Optional step: You may have the build error warning off. In that case you will have to turn it on from Tools > Options > Projects and Solutions > Build and Run, then on the right panel under the "on Run, when build or deployment errors occur:" - select "Prompt to launch" option. Then click ok.

enter image description here

Now if you run the project VS will compile your razor views and if there is any error anywhere in the solution you will see a prompt, click the No button if you do not want to run.

enter image description here

Upvotes: 3

Related Questions