3

How to configure TeamCity to build a solution with 2 projects?

I have configured TeamCity to build my solution which has 1 project which is chosen as Startup Project and it builds fine.

I configured it by adding a new Build Step with Runner Type of "Visual Studio (sln)" from its WebUI.

I added a new class library project and added a reference to it from the first project and it builds fine locally.

The .csproj file of the first project now contains this:

 <ItemGroup>
    <ProjectReference Include="..\ClassLibrary1\ClassLibrary1.csproj">
      <Project>{00E69E26-2576-4B9A-9180-CB1877B1D951}</Project>
      <Name>ClassLibrary1</Name>
    </ProjectReference>
  </ItemGroup>

I checked in the code and teamcity fails to build!

error CS0246: The type or namespace name 'ClassLibrary1' could not be found (are you missing a using directive or an assembly reference?) 

TeamCity seems to only build the startup project not the ClassLibrary1 although it's referenced.

How could I configure it to build my solution?

Would this be possible using the WebUI or I should be writing e.g. MSBuild scripts?

Thanks,

The Light
  • 26,341
  • 62
  • 176
  • 258

2 Answers2

3

Team City handles .sln files, so you should not have any problems with mutliple projects. Make Team City build the .sln files, not a csproj.

If it's already ok, check your reference to see if it points to the project within the solution or if it refers to the assembly file (might cause problem if you change your build configuration for example)

Your reference should look like this

<ProjectReference Include="..\ClassLibrary1\ClassLibrary1.csproj">
      <Project>{some guid identifying your project}</Project>
      <Name>ClassLibrary1</Name>
    </ProjectReference>

To have this result, the reference should be made by right clicking a project on solution explorer, choose add reference and go to the Project section

Cédric Rup
  • 15,468
  • 3
  • 39
  • 30
  • That's not what I see; I mean it doesn't seem to handle a solution file with multiple projects. I referenced the second project from the first project within the same solution. The references are correct, what else could be wrong? – The Light Jan 31 '12 at 12:57
  • Are you sure the reference is made to the project? Another possiblity would be that you forget to commit either your sln or a csproj to your source control – Cédric Rup Jan 31 '12 at 13:02
  • To verify, you can clean your solution, choose the Debug configuration and build. You should have the very same error message – Cédric Rup Jan 31 '12 at 13:10
  • Thanks for your comment. I removed and re-added the project and I can see the ProjectReference there. I changed the configuration from Release to Debug and tried again but still getting the same error message from TeamCity. Still not found what could be wrong... – The Light Jan 31 '12 at 14:53
  • I checked the ProjectReference line is in TFS, however, TeamCity doesn't export the latest version properly from TFS! TeamCity has cached the old csproj file and doesn't get the latest version from TFS! – The Light Jan 31 '12 at 15:01
3

Actually, the problem was TeamCity was caching because and the solution was to check the below check box from the Version Control Settings:

Agent checkout: Enforce overwrite all files

The reason it was caching was that I'm using the Checkout mode of "Automatically on server" which means it will cache: http://confluence.jetbrains.net/display/TCD65/VCS+Checkout+Mode

The Light
  • 26,341
  • 62
  • 176
  • 258