Tuesday, March 8, 2011

TFS 2010 Build: Keep folder tree structure

There are two approaches :
=============================================
Approach 1
=============================================

To keep the output structure, you have to make TFSBuildHost not pass OutDir
to MSBuild and  custom the output path of each project.
  1. Open the build process file, navigate to Compile the Project Sequence, edit the property of Run MSBuild for Project Activity.
    • Set OutDir to empty (just make the textbox is empty)
    • set CommandLineArguments to String.Format("/p:SkipInvalidConfigurations=true {0} /p:TeamBuildOutDir=""{1}""", MSBuildArguments, outputDirectory)
  2. Modify each project file in the solution.
    • Check out project file to Edit.
    • Open project file  with notepad.
    • Find <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
    • Use following code to replace the default OutputPath Property.
                   <OutputPath Condition=" '$(TeamBuildOutDir)'=='' ">bin\release\</OutputPath>
                   <OutputPath Condition=" '$(TeamBuildOUtDir)'!='' ">$(TeamBuildOutDir)\<ProjectName>\</OutputPath>
                  The word “Release|AnyCPU” is dependent on the value of “ConfigrationToBuild”  in   TFSBuild.proj.      
    • Save project file and check in.
=============================================
Approach 2
=============================================
  1. Open the build process file, navigate to Compile the Project Sequence, edit the property of Run MSBuild for Project Activity.
  2. Set OutDir to empty (just make the textbox is empty)
  3. Set OutDir to System.IO.Path.Combine(outputDirectory, System.IO.Path.GetFileNameWithoutExtension(localProject))
  4. In the build definition, instead of specifying a single solution, specify the projects individually

No comments:

Post a Comment