如何让 TFS 2010 将每个项目构建到单独的目录? [英] How can I get TFS 2010 to build each project to a separate directory?

查看:21
本文介绍了如何让 TFS 2010 将每个项目构建到单独的目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的项目中,我们希望我们的 TFS 构建将每个项目放入 drop 文件夹下的自己的文件夹中,而不是将所有文件放入一个平面结构中.为了说明这一点,我们希望看到这样的内容:

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 illustrate, we'd like to see something like this:

DropFolder/
  Foo/
    foo.exe
  Bar/
    bar.dll
  Baz
    baz.dll

这与问的问题基本相同 此处,但现在我们使用的是基于工作流的构建,这些解决方案似乎不起作用.使用 CustomizableOutDir 属性的解决方案看起来最适合我们,但我无法识别该属性.我自定义了我们的工作流,将它作为命令行参数传递给 MSBuild (/p:CustomizableOutDir=true),但似乎 MSBuild 只是忽略了它并将输出放入工作流给出的 OutDir.

This is basically the same question as was asked here, but now that we're using workflow-based builds, those solutions don't seem to work. The solution using the CustomizableOutDir property looked like it would work best for us, but I can't get that property to be recognized. I customized our workflow to pass it in to MSBuild as a command line argument (/p:CustomizableOutDir=true), but it seems MSBuild just ignores it and puts the output into the OutDir given by the workflow.

我查看了构建日志,我可以看到 CustomizableOutDir 和 OutDir 属性都在命令行参数中设置为 MSBuild.我仍然需要传入 OutDir,以便我可以在最后将我的文件复制到 TeamBuildOutDir.

I looked at the build logs, and I can see that the CustomizableOutDir and OutDir properties are both getting set in the command line args to MSBuild. I still need OutDir to be passed in so that I can copy my files to TeamBuildOutDir at the end.

知道为什么我的 CustomizableOutDir 参数没有被识别,或者是否有更好的方法来实现这一点?

Any idea why my CustomizableOutDir parameter isn't getting recognized, or if there's a better way to achieve this?

推荐答案

我想出了一个很好的方法.事实证明,由于您可以在工作流中将 OutDir 设置为您想要的任何内容,如果您将其设置为空字符串,MSBuild 将改为使用特定于项目的 OutputPath.这让我们变得更加灵活.这是我的整个解决方案(基于默认构建工作流程):

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):

在运行 MSBuild 任务中,将 OutDir 设置为空字符串.在同一个任务中,将您的 CommandLineArguments 设置为如下所示.这将允许您从项目中引用 TFS 默认的 OutDir:

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)

在要复制到放置文件夹的每个项目中,像这样设置 OutputPath:

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

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <OutputPath Condition=" '$(CommonOutputPath)'=='' ">binRelease</OutputPath>
    <OutputPath Condition=" '$(CommonOutputPath)'!='' ">$(CommonOutputPath)YourProjectNameinRelease</OutputPath>
</PropertyGroup>

检查所有内容,您应该有一个工作构建,它将您的每个项目部署到 drop 文件夹下的自己的文件夹中.

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

这篇关于如何让 TFS 2010 将每个项目构建到单独的目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆