182

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?

EDIT:

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 ==========
    
Leniel Maccaferri
  • 94,281
  • 40
  • 348
  • 451
Abhijeet
  • 12,062
  • 24
  • 73
  • 149
  • 5
    how do you know that your build is failing? – Sam I am says Reinstate Monica Nov 05 '12 at 19:53
  • @SamIam Updated question to indicate this. – Abhijeet Nov 05 '12 at 20:13
  • 5
    Is there anything in the output tab? – Malice Nov 05 '12 at 20:16
  • @Malice It includes configuration details. ------ Build started: Project: Configuration: Debug Any CPU ------ – Abhijeet Nov 05 '12 at 20:19
  • 16
    Try to increase verbosity of the Output Window in Visual Studio. It can help to determine the problem. How to increase verbosity level: http://blogs.msdn.com/b/saraford/archive/2008/10/07/did-you-know-you-can-configure-the-msbuild-verbosity-in-the-output-window-329.aspx – Maxim Kornilov Nov 05 '12 at 20:20
  • 6
    Have you tried restarting VS2010 or even rebooting your PC? – comecme Nov 05 '12 at 20:24
  • @autrevo: There might be something in your computer's event log. See http://www.neovolve.com/post/2010/09/10/TFS-Build-fails-for-no-indicated-reason-with-code-contracts-in-test-assemblies.aspx for more information. – Malice Nov 05 '12 at 20:35
  • Or try to clean you solution and rebuild all, then run it. – DJ Burb Nov 05 '12 at 20:55
  • @MaximKornilov I did increase verbosity to Diagnostic mode. But couldn't find much useful info. – Abhijeet Nov 06 '12 at 15:19
  • It's been two years since the original post, given that you modified the question 3 minutes ago, do you still have the problem? – Nahuel Ianni May 21 '14 at 11:11
  • 3
    @NahuelI. I got similar problem once again in another project, when I searched stackoverflow I got my own question back :-) – Abhijeet May 21 '14 at 11:34
  • @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 '14 at 11:35
  • @Abhijeet Just to try stuff, did you try closing VS, deleting the bin and obj folder, opening VS and compiling again? – Nahuel Ianni May 22 '14 at 08:16
  • 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 '14 at 20:23
  • @Abhijeet Did you find the solution and if - what is it? – f470071 Nov 06 '15 at 13:46

34 Answers34

195

Build + Intellisense swallowed the error messages. Selecting Build Only displayed them.

Screenshot

Abu Abdullah
  • 2,414
  • 1
  • 15
  • 15
148

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 > 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.

Richard J Foster
  • 3,878
  • 2
  • 27
  • 40
  • 3
    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 04 '16 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 '17 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 – Renat Khabibulin Jun 29 '17 at 08: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 '19 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 01 '20 at 21:29
  • @RenatKhabibulin For my `VS2019`, just closing and restarting the `VS2019` worked. – nam Nov 16 '20 at 17:13
65
  • If solution contains more than one project, try building them one at a time.
  • Try restart Visual Studio.
  • Try restart Computer.
  • Try "Rebuild all"
  • Try "Clean Solution" then remove your "vspscc" files and "vssscc" files and then restart Visual Studio and then "Rebuild All".
Hakan Fıstık
  • 11,376
  • 8
  • 74
  • 105
Sasse
  • 1,028
  • 10
  • 14
27

VS (2013 Pro, Win 8.1) restart did it for me.

Ignas Vyšnia
  • 1,910
  • 1
  • 14
  • 15
23

Delete .vs folder & restart VS, worked for me

enter image description here

Arun Prasad E S
  • 7,342
  • 6
  • 61
  • 75
  • It's worth noting [what is actually in this folder](https://stackoverflow.com/a/56586164/542251) – Liam Nov 16 '20 at 09:03
  • @Liam a lot of things, like cache, configuration settings etc. https://stackoverflow.com/a/48897202/5237614 – Arun Prasad E S Nov 16 '20 at 14:28
  • 1
    that is what i was looking for. project is not building after changes because of this folder – Svet Nov 18 '20 at 02:28
9

I want to expand on Sasse's answer.

To fix the problem with Visual Studio 2015 Update 2 I had to build each project one at a time and look at the output window after each build.

One project gave me

"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.

Community
  • 1
  • 1
user764754
  • 3,053
  • 2
  • 34
  • 46
  • 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. -.- – Dovydas Navickas May 02 '16 at 02:55
6

Seems that there are multiple answers to this question, so I'll add mine from personal experience hoping it will save someone time/stress.

Make sure all the projects in your solution are targeting the same .NET version.

Similar to OP, there were 0 errors but the build kept failing. However, there was one warning entry (buried in between several hundred useless XML warnings...) saying that one project was targeting a different .NET version than a project that was referencing it. The entire issue was that one project within my solution was targeting .NET 4.5.2, when the rest were targeting 4.5.1. It should work even with this discrepancy (hence why it was just a warning) but unfortunately, it broke the build.

The strange part was that it built/ran fine for a while, but suddenly the build started failing one time causing this issue. Not sure what I did for it to start complaining about differing .NET target versions, but I feel that there are just some mysteries in Visual Studio that will never be solved.

Alan Thomas
  • 868
  • 2
  • 13
  • 30
  • 1
    Turns out I'd added a new project and it had a different .Net target framework version - I fixed that and, although the build still failed, I was then able to see the error that was breaking the build. Thanks. – Fijjit Nov 04 '16 at 15:23
5

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

Andy
  • 92
  • 1
  • 4
5

I have faced the same issue recently, I also tried so many things like, restart Visual Studio, Clean and rebuild Solution, restart PC etc. (First of all make sure all the projects in your solution are targeting the same .NET version.)

But apparently nothing worked for me so I followed the below procedure;

  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

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

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

  3. Finally, delete them all.

This worked for me, hopefully it works for your case.

Dun0523
  • 608
  • 10
  • 19
MrMalith
  • 832
  • 8
  • 20
3

Firstly "Clean the Solution" , then Rebuild soln.

If won't work close the Solution and restart the solution.

Try these things, hope definitely works.

Santosh K
  • 45
  • 4
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.

Bill Yang
  • 1,342
  • 16
  • 27
3

this can happen when one of the projects referenced is a higher version of the .NET framework than your current project.

mcmillab
  • 2,672
  • 2
  • 19
  • 32
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

mcy
  • 988
  • 4
  • 22
  • 30
3

I had this same problem and I traced this issue down to the Error List options "Build + Intellisense".

If this option is selected then no errors are shown in the list. Switch to "Build Only" and the errors appear as expected.

Its look like a bug in Visual Studio. Restarting the visual studio solved this issue.

Christlin Panneer
  • 1,345
  • 1
  • 13
  • 26
3

Go to output window , search for 'error' in output window, TADA

Mahdi Khalili
  • 763
  • 9
  • 25
3

Try building your project from the Powershell command line:

dotnet build

Then you can see any errors in the command line output even if Visual Studio is playing hide and seek with build error messages.

user3810867
  • 96
  • 1
  • 6
  • Wow this command showed the error which building inside VS didn't so I've been able to solve the error. The question now is why VS doesn't report the error while this command does – Marc Roussel Feb 25 '21 at 19:07
3

For me, the Target Framework was the issue.

My project's Target Framework was 4.5.2 and the referenced project's Target Framework was 4.6.1.

Once I updated my project's Target Framework to 4.6.1, the issue got fixed.

Ankush Jain
  • 3,773
  • 3
  • 21
  • 42
  • Thanks! If you don't find the specific error but suspect this is the issue, you can try changing the project's TF to a higher one. That was it in my case. – Mariano Luis Villa Sep 18 '20 at 15:53
2

I had a similar problem after adding a new project (called "TestCleaner") to my solution: Build failed, no errors.

I increased output verbosity (see Richard J Foster's instructions) and searched the output for "failed". I quickly discovered which project was failing, and why: project "TestRunner" had failed with "error CS0246: The type or namespace name 'TestCleaner' could not be found" (even though no problems were highlighted in the code).

Checking TestRunner's references, sure enough the reference to TestCleaner was marked as unresolved, and the path was missing from the reference properties. Deleting and re-adding didn't fix it. Again, no explanation why.

unresolved reference

I finally discovered the cause: "TestCleaner" was using a different target framework to the other projects. It was .Net 4.5.2; the others were 4.5.

Ben Whitmore
  • 724
  • 4
  • 10
2

I had the same problem. The error list window has 2 dropdowns "Show items contained by" and "Show issues generated". These names are visible after hovering over the dropdown. The "Show issues generated" dropdown was set to "Build + IntelliSense" and after changing to "Build Only" the errors appeared on the list.

jakubiszon
  • 1,956
  • 1
  • 19
  • 33
2

In my case I set Diagnostic for the MSBuild verbosity as shown here.

Guess what... in the last line of the Output window in Visual Studio it showed this:

2>"C:\Company\Project\project.sharded\Project\Project.csproj" (Rebuild;BuiltProjectOutputGroup;BuiltProjectOutputGroupDependencies;DebugSymbolsProjectOutputGroup;DebugSymbolsProjectOutputGroupDependencies;DocumentationProjectOutputGroup;DocumentationProjectOutputGroupDependencies;SatelliteDllsProjectOutputGroup;SatelliteDllsProjectOutputGroupDependencies;SGenFilesOutputGroup;SGenFilesOutputGroupDependencies target) (1) ->
2>(CoreCompile target) -> 
2>  C:\Company\Project\project.sharded\Project\Services\UserService.cs(387,59,387,62): error CS0136: A local or parameter named 'sut' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter
2>
2>    2147 Warning(s)
2>    1 Error(s)

This looks like a bug in Visual Studio 2019 (16.3.5).

No errors were shown in the Error List window in Visual Studio.

This is the kind of errors that generally appear in the Error List window.

This is the offending line:

var sut = _sdb.SysUsableThreads.SingleOrDefault(sut => sut.uid == thread.uid && sut.thread_core == thread.core);

OK. Can't use sut because the var is named sut and I named the lambda sut. Again, this is the kind of thing that should be displayed in the Error List. For sure this is a bug in Visual Studio 2019. I reported it inside Visual Studio.

Leniel Maccaferri
  • 94,281
  • 40
  • 348
  • 451
  • I had the same issue with Visual Studio 2019 showing the number of errors in the build diagnostics but not in the Error List. I was able to see errors in the error list by opening the project with Visual Studio 2017 – AAV Jan 11 '21 at 19:53
2

With Visual Studio 2019, I had to 'Run as as administrator' and it finally built ok. So open the application as admin (right mouse click- run as Administrator).

JaganY
  • 73
  • 4
1

I faced the same problem! Just delete bin folder and restart your VS. That's all. tested in VS 2013.

Nur Uddin
  • 1,328
  • 20
  • 35
  • When I attempted to resolve this by deleting bin and obj folder it fixed it. Also I required admin rights to delete the obj folder so something very strange had happened. – DAG Jun 30 '20 at 20:57
1

What solved it for me was deleting the .vs folder from the root of the solution and restarting Visual Studio.

Also maybe important to say that even though the errors were not showing in the Error List pane, they were still present in the Output from the Build.

Ronald Rey
  • 524
  • 7
  • 8
1

On my side, i got this problem when i added a new project (Library)

How i solved it

Right click the new added Library go to Properties then Application, under Application change the Target Framework to the framework of all projects.

The problem is that you have project using different target frameworks.

Shonie
  • 77
  • 8
0

This happened to me after adding a new page to an asp.net project.

What I did was exclude the page, get it to build again successfully.

Then I added back the page with all the code commented out. Success.

Then I uncommented the code bit by bit and then it all worked.

toddmo
  • 16,852
  • 9
  • 86
  • 91
0

I had the same problem after deleting a couple of forms. The errors popped up once I went into the code and did a "Show Definition" for one of the controls that I removed.

I was also targeting a higher framework on one of my projects, so that might have been the issue as well.

Dennis Kuypers
  • 561
  • 5
  • 16
0

I've tried all but nothing worked in my case then I've changed these mentioned settings which resolved the issue quite well for me. Try If it could of any help latter viewers. These settings could be vary in your situation but make sure build all the including DLLs with the same config settings you kept initially (mentioned in the image.). Configuration Settings

Image here.

Cheers!

Iqra.
  • 423
  • 1
  • 4
  • 14
0

If nuget package 'Microsoft.Net.Compilers' is installed, make sure that it suits version of your Visual Studio (Build Tools version).

Versions 1.x mean C# 6.0 (Visual Studio 2015 and updates). For instance, 1.3.2

So don't upgrade to version above 1.x if you use VS2015

https://stackoverflow.com/a/44397905/3862615

Roman M
  • 333
  • 1
  • 3
  • 11
0

I had really old project on older machine. Project was building correctly when I turned off machine. Today, I am getting build error but no error message. After trying some of suggestion from above, no luck.

In Visual Studio 2015, I turned on Detailed MSBuild under TOOLS > Options > Projects and Solutions > Build and Run

It gave me few details about build but no errors. After that I tried to check Extensions and updates (Tools > Extension and Updates) and found few of them needed update.

Nuget Package was culprit, after updating Nuget - build is successful.

enter image description here

spicet
  • 511
  • 4
  • 9
0

It's may be due difference reportviewer version in your project and VS

Roohi Ali
  • 375
  • 3
  • 6
0

Since everything did not work, found that errors don't show when opening the project as solution (.sln), while the error shows when opening the project as a project.

Mosta
  • 569
  • 5
  • 18
0

I had the same issue, I changed Tools -> Options -> Projects and Solutions/Build and Run -> MSBuild project build log file verbosity[Diagnostic]. This option shows error in log, due to some reasons my VS not showing Error in Errors tab!

enter image description here

Do above settings and in output copy in notepad/texteditor and search for error. It will show you all errors.

Jenish Zinzuvadiya
  • 803
  • 2
  • 14
  • 28
0

Restarting the Visual Studio worked for me. Also try restarting Visual Studio normally (Not Run as Administrator). Try Restarting the System and repeat above step.

Juned Khan Momin
  • 2,028
  • 10
  • 30
0

A different way to reproduce this symptom:

I added a new project to an existing solution and the build output reported errors like "the type or namespace name X could not be found..." but no errors were presented in the error list.

The classes I referred to were in other projects (that were referenced) in the same solution.

It turned out that I by mistake had selected an earlier version of .net in the new project. Once I changed to the same version as the other projects, everything built without any errors.

Devosaur
  • 31
  • 3