44

We get the above error message on our build server, when we build the solution or the specific project that the error refers to.

We can build the solution without any problem using visual studio (also on the build server), however it fails with the above error when running msbuild.

Any Ideas?

Ruben Bartelink
  • 59,778
  • 26
  • 187
  • 249
Shiraz Bhaiji
  • 64,065
  • 34
  • 143
  • 252

4 Answers4

45

I found the solution.

There is a "bug" in msbuild, that results in it failing when there are not source files in the project. For example Filename.cs.

Our project only had xml and other file types.

Just added an empty cs file and it worked.

Shiraz Bhaiji
  • 64,065
  • 34
  • 143
  • 252
  • +1 (I came here looking for a better answer, but I guess if this is all we can get, so be it!). Still present in 3.5 SP1. MS people not busy waiting for Connect to refresh, please note! – Ruben Bartelink Feb 26 '10 at 09:25
  • I had to add a main method in my empty class, I guess the person that added the project made it a console app. – aceinthehole Sep 14 '10 at 20:09
  • 4
    just make sure in the empty .cs file you put a comment/link to this question - or someone in the future is going to be equally confused! – Simon_Weaver Nov 10 '10 at 11:22
  • 6
    Downvoted as this is not the best way to solve this problem, an empty class solves nothing and creates a class in a namespace that is simply not required, the correct way to overcome this is to create an assembly info as described below. – krystan honour Aug 05 '11 at 13:37
44

You should add assembly info to the project. This evades the need to create an empty class file.

To create an assembly info file easily, open the project properties, select the application tab, click "Assembly Information", and enter appropriate data. This will automatically create the assemblyinfo.cs file in the appropriate location.

barneco
  • 536
  • 3
  • 11
ranthonissen
  • 1,464
  • 15
  • 16
9

I also got this error message when "building" a project which didn't have any *.cs files...but we do that fairly often for SharePoint projects which are just XML. the VS project is just to organize some of the XML documents. Long story short the problem was that there was AssemblyInfo.cs file. After adding some assembly info to the project properties, voila! It worked. So I guess, yes, you need a .cs file to actually compile anything, but the AssemblyInfo.cs is enough.

MarloBello
  • 231
  • 3
  • 5
  • This is a better way to solve the problem however perhaps we shouldn't use .csproj files in the first place to organise this content in general – krystan honour Aug 05 '11 at 13:38
6

I had the same error with a project that does not have any .cs files. I solved it by adding the following section to the corresponding .csproj-file:

  <PropertyGroup>
    <CoreBuildDependsOn>
    </CoreBuildDependsOn>
  </PropertyGroup>

This way the project will not be built, and there will be no build-output (no DLL is created) Works on both VS and TFS.