Search code examples
compilationmsbuildcruisecontrol.net

MSbuild solution with referenced DLL from a project within the solution


I am trying to get our continuous integration server (cruise control .net) working with our solution. From cruisecontrol i call msbuild to build the solution and i'm running in some problems, let me explain the structure of the solution:

4 Projects:

  • DataAccess
  • BusinessEntity
  • BusinessLayer
  • (Project A)

Project A is the actual project with all the user forms etc. This project has references to the other 3 projects.

When compiling in Visual Studio, everything works of course.. From what i understand is that MSBuild works quite different from VS.

When building project A with msBuilds i get the following error:

C:\CI\Project A\Source\Project A\General.vb(859,33): error BC30007: Reference   required to assembly 'System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' containing the base class 'System.EnterpriseServices.ServicedComponent'. Add one to your project. [C:\CI\Setra\Source\Project A\Project A.vbproj]]]></message>

The funny thing is that Project A has no reference at all to the mentioned assembly. But the referenced DLL's in project A do have.

When i compile the other projects (those that generate the DLL's) with msbuild, the build succeeds.

I have the feeling it has something to do with the way the DLL's are referenced in the main project, but i can't seem to figure it out..

Any help or suggestions is greatly appreciated !!


Solution

  • This blogpost, despite being quite old, should answer your question. Some more useful info on how to approach this problem can be also found here.

    In general, MSBuild has problems resolving secondary, ternary etc. references directly. More up to date article can be found here. I haven't tested this approach, though it seems quite good and easy to implement at the first sight:

    Paste the following code into the file before the last tag:

    <Target Name="AfterResolveReferences">
        <!-- Redefine referencepath to add dependencies-->
        <ItemGroup>
            <ReferencePath Include="@(ReferenceDependencyPaths)"></ReferencePath>
        </ItemGroup>
    </Target>