[MSBuild output] CSC : fatal error CS2008: No inputs specified

Today I was setting up an automated build using TeamCity and came across an issue where the build of the solution kept failing.  The only reason that was given was this:

[MSBuild output] CSC : fatal error CS2008: No inputs specified

Turns out that MSBuild actually fails the whole build when you’re running it from the command line like this if there’s not a file that it can build.  The project in question was actually just full of XML and configuration files that other projects referenced and got published with a NuGet package to our private feed.  To fix it, I just added a simple .cs file, so that MSBuild had something to do.  :)

Here’s the code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Configuration
{
class MSBuildBugFix
{
// MSBuild has a bug where if no source files are found, the build fails when
// running from the commandline (or in our case, TeamCity). This file is only here
// to allow the build to complete.
}
}

 

Ryan Hayes

Ryan is a Microsoft MVP award winner with over eight years of software experience, working with big-name clients such as Discovery Channel, AOL, Toyota, and the National Academy of Sciences. Ryan has helped teams deliver award-winning applications that drive business processes, site traffic, and profit, putting his experience and creativity to work to build amazing solutions for the enterprise web, desktop and mobile platforms.