2

I migrated a visual studio solution from using a "website" to a "ASP.net project" to be able to use Web.config transformation.

Now, after having migrated, Visual Studio completely ignores syntax erros when I clean/build/rebuild my solution.

Those syntax errors will be shown in my browser as soon as I open the web application - but seeing them during compile time would be helpful. They used to be shown in my error list - where I can now only see some uninteresting warnings.

I can still run my web application, and everything works well.

How can I configure my solution, so that compile errors will appear during compile time?


edit (in response to answers/comments):

  • As soon as I open the .cs file (by double clicking on it) the syntax errors are shown (inside the file and inside the error list view).
  • I'm using Microsoft Visual Studio Professional 2012 (Version 11.0.61030.00 Update 4) with .NET 4.5.50709 (german language version). I'm locally deploying to Visual Studio's IIS.
  • I'm not using NuGet, all my sources are in one single project
  • I'm actually only providing a REST-Backend using WCF. I only have c# sources. The syntax errors are in my c# classes.
  • The syntax errors are in my .cs files in my App_Code folder.
  • When I migrated my website to a project I manually edited my .csproj file (added missing "Content Include"s etc.). I hope that this did not break my solution...
  • I am not using the default "DEBUG" and "RELEASE" build configurations, but created my own server-specific configurations (named after the names of each server).
  • ( @Guvante ) When I edit the build configurations, I see one line in the "project context table". The first and only line shows:
    1. the name of my project
    2. the configuration name in a dropdown
    3. the plattform "Any CPU"
    4. a checked checkmark "build"
    5. the empty field "deploy"
  • My error list is filtered to "current project" and it won't show the syntax errors, no matter which item I select in my solution explorer.
  • Sometimes (can't tell when exactly) VS shows a warning, when starting debugging, telling my that my module was build with optimizations or without debugging information. Don't know, whether this warning is related to this issue.
  • Console output of successful build (though sources contain syntax error) is:

    1>------ Erstellen gestartet: Projekt: MyProject, Konfiguration: localdev Any CPU ------ 1> MyProject -> C:\path\MyProject\bin\MyProject.dll ========== Erstellen: 1 erfolgreich, 0 fehlerhaft, 0 aktuell, 0 übersprungen ==========

  • I saved, closed VS, rebooted machine, reopened VS, closed eyes, crossed fingers - @chief-two-pencils ;)
slartidan
  • 20,403
  • 15
  • 83
  • 131
  • 2
    Are you using MVC or ASP.Net? Is it only ignoring errors in the web forms, or in your C# code as well? – Scottie Feb 19 '15 at 16:19
  • 1
    Specifically, are the syntax errors in your .cs files, or are they in .aspx, .asmx, ashx, .cshtml? You may need to [set those to compile](http://stackoverflow.com/questions/28289107/vs2013-does-not-compile-asp-net-mvc5-views) so you catch them when they compile on your dev machine instead of when the web server compiles them. – mason Feb 19 '15 at 16:22
  • @Scottie I updated my question (it is ignoring errors in my C# code as well) - do you have a hint for me? – slartidan Feb 19 '15 at 16:37
  • 1
    I guess we should assume you've completed the standard procedure for VS problems? Save, Close VS, Reboot machine, Open VS, Close eyes, Cross fingers... – ChiefTwoPencils Feb 19 '15 at 16:47
  • Double check your custom build configurations, it could be you accidentally unselected your projects. – Guvante Feb 19 '15 at 16:51
  • @Guvante I checked the build configurations, but could not find any suspicious setting. – slartidan Feb 20 '15 at 09:13
  • 2
    Create a new asp.net project and copy paste files manually, although it will not fix this problem it will probably save you some time. – Davor Zlotrg Feb 24 '15 at 11:49
  • @DZL sadly this is my standard procedure for VS problems. But it works! – user__42 Feb 24 '15 at 13:25

3 Answers3

2

In the .csproj file you can change

<Content Include="C:\...\foo.cs" />

back to

<Compile Include="C:\...\foo.cs" />

More info on the MSDN documentation and this stackoverflow question.

Community
  • 1
  • 1
user__42
  • 543
  • 4
  • 13
  • Thanks, that's it! Seems like the "website" did not need the "Compile", but "ASP.net project" does... – slartidan Feb 24 '15 at 13:20
  • I also had to rename "App_Code" to another name, otherwise the IIS had duplicate classes (referencing two same DLLs). – slartidan Feb 24 '15 at 14:49
1

You should change it to:

<Compile Include="....." />

The MSDN article on the build action property says:

  1. Compile - The file is compiled into the build output. This setting is used for code files.

  2. Content - The file is not compiled, but is included in the Content output group. For example, this setting is the default value for an .htm or other kind of Web file. Means that it is a deployable project item, it signals that the file needs to be copied to the target machine. Also note that Content will be included when using one-click deploy.

See more about build action here.

Community
  • 1
  • 1
Raging Bull
  • 18,593
  • 13
  • 50
  • 55
0

if you have Nuget packages run an update-package

try to unload the project and reload it into the solution

This worked for me