4
votes

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

1 Answers

5
votes

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>