Ask a questionAsk a question
 

AnswerCreate separate drop folder for each solution

  • Friday, September 15, 2006 5:59 PMEsteban Garcia Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I have an integration build that builds all my solutions (about 15 of them).  I'd like to have my build drop the assemblies for each solution into it's own directory rather than dropping all the assemblies into one directory.  So I'm looking for something like this:

    Integration\Binaries\Solution1
        Assembly1.dll
        Assembly2.dll
        Assembly3.dll

    Integration\Binaries\Solution2
        Assembly4.dll
        Assembly5.dll
        Assembly6.dll

    Integration\Binaries\Solution3
        Assembly1.dll
        Assembly3.dll
        Assembly6.dll

Answers

  • Friday, September 15, 2006 8:14 PMAaron HallbergMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    This is a non-trivial task with the current targets file, unfortunately.

    You'll need to set the SkipDropBuild property to true (to skip the standard dropping of binaries) and then override the AfterDropBuild target to do what you are looking for.  You'll want to copy the binaries from their intermediate directories (e.g. <solution directory>\obj\debug) rather than their output directories, since you won't be able to distinguish which assemblies came from which solutions there. 

    You'll want to batch over the SolutionToBuild collection in some way, but it may be a bit tricky.  You'll need something like this:

     <Target Name="AfterDropBuild">

        <CreateItem Include="%(SolutionToBuild.RootDir)%(SolutionToBuild.Directory)\**\*.dll;%(SolutionToBuild.RootDir)%(SolutionToBuild.Directory)\**\*.exe" AdditionalMetadata="SolutionName=%(SolutionToBuild.Filename)">

            <Output ItemName="FilesToCopy" TaskParameter="Include" />

        </CreateItem>

        <Copy SourceFiles="@(FilesToCopy)" DestinationFiles="@(FilesToCopy ->'$(DropLocation)\$(BuildNumber)\Integration\Binaries\%(SolutionName)\%(RecursiveDir)%(Filename)%(Extension)')" />

    </Target>

    You'll need to include whatever other extensions you care about in the Include list.

    -Aaron

All Replies

  • Friday, September 15, 2006 8:14 PMAaron HallbergMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    This is a non-trivial task with the current targets file, unfortunately.

    You'll need to set the SkipDropBuild property to true (to skip the standard dropping of binaries) and then override the AfterDropBuild target to do what you are looking for.  You'll want to copy the binaries from their intermediate directories (e.g. <solution directory>\obj\debug) rather than their output directories, since you won't be able to distinguish which assemblies came from which solutions there. 

    You'll want to batch over the SolutionToBuild collection in some way, but it may be a bit tricky.  You'll need something like this:

     <Target Name="AfterDropBuild">

        <CreateItem Include="%(SolutionToBuild.RootDir)%(SolutionToBuild.Directory)\**\*.dll;%(SolutionToBuild.RootDir)%(SolutionToBuild.Directory)\**\*.exe" AdditionalMetadata="SolutionName=%(SolutionToBuild.Filename)">

            <Output ItemName="FilesToCopy" TaskParameter="Include" />

        </CreateItem>

        <Copy SourceFiles="@(FilesToCopy)" DestinationFiles="@(FilesToCopy ->'$(DropLocation)\$(BuildNumber)\Integration\Binaries\%(SolutionName)\%(RecursiveDir)%(Filename)%(Extension)')" />

    </Target>

    You'll need to include whatever other extensions you care about in the Include list.

    -Aaron