188
votes

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 ==========
    
30
how do you know that your build is failing?Sam I am says Reinstate Monica
Is there anything in the output tab?Malice
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/…Maxim Kornilov
Have you tried restarting VS2010 or even rebooting your PC?comecme
@NahuelI. I got similar problem once again in another project, when I searched stackoverflow I got my own question back :-)Abhijeet

30 Answers

150
votes

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.

204
votes

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

Screenshot

65
votes
  • 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".
27
votes

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

24
votes

Delete .vs folder & restart VS, worked for me

enter image description here

9
votes

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.

6
votes

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.

5
votes

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

5
votes

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.

3
votes

Firstly "Clean the Solution" , then Rebuild soln.

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

Try these things, hope definitely works.

3
votes

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
votes

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

3
votes

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

3
votes

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.

3
votes

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

3
votes

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.

3
votes

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.

2
votes

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.

2
votes

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.

2
votes

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.

2
votes

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

1
votes

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

1
votes

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.

1
votes

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.

0
votes

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.

0
votes

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.

0
votes

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!

0
votes

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

0
votes

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

0
votes

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