7

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.

Vaccano
  • 78,325
  • 149
  • 468
  • 850

1 Answers1

8

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)
)
Michael Edenfield
  • 28,070
  • 4
  • 86
  • 117
  • But outdir is relative. I would really like a full path. If you have projects in sub directories in your solution then a relative path becomes difficult to use. – Vaccano Feb 03 '12 at 18:17
  • I'm not sure exactly where you need to use this property so it's hard to give you a better answer; in a post-build event, for example, the property will be relative to whatever project is running. I'll update my answer with a way to get a full path in either case. – Michael Edenfield Feb 03 '12 at 18:40