$(TeamBuildConstants) is blank for TFS builds

元气小坏坏 提交于 2019-12-01 20:42:00

问题


I have a post build event like this:

if NOT "$(TeamBuildConstants)"=="_TEAM_BUILD_" "$(SolutionDir)Tools\NuGet.exe" pack "$(ProjectDir)MyAssembly.nuspec" -BasePath "$(ProjectDir)$(OutDir)."

if "$(TeamBuildConstants)"=="_TEAM_BUILD_" "$(SolutionDir)Tools\NuGet.exe" pack "$(ProjectDir)MyAssembly.nuspec" -BasePath "$(OutDir)."

When I build on in Visual Studio $(TeamBuildConstants) is blank (as it should be).

But when I build on my TFS 2010 Server, $(TeamBuildConstants) is still blank. What do I need to do to tell when I have a TFS Build running?


回答1:


Team Build

http://social.msdn.microsoft.com/Forums/en-US/tfsbuild/thread/618392e6-a108-4e70-898b-52ee6afc0600/

TeamBuild 2008 sets IsDesktopBuild=false for builds run by a build agent. The default (if not set on the command line or by a project property) is true. The TFS 2010 behavior is the same, so try something like:

<PostBuildEvent Condition=" '$(IsDesktopBuild)' == 'true' ">echo This is post-build</PostBuildEvent>

Although I have heard from some people that it doesn't work, and there is an alternative property - $(BuildingInsideVisualStudio) - which may work instead.

If neither work you may need to edit your Build Definition and customize the msbuild call yourself.

NuGet 1.6

NuGet 1.6 also has an msbuild file that can create nuget files which may be worth looking at.

snippet

<PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>
<BuildCommand>"$(NuGetExePath)" pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)" -symbols</BuildCommand>


来源:https://stackoverflow.com/questions/9134004/teambuildconstants-is-blank-for-tfs-builds

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