是否有一个MSBuild和TFSBuild变量指向二进制文件所在的位置? [英] Is there a single MSBuild and TFSBuild variable that will point to where the binaries are?

查看:70
本文介绍了是否有一个MSBuild和TFSBuild变量指向二进制文件所在的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否存在可以始终指向二进制文件所在位置的Visual Studio构建或TFS构建中使用的属性?

Is there there a property that can be used in either a Visual Studio build or a TFS build that will always point to where the binaries are?

意味着,当我在Visual Studio中构建时,它将指向 C:\ MySolution \ MyProject \ bin \ Release ,而在TFS Build中,它将指向 C:\ Build \ Path \ MySoution \ Binaries

Meaning that when I build in Visual Studio it will point to C:\MySolution\MyProject\bin\Release and in a TFS Build it will point to C:\Build\Path\MySoution\Binaries

如果没有一个,为什么不呢?这似乎是一个常见的基本需求/功能.

And if there is not one, why not? This seems like a common, basic need/feature.

推荐答案

有一个$OutDir属性,您可以在生成后事件中使用它.

There is an $OutDir property, which you can use in things like post-build events.

在VS2010版本中,它将是从当前项目到二进制文件的相对路径,因此它将是"bin \ Debug \". (输出的完整路径是$ TargetDir,即$(ProjectDir)\ $(Outdir).)

In a VS2010 build, it will be a relative path from the current project to the binaries, so it will be "bin\Debug\" for example. (The full path to the output is $TargetDir, which is $(ProjectDir)\$(Outdir)).

$ OutDir在TFS构建期间被覆盖,以指向将二进制文件放入其中的路径:

$OutDir is overriden during TFS builds to point to the path where it puts your binaries:

 <OutDir Condition=" '%(ConfigurationToBuild.PlatformToBuild)' != 'Any CPU' ">$(BinariesRoot)\%(ConfigurationToBuild.PlatformToBuild)\%(ConfigurationToBuild.FlavorToBuild)\</OutDir>
 <OutDir Condition=" '%(ConfigurationToBuild.PlatformToBuild)' == 'Any CPU' ">$(BinariesRoot)\%(ConfigurationToBuild.FlavorToBuild)\</OutDir>

无论哪种情况,要获取完整路径,您可以使用以下一种方法:

To get a full path in either case, one option you could use is something like this:

IF '$(BuildingInsideVisualStudio)'=='true' (
  COPY SomeFile $(TargetDir)$(OutDir)
) ELSE (
  COPY SomeFile $(OutDir)
)

这篇关于是否有一个MSBuild和TFSBuild变量指向二进制文件所在的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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