Question

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.

Was it helpful?

Solution 2

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>

OTHER TIPS

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?

In your build file, you can define a target for copying files:

<Target Name="CopySomeFiles">

    <ItemGroup>
        <SomeFiles Include="$(SourceFolder)\*.*"></SomeFiles>
    </ItemGroup>

    <Copy SourceFiles="@(SomeFiles)" DestinationFolder="$(DestFolder)"  SkipUnchangedFiles="false"/>

</Target>

You can then add this target where you want, e.g. after compile:

<Target Name="AfterCompile"
        DependsOnTargets="CopySomeFiles">
</Target>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top