locked
How to get TFS build to copy correctly referenced Assembly DLL? RRS feed

  • Question

  • I have a WCF Service project (MainService) that refences an Assembly DLL Version 1 in the project sub-folder /OldLibs/.  I have another project, a Service Host Project that references the Service project I mentioned first.  The DLL is copied correctly in the Visual Studio build but, when run through TFSBuild it copies the Version 2 of the DLL with the same name from a shared Binaries directory that is not referenced in the project.  Below is the structure of the project.

    HostService
     - References MainService

    MainService   
      /OldLibs/
        Assembly1.DLL - Version 1

               - Assembly1.DLL - Version 1 is referenced to /OldLibs/ in this project


    SharedBinaries
       Assembly1.DLL - Version 2

    Result:

      HostService
       /bin/
         Assembly1.DLL - Version 2 

      I would expect Assembly1.DLL - Version 1 to be copied to /bin/.

    Any thoughts?

    Wednesday, May 12, 2010 7:26 PM

Answers

  • Hi,

    How did you refer to the Assembly1.dll in HostService?

    When TFSBuild builds a project that has a assembly reference, it will try to get the reference in the  HintPath defined in the project file(*.csproj) first, then in GAC and additional reference path.

     <ItemGroup>
      <Reference Include="ClassLibrary, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>
       <HintPath>..\ref\ClassLibrary.dll</HintPath>
      </Reference>
      <Reference Include="System" />
      <Reference Include="System.Core">
       <RequiredTargetFramework>3.5</RequiredTargetFramework>
      </Reference>
      <Reference Include="System.Xml.Linq">
       <RequiredTargetFramework>3.5</RequiredTargetFramework>
      </Reference>
      <Reference Include="System.Data.DataSetExtensions">
       <RequiredTargetFramework>3.5</RequiredTargetFramework>
      </Reference>
      <Reference Include="System.Data" />
      <Reference Include="System.Xml" />
     </ItemGroup>

    In your scenario, TfsBuild failed to get the assembly1.dll in the path, so it got the one in shared folder.

    To fixed this,

    First, map HostService and MainService  in your workspace with the correct structure. So that when you refer to assembly1.dll, the project will use the relative path in  HintPath

    Then, make sure the workspace of the build definition is the same as your local structure.


    Best regards,
    Ruiz
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com
    Thursday, May 13, 2010 1:09 AM
    Moderator