[c#] How to find reason of failed Build without any error or warning

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

This question is related to c# asp.net .net visual-studio-2010

The answer is


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.


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.


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


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.


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.


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.


Delete .vs folder & restart VS, worked for me

enter image description here


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

Screenshot


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.


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.


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


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.


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

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


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


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


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


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.


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.


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.


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.


Firstly "Clean the Solution" , then Rebuild soln.

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

Try these things, hope definitely works.


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


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.


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.


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.


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!


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


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


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.


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.


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


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.


Examples related to c#

How can I convert this one line of ActionScript to C#? Microsoft Advertising SDK doesn't deliverer ads How to use a global array in C#? How to correctly write async method? C# - insert values from file into two arrays Uploading into folder in FTP? Are these methods thread safe? dotnet ef not found in .NET Core 3 HTTP Error 500.30 - ANCM In-Process Start Failure Best way to "push" into C# array

Examples related to asp.net

RegisterStartupScript from code behind not working when Update Panel is used You must add a reference to assembly 'netstandard, Version=2.0.0.0 No authenticationScheme was specified, and there was no DefaultChallengeScheme found with default authentification and custom authorization How to use log4net in Asp.net core 2.0 Visual Studio 2017 error: Unable to start program, An operation is not legal in the current state How to create roles in ASP.NET Core and assign them to users? How to handle Uncaught (in promise) DOMException: The play() request was interrupted by a call to pause() ASP.NET Core Web API Authentication Could not load file or assembly 'CrystalDecisions.ReportAppServer.CommLayer, Version=13.0.2000.0 WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for jquery

Examples related to .net

You must add a reference to assembly 'netstandard, Version=2.0.0.0 How to use Bootstrap 4 in ASP.NET Core No authenticationScheme was specified, and there was no DefaultChallengeScheme found with default authentification and custom authorization .net Core 2.0 - Package was restored using .NetFramework 4.6.1 instead of target framework .netCore 2.0. The package may not be fully compatible Update .NET web service to use TLS 1.2 EF Core add-migration Build Failed What is the difference between .NET Core and .NET Standard Class Library project types? Visual Studio 2017 - Could not load file or assembly 'System.Runtime, Version=4.1.0.0' or one of its dependencies Nuget connection attempt failed "Unable to load the service index for source" Token based authentication in Web API without any user interface

Examples related to visual-studio-2010

variable is not declared it may be inaccessible due to its protection level SSIS Excel Connection Manager failed to Connect to the Source This project references NuGet package(s) that are missing on this computer Gridview get Checkbox.Checked value error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in CppFile1.obj What is the difference between Visual Studio Express 2013 for Windows and Visual Studio Express 2013 for Windows Desktop? Attach (open) mdf file database with SQL Server Management Studio What is and how to fix System.TypeInitializationException error? Could not load file or assembly "Oracle.DataAccess" or one of its dependencies IIS error, Unable to start debugging on the webserver