Question: I am trying to get the drop folder location for TFS within my MsBuild script for a particular project.

I have tried to use the $(DropLocation) property but this is empty. What is the best way to get the drop folder location used by TFS in an MSBuild script?

Answer: 
If you were using TFS 2013, you have the nice TF\_BUILD\_DROPLOCATION environment variable at hand, which you can use just like any property.

In 2012 and earlier, you can customize the TFS Build Template: pick the [BuildDetail.DropLocation](http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.build.server.builddetail.droplocation.aspx) property and pass the value to MSBuild. See [How to pass TFS variable to a MSBuild task of the project](https://stackoverflow.com/questions/9030328/how-to-pass-tfs-variable-to-a-msbuild-task-of-the-project) for details.

Use TF\_BUILD\_DROPLOCATION as property name so you code will work when you upgrade to TFS 2013.
(I did this in ts2010, still works with tfs2012)
add to your msbuild .proj, something like this

```
<Project DefaultTargets="SetEnv" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
  <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets" />

  <PropertyGroup>
    <TeamBuildRefPath Condition="'$(TeamBuildRefPath)'==''">$(PathToMyDevenv)\IDE</TeamBuildRefPath>
  </PropertyGroup>

```

then the $(DropLocation) becomes populated as you'd expect.

I've a feeling you only need the import, it's been a while since I did this. 

Cheers