Is there a single MSBuild and TFSBuild variable that will point to where the binaries are?

落爺英雄遲暮 提交于 2019-12-01 16:46:23

问题


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?

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.


回答1:


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

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

EDIT:

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


来源:https://stackoverflow.com/questions/9133375/is-there-a-single-msbuild-and-tfsbuild-variable-that-will-point-to-where-the-bin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!