3
votes

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,

2

2 Answers

3
votes

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

3
votes

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