234

I have a WebApplication which contains reference to WCF services.

While building using Visual Studio 2010, Build fails without any error or warning. However building the .csproj using MsBuild is successful.

Can't figure out what should I try in Visual Studio, to resolve / diagnose the issue. Can you please help out?

I find out that the build has been failing,

  1. From text displayed in status Bar.
    enter image description here

  2. From output window:

     ========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========
    

    The output tab includes configuration details.

    ------ Build started: Project: <projectName here> Configuration: Debug Any CPU
    
6
  • 17
    Try to increase verbosity of the Output Window in Visual Studio. It can help to determine the problem. How to increase verbosity level: blogs.msdn.com/b/saraford/archive/2008/10/07/… Nov 5, 2012 at 20:20
  • @autrevo: There might be something in your computer's event log. See neovolve.com/post/2010/09/10/… for more information.
    – Malice
    Nov 5, 2012 at 20:35
  • @MaximKornilov I did increase verbosity to Diagnostic mode. But couldn't find much useful info.
    – Abhijeet
    Nov 6, 2012 at 15:19
  • @NahuelI. Last time there was an issue in .csproj which we had to edit manually to fix the issue. As suggested in comments I have tried to change msbuild verbosity to diagnostics but I don't see an error.
    – Abhijeet
    May 21, 2014 at 11:35
  • Post the result from the output window. The problem can't be solved without more information because at this point, the community has no code, no error message, and no output.
    – Moby Disk
    Jul 29, 2014 at 20:23

11 Answers 11

366

I noticed that if "Build + Intellisense" is selected in the Error List, it causes the error messages to be swallowed.

Change this option to "Build Only", and all error messages will be displayed:

Screenshot

I don't know if this is a bug in Visual Studio or what, but it certainly revealed hidden error messages that were the key to pinpointing the failure for me.

Some, like Richard J Foster, have suggested increasing the "MSBuild project build output verbosity" setting to "Diagnostic" (the highest possible option), but this didn't solve the problem for me, as Visual Studio appeared to be suppressing the error message(s) themselves.

As an alternative, you may try to use the raw output messages from the "Output" tab, which haven't been filtered by Visual Studio. Either do an in-place search for the strings "error" and/or "failed", or copy all of the output to your favorite text editor and do a search there.

To ensure that the Output window appears each time you do a build, you can go to Tools → Options → Projects and Solutions → General, and ensure that the option "Show Output Window when build starts" is checked.

As an additional troubleshooting step, it is also possible to build the project from the PowerShell command line by running dotnet build. This will show you the complete build output, including any errors that Visual Studio may be hiding.

1
182

I just ran into a similar situation. In my case, a custom action (from the MSBuildVersioning package available on Nuget.org - http://www.nuget.org/packages/MSBuildVersioning/) which appeared in the csproj file's BeforeBuild target was failing without triggering any error message in the normal place.

I was able to determine this by setting the "MSBuild project build output verbosity" (in the latest Visual Studio's Tools tab [Path: Tools > Options > Projects and Solutions > Build and Run]) to "Diagnostic" as shown below. This then showed that the custom action (in my case HgVersionFile) was what had failed.

Screen capture from Visual Studio showing the modified setting.

5
  • 4
    For anyone who is clueless like me: to use this method you may have to search the contents of the output window. My build errors were being hidden by #pragma warning disable statements and were only visible when I searched 'error' in the output window.
    – sirdank
    Nov 4, 2016 at 16:51
  • 1
    After setting my verbosity to diagnostic, I discovered I was getting a System.OutOfMemoryException. I was using 98% of my computer's available memory. This is a great answer!
    – TxRegex
    Jan 19, 2017 at 16:14
  • 1
    In my case it was a project with .Net 4.5 references project with 4.5.2. Detailed diagnostic helper to find it out Jun 29, 2017 at 8:33
  • 1
    For me I was using Queue New Build to build on TFS and the Queue Build dialog has a verbosity on the second tab I could turn up and then see the problem in the build log.
    – AaronLS
    Mar 11, 2019 at 22:15
  • Added a reference to another project in the solution. Somehow something went wrong. References list in the Solution Explorer stated that it was there. Only after switching to diagnostic mode, the output window told me that there was something wrong with that reference. Removed it and added it again, and problem solved.
    – Tys
    Mar 1, 2020 at 21:29
71

Here are some things that you can try:

  • If your solution contains more than one project, try building each project one at a time. (You may even want to try opening each project independently of the solution.)
  • If applicable, ensure that all of your projects (including dependencies and tests) target the same version of the .NET Framework. (Thanks to user764754 for this suggestion!)
    Tip: Check Tools → Extension and Updates to ensure that your packages are up-to-date.
  • Ensure that all dependency projects are built to target the same platform as your main project.
  • Try restarting Visual Studio.
  • As suggested by Bill Yang, try running Visual Studio as Administrator, if you aren't already. (If you are already running Visual Studio as Administrator, perhaps try the opposite?)
  • Try restarting your computer.
  • Try "Rebuild All".
  • Run "Clean Solution", then remove your *vspscc* and *vssscc* files, restart Visual Studio, and then "Rebuild All".
  • As suggested by Andy, close Visual Studio, delete the .suo file, and restart Visual Studio.
  • As suggested by Arun Prasad E S, close Visual Studio, delete the .vs folder in your solution directory, and then re-open Visual Studio. (This folder is auto-generated by Visual Studio and contains cache, configuration settings, and more. More details can be found in these questions: Visual Studio - Deleting .vs folder and https://stackoverflow.com/q/48897191.)
  • As suggested by MrMalith, close Visual Studio, delete the obj folder in your solution directory, clear your temporary folder, and then re-open Visual Studio.
5
  • 5
    Just restarting VS2013 helped me. I was working on a VM with limited resources but I'm not sure if that had anything to do with it.
    – Jmaurier
    Oct 18, 2016 at 14:01
  • 2
    You cannot clean the solution if you are having this issue.
    – H. Aydin
    Dec 22, 2017 at 17:29
  • 2
    What helped me is closing all instances of VS (not enough to close the faulty one), and then delete the .vs folder and start VS again.
    – EliSherer
    Aug 15, 2018 at 8:18
  • In my case, compiling the projects one at a time helped. I didn't get any error when doing Rebuild All (even cleaning/reopening/etc), except when I went singularly and did Build on every single project. One of the projects in the chain had errors that popped up only like this. Fixing the errors allowed me to compile the solution.
    – alelom
    May 10, 2022 at 11:44
  • Visual Studio doesn't always seem to recover well if the computer goes into sleep mode, and restarting VS seems to help. That effectively defeats the purpose of sleep mode, but at least it has seemed to fix this issue for me when it's been caused by sleep mode. May 4, 2023 at 1:51
30

Delete the hidden .vs folder & restart Visual Studio. That worked for me.

3
11

I want to expand on Sasse's answer. I had to target the correct version of .NET to resolve the problem.

One project was giving me an error:

"The type or namespace name 'SomeNamespace' does not exist in the namespace 'BeforeSomeNamespace' (are you missing an assembly reference?)".

There was no error in the Error List window but the assembly had a yellow warning sign under "References".

I then saw that the referencing project targeted 4.5.1 and the referenced project 4.6.1. Changing 4.6.1 to 4.5.1 allowed the overall build to succeed.

1
  • 1
    Well, building a project at a time might not be necessary, but one thing is for sure: carefully look at the output window (of better yet copy/paste it to notepad and use Ctrl + F find) for a word "missing". It'not showing up in the errors list, but it sure as hell breaks your solution. -.- May 2, 2016 at 2:55
5

Nothing was working for me so I deleted the .suo file, restarted VS, cleaned the projected, and then the build would work.

5

I tried many things like restarting Visual Studio, cleaning and rebuilding the solution, restarting the PC, etc., but none of them worked for me. I was finally able to solve the problem by doing the following:

First of all, make sure all the projects in your solution (including tests) are targeting the same .NET version. Then:

  1. Save pending changes in the project and close Visual Studio

  2. Find the exact location from file explorer and find "obj" file and open it,

    enter image description here

  3. Then, delete all the included files (some files won't remove, it doesn't matter, just skip them).

  4. Use run command (by pressing Windows Key + R) and type "%temp%" and press enter to find temporary files.

  5. Finally, delete them all.

0
3

On other possibility is that Visual Studio needs to run as Administrator, this might be related to deploying to local IIS server or other deployment need.

3

Just for the sake of completion and maybe helping someone encountering the same error again in the future, I was using Mahapps metro interface and changed the XAML of one window, but forgot to change the partial class in the code-behind. In that case, the build failed without an error or warning, and I was able to find it out by increasing the verbosity of the output from the settings:

Error pane

output pane

0
1

In my case (VS 2019 v16.11.20), disabling Text Editor->C#->Advanced->Enable 'pull' diagnostics in the options solved the issue.

0

Double check for _underscore.aspx pages in your project.

I had a page and code-behind:

`myPage.aspx` and `myPage.aspx.vb`

when building the project, I'd get errors on the .aspx.vb page stating that properties defined on the .aspx page didn't exist, even though the page itself would build fine and there were NO OTHER ERRORS showing in the output (even with diagnostic level build output).

I then came across a page in the project that was named the same thing but with an underscore: _myPage.aspx - not sure where it came from, I deleted it, and the solution built fine.

Not the answer you're looking for? Browse other questions tagged or ask your own question.