Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get static content to copy to TFS Build Drop location

I'm using TFS 2013 / VS 2013.

For various reasons, I need some static content copied to a TFS build drop location. I've created a custom project type that simply copies a directory structure/files to an output path.

I would expect that TFS would then take everything in the output path and copy it to the drop location, but it's not. No files from my project show up in the drop location.

Here is my proj file:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <OutputPath>db\</OutputPath>
  </PropertyGroup>
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <Target Name="Build">
    <Copy SourceFiles="@(Content)" DestinationFiles="@(Content->'$(OutputPath)%(RelativeDir)%(Filename)%(Extension)')" />
  </Target>
  <Target Name="Clean">
    <Exec Command="rd /s /q $(OutputPath)" Condition="Exists($(OutputPath))" />
  </Target>
  <Target Name="Rebuild" DependsOnTargets="Clean;Build" />
  <ItemGroup>
    <Content Include="**\*.*" Exclude="db\**\*.*;*.csproj;*.rgdbproj;*.vspscc" />
  </ItemGroup>
</Project>

When I build this in Visual Studio, I get the desired directory structure to appear in the /db folder.

like image 390
RMD Avatar asked Jan 01 '26 00:01

RMD


2 Answers

In TFS 2013 you can specify a pre-build and post-build script. You can run PowerShell scripts to copy the files. See below question on how to do it. You will have to use TfvcTemplate.12.xaml for that.

Where can we open the `Post-build script` box of a build process template?

like image 88
Adarsh Shah Avatar answered Jan 03 '26 17:01

Adarsh Shah


I was able to resolve this issue by changing all my references from OutputPath to OutDir. Apparently, OutputPath is deprecated and OutDir is what TFS Build pays attention to. Here is my final build script:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <OutputPath>db\</OutputPath>
    <OutDir>db\</OutDir>
  </PropertyGroup>
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <Target Name="Build">
    <Copy SourceFiles="@(Content)" DestinationFiles="@(Content->'$(OutDir)%(RelativeDir)%(Filename)%(Extension)')" />
  </Target>
  <Target Name="Clean">
    <Exec Command="rd /s /q $(OutDir)" Condition="Exists($(OutDir))" />
  </Target>
  <Target Name="Rebuild" DependsOnTargets="Clean;Build" />
  <ItemGroup>
    <Content Include="**\*.*" Exclude="db\**\*.*;*.csproj;*.rgdbproj;*.vspscc" />
  </ItemGroup>
</Project>
like image 26
RMD Avatar answered Jan 03 '26 16:01

RMD



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!