Why Doesn’t My Visual Studio Solution Build? A Troubleshooting Guide

broken building

I’m pretty good at getting Visual Studio projects building correctly – I’m a bit of a Visual Studio whisperer. In one job I could get the ‘flag ship’ application up and running on a new machine in half the time of anyone else – that still meant half a day’s work. Strangely that’s not on my CV.

So here are the steps I go through to get a rogue project building in Visual Studio. These steps range from the basic to the bizarre. They are in the order I would do them and by following them I can pretty much get any Visual Studio project back on track. So put on your tin hat and let’s get that errant Visual Studio solution building.

Sanity Check

Before embarking on a full blown Visual Studio troubleshooting endeavour it’s best just to do a few simple checks.

Have you got latest code?

Everybody has wasted hours trying to get an old version of the code working. I still do it. The developer that sits opposite me still does it. My boss still does it. Don’t do it. Get the latest version of the code from your repository.

Does it build for other people in your team?

Just see if other people are having the same problem. If you have continuous build – check that is still working and running through cleanly. The code might not work for anyone. More illuminating – it might work for some at not others.


Every few weeks you will probably be faced with a non-building Visual Studio project. Here are some basic steps to help. These will probably be enough.

Clean and rebuild

clean solution

Go to

Solution Explorer -> Right Click -> Select Clean -> Wait -> Select rebuild

Often the bin directories have gone all wonky and are full of junk. Who knows what has happen to them. Clean and rebuild will refresh them and often work when a normal build doesn’t. Standard stuff – but then we are just beginning.

Build each project individually

Often you are faced with mountains of errors which is misleading. It could be one of your low level library projects that is failing to build and causing all other projects to fail. Rebuild each project individually starting with the low level ones that are dependencies for others. Sometimes that’s enough to get the entire solution building. At a minimum, you will better be able to see where the actual issue is and not be swamped by a heap of irrelevant error messages.

Close and reopen Visual Studio

It’s time to restart your Visual Studio. Don’t leave this till the end – it is often the problem. Turn it on and off again – it might help.

As a note – in my experience restarting your computer rarely helps. By all means try it but don’t be surprised when the solution still stubbornly refuses to build.

Manually delete all bin folders

This is really worth a try if you are working with an application with language variants. The language specific resource (e.g. Messages.fr-CH.resx) files compile down into satellite resource files in your bin folder that are contain in their own subfolder e.g.


Weirdly Visual Studio Clean can leave these satellite assemblies behind. Your application will still build but it can cause changes in languages variants not to shine through.

This might seem like an edge case but this exact thing kept a colleague of mine baffled for 6 hours. It was a very emotional moment when we finally sorted it out. So this is very much worth a try.

Start Visual Studio in admin mode

run as administrator

I’m master of my own machine (i.e. I’m a local admin) and I’ve got my Visual Studio set to always open as an administrator. You might not. Right click and run as administrator.

If it isn’t possible get someone who is an administrator to open Visual Studio on your behalf. Then complain bitterly about not being a local admin or your own machine – you are a developer; you really should be.

Have you got bad references?

bad references

Just check all projects and make sure that the references are all there. Look out for the little yellow triangle. If you have bad references then jump to section below dealing with that.

Check IIS

This isn’t relevant for all projects but if you are building a web project using IIS then it’s worth doing checks around that. Obviously it’s a completely legitimate setup to use IIS Express. In that case this isn’t relevant.

IIS pointing at the wrong folder

This is often a problem when changing branches. Visual Studio normally makes a good job of switching for you but not always. If you are hooked up to the wrong folder then your project will build but you won’t be able to debug it. Also changes that you are convinced you are made won’t shine through. This has driven me crazy before.

IIS explore folder

To check

  1. Open IIS (run -> inetmgr)
  2. Navigate to website
  3. Press explore and confirm you are where you think you should be. You might not be in Kanas anymore.

Permissions on app pool

This won’t manifest itself as a build failure but the project won’t be running as expected particularly when accessing external resources. It might be worth checking what the app pool is running as.


application pool settings

To check

  1. Open IIS (run -> inetmgr)
  2. Application Pool -> select the one for the website
  3. Advanced settings

You can now check the user.

The application pool runs under ApplicationPoolIdentity by default. What I’ve sometimes seen is that it’s been changed to a normal user whose password has expired. This is typically fallout from previous Visual Studio failures echoing through the ages.

Bad references

bad references

If you are noticing a yellow triangle on your project references then Visual Studio can’t find a dependency. Sometimes there is no yellow triangle and all looks fine but it still can’t find the dependencies.

With the advent of nuget this is less of a problem now but it does still happen. There are instances where incorrect use of nuget makes it worse and more baffling.

Check reference properties

Go to the references -> right click -> properties

references properties

There are two things to look for

  1. Is it pointing to where you think it should be? It might not be
  2. Copy Local. Bit of witchcraft but I always set this to copy local. It will copy the dll into the bin folder so at least I can satisfy myself that it has found it and is copying it through OK.

Have you checked in the packages folder – don’t!

Even if you are using nuget your bad reference problem might not be at an end. Checking in the packages folder can cause the references not to be found. This is especially baffling since looking at the reference properties reveals no problems. The path to the required dlls is definitely valid and the dlls are definitely there. But it cannot be found – frustration and finger biting.

To resolve delete the packages folder then remove the folder from source control. Rebuild and all will be well.

Resetting Visual Studio

Resetting Visual Studio can (probably will) cause your environment to lose all your custom defaults – so all your shortcuts, settings perhaps plugins will go. Therefore I’ve left this step towards the end as it is not without consequences. That said it is often the resolution so it’s not a bad idea to do it earlier in the ‘what on earth is going wrong with Visual Studio’ resolution process.

Delete all temporary and cache files

This was a fix that often worked in slightly older versions of Visual Studio. I’m using VS 2015 currently and this often isn’t a problem. Still it is worth clearing out these folders and rebuilding

C:\Users\{user name}\AppData\Local\Microsoft\WebsiteCache

C:\Users\{user name}\AppData\Local\Temp

Delete project setting files

Your user settings for a project are stored in files with the extension *.csproj.user i.e


It’s worth deleting all those and rebuilding so reset user specific settings. Also if you have these checked into source control then remove them. They are specific to you and shouldn’t be in a shared repository.

Reset Visual Studio on the command line

When Visual Studio appears utterly broken and you are reaching for the uninstall button, this can often help. It takes Visual Studio back to its initial settings you will need to reapply any custom settings that you have.

Close VS then in a command prompt go to the folder that has the Visual Studio.exe (devenv.exe) i.e.

cd C:\Program Files (x86)\Microsoft Visual Studio {Version code}\Common7\IDE

For VS 2015 it is

cd C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE


devenv /setup

Reopen visual studio

A similar approach can be used with devenv.exe /Resettings as detailed here.

Reset Visual Studio through file explorer

If the command line doesn’t work then try resetting Visual Studio via the file system. This often works when the command line doesn’t. Try this when Visual Studio is undergoing a profound collapse particularly when it keeps popping up an alert box detailing errors being written here…

C:\Users\{user name}\AppData\Roaming\Microsoft\VisualStudio\{VS version}\ActivityLog.xml

i.e. for Visual Studio 2013


To resolve for Visual Studio 2013

  1. Close VS
  2. Go to C:\Users\tbrown\AppData\Local\Microsoft\VisualStudio\12.0
  3. Rename the folder to C:\Users\tbrown\AppData\Local\Microsoft\VisualStudio\12.0.backup
  4. Reopen VS. The folder C:\Users\tbrown\AppData\Local\Microsoft\VisualStudio\12.0 will be regenerated.

The process is the same for other versions of Visual Studio except the version number at the end will be different i.e C:\Users\tbrown\AppData\Local\Microsoft\VisualStudio\14.0 for VS 2015.

Disable plugins

Leave this one till last because it’s a pain. Go to Tools -> Extensions and plugins. Then disable each plugin you can one by one.

disable plugin box

It’s a pain because even if it is a plugin that causes it, you have a choice of uninstalling and living without it or contacting the vendor. Clearly if you didn’t buy it then the vendor isn’t going to be interested in helping you. I’ve found PostSharp and Resharper the likely culprits here. The Resharper vendor was very helpful. PostSharp weren’t (because we hadn’t bought it!!).

Bizarre Ones

Be careful what you check in

Checking files into source control that you really shouldn’t can cause difficult to diagnose problems. This often happens to me for continuous builds where the user building has fewer privileges than I’m used to. It does happen locally too. The following files shouldn’t be checked in

  • Bin folders
  • Obj folders
  • Autogenerated xml (i.e. documentation generated during build)
  • Packages folder
  • .csproj.user files

If you have checked them in then delete from your disk, remove from source control and rebuild.

Is your file path too long

Windows limits the file path to 260 characters. It could be that you have exceeded this and Visual Studio has started to complain. The awkward thing is that it complains in a very oblique way. The error that you see will be something on the lines of…

“obj\Debug\LongFileName.cs” has an invalid name. The item metadata “%(FullPath)” cannot be applied to the path “obj\Debug\LongFileName.cs “. obj\Debug\\LongFileName.cs           ContainingProject.proj            C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets

So not obvious. Double click the error and it will take you to the Microsoft.Common.CurrentVersions.targets file in the depths of the framework folder. Less than illuminating.

Once you have diagnosed this then the resolution is easy – move your project to a shorter file path. I’ve found this a problem when switching branches which can have longer file paths than the Main branch.

If all else fails

If all else fails uninstall Visual Studio and reinstall. But honestly, I have reached this frustrating point, uninstalled, reinstalled, waited hours and the problem persists. This might not be the cure that you were looking for. Go into a corner and have a good long think before you resort to this one.

So congrats if you have read this far (or commiserations as your Visual Studio install is clearly in a bad way) but hopefully this guide will enable you to have a healthy and happy Visual Studio for years to come.

Useful Links

Good stack overflow explanation on why the 260 character filepath limit exists in windows.

Official advice from Microsoft about bad references.

There is a difference between Clean + Build and ReBuild as detailed here.

10 Beautiful Software Development Haikus

mount fuji

In my day job I send a lot of very routine emails announcing new deployments or pleading with people to fix the continuous build. I’ve started to amuse myself by sending them as haikus (3 line poems with 5, 7 then 5 syllabus on each line). I don’t think anyone has noticed. They just think I’m being a bit more terse than usual.

I this spirit I’m going to share with you 10 more beautiful haikus about software development. I’m sure you’ll agree that they capture the exquisite beauty of the software craft, the bittersweet sadness of an application crash and the inevitable fragility of a software patch to live. They are also short, don’t have to rhyme and are easy to write.

Traditional haiku collections are split into seasons. I’ll also split them but into categories that better juxtapose the joys and frustrations of the software development cycle.

Development Operations

Build server is slow
Disk whirs, lights flash but no builds
Request SSD

Test build being deployed
We wait for the build green line
Sadness. It’s amber

TFS build red
Queue the integration build
TFS still red

Build has been deployed
Is available for test
Please handle with care


SOLID principles
Still don’t know Liskov

Flakey code base
Instigate peer code reviews
No one has the time

Application crash
Detailed error report but
Where is the stack trace?

The Workplace

Corporate fruit bowl
Apples, bananas and plums
No-one eats kiwi

Our daily stand up
Managers attend. Involved,
But not committed

Professional Development

Personal dev blog
I watch the web traffic. Why?
I don’t really know

The Worst Thing About Microsoft Exams

Exam Upset I’ve long been a bit of a fan of Microsoft exams – shiny new exams that give the veneer of professionalism to a CV. Lovely. I did a fair number at the start of my career and a few thereafter. I’ve dined out on the knowledge gained for years. However there is a real risk being steered towards obsolete or just strange technology choices. From the last few exams I took here are just some examples of the odd/skewed/’never going to use’ technologies that the MS exam devotee might end up being steered towards.

Health Monitoring

web event hierarchyWith ASP.Net there is an extensive health monitoring architecture for your applications that you are never going to use. It’s got everything you need and much, much more – way too much more. I’ve never seen anyone use it and even the lead developer who implemented it admits it’s over-engineered.

Just 2 seconds looking at the above web event hierarchy makes my retinas ache. Every uses log4net, elmah or just rolls their own. Unfortunately it’s on every ASP.Net exam I’ve ever done (70-315, 70-551, 70-486) and you have to learn about it (sigh).

Lab Management

Lab management is a test environment provisioning architecture in Team Foundation Server. It forms a not insignificant portion of the TFS admin exam (70-496). It looks great and the books and videos are convincing. I was convinced it was a great idea and wanted to implement it and tried to convince others.

It turns out though this is not best practice for deployments at all. You should use the same method of promotion that you use into live. This is becoming more current with the advent of technologies such as Docker. Lab Management though is very particular and the deployment into lab management environments bears no relationship to deployment into production. None! It’s a pain to learn and it’s still on the exam (sigh).

App Fabric

A minor gripe now. In the MVC exam (70-486) the azure caching section steers you towards learning about App Fabric as a service bus for hybrid applications. Fine but turns out this technology is end of life and will be retired in 2017. But it’s still on the exam (sigh).

Windows Azure


azure vs aws

There is an entire exam track around Azure cloud computing and it’s a goodly portion of the MVC exam 70-486. Being a Microsoft exam devotee I imagined that Azure was THE cloud computing solution. I was surprised when I saw the above graph and realised that Amazon Web Services has way more implementations out there.

Azure is fine and interesting and good and healthy and I’m sure your mother approves of the use of it at the dinner table. But this is a textbook example of the MS exam narrowing your perspective and encouraging people (me) to ignore other potentially more viable alternatives. But it’s on the exams and you have to learn about it (sigh).

MSTest, Fakes and Shims

Unlike some of my other gripes, I do unit testing on a regular basis so it’s a drag to have to learn an alternative unit test framework for an exam that I’m unlikely to use. Maybe millions of developers use MSTest but I’ve never met them. I wish the exams were a bit more neutral with the choice of unit test technology but they predictably steer you towards Microsoft technologies. But it’s on the MVC exam so put on your big boy pants and learn about it (sigh).

But it’s all good really

Nothing is perfect. I’m not, the software I write isn’t and Microsoft exams aren’t. I still think they are great for developers at the start of a career – it gave me a boost and I still like to see them on developer CVs. It’s a good signal of career dedication. I’d much rather have a Microsoft exam than not. It just helps to be aware of their limitations.