How can I get TFS 2010 to build each project to a separate directory?

后端 未结 9 913
忘掉有多难
忘掉有多难 2020-12-23 12:37

In our project, we\'d like to have our TFS build put each project into its own folder under the drop folder, instead of dropping all of the files into one flat structure. To

相关标签:
9条回答
  • 2020-12-23 13:02

    Here's a very simple solution that requires no modification to source files or project files. When setting up your build definition's Process -> Projects to Build, instead of specifying your .sln file in the projects to build, add each project (.csproj or .vbproj). Now inside the "Run MSBuild for Project" step of your workflow, change the OutDir property to the following:

    outputDirectory + "/" + serverBuildProjectItem.Substring(serverBuildProjectItem.LastIndexOf("/"), serverBuildProjectItem.Length - serverBuildProjectItem.LastIndexOf("/")).Replace(".csproj", String.Empty)
    

    This will place each project's build output in to a subdirectory named after the project.

    0 讨论(0)
  • 2020-12-23 13:05

    I figured out a nice way to do it. It turns out that since you can set the OutDir to whatever you want within the workflow, if you set it to the empty string, MSBuild will instead use the project-specific OutputPath. That lets us be a lot more flexible. Here's my entire solution (based on the default build workflow):

    In the Run MSBuild task, set OutDir to the empty string. In that same task, set your CommandLineArguments to something like the following. This will allow you to have a reference to the TFS default OutDir from your project:

    String.Format("/p:CommonOutputPath=""{0}\\""", outputDirectory)
    

    In each project you want copied to the drop folder, set the OutputPath like so:

    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
        <OutputPath Condition=" '$(CommonOutputPath)'=='' ">bin\Release\</OutputPath>
        <OutputPath Condition=" '$(CommonOutputPath)'!='' ">$(CommonOutputPath)YourProjectName\bin\Release\</OutputPath>
    </PropertyGroup>
    

    Check everything in, and you should have a working build that deploys each of your projects to its own folder under the drop folder.

    0 讨论(0)
  • 2020-12-23 13:14

    The steps here don't require a project file modification - http://lajak.wordpress.com/2011/05/07/customize-binaries-folder-in-tfs-team-build/

    0 讨论(0)
提交回复
热议问题