3

I need to include a folder and the files in it into the deployment process.This folder isn't part of the project. This folder is created on the build server. I cannot include this files in the project.

I found this answer very helpful.

I've edited my web application csproj file and added this to the end of the file

  <PropertyGroup>
    <CopyAllFilesToSingleFolderForPackageDependsOn>CustomCollectFiles;$(CopyAllFilesToSingleFolderForPackageDependsOn);</CopyAllFilesToSingleFolderForPackageDependsOn>
    <CopyAllFilesToSingleFolderForMsdeployDependsOn>CustomCollectFiles;$(CopyAllFilesToSingleFolderForPackageDependsOn);</CopyAllFilesToSingleFolderForMsdeployDependsOn>   
  </PropertyGroup>

  <Target Name="CustomCollectFiles">
    <ItemGroup> 
      <_CustomFiles Include="Workspace\build\**\*" />
      <FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
        <DestinationRelativePath>Workspace\build</DestinationRelativePath>
      </FilesForPackagingFromProject>
    </ItemGroup>
  </Target>  

It should include all files from the folder Workspace\build and place it in the deployment directory in the same place.

But unfortunately it's not working. I'm not very good with msbuild, so I guess I'm missing something here.

Community
  • 1
  • 1
user49126
  • 1,825
  • 7
  • 30
  • 53

2 Answers2

1

For example, given that your files are in a directory called build which is on the same directory level as the solution directory you can do it like this:

<Target Name="AfterBuild">
    <CreateItem Include="$(SolutionDir)..\build\**\*.*">
        <Output TaskParameter="Include" ItemName="AdditionalFiles" />
    </CreateItem>
    <Copy SourceFiles="@(AdditionalFiles)" DestinationFolder="$(TargetDir)build" />
</Target>

This would copy those files in $(SolutionDir)..\build to the build subdirectory of the output directory $(TargetDir)build whenever the solution is built. Modify the Include mask, DestinationFolder and build target name to suit your needs.

Boris B.
  • 4,933
  • 1
  • 28
  • 59
0

See http://sedodream.com/2012/10/09/VSWebPublishHowToIncludeFilesOutsideOfTheProjectToBePublished.aspx

This only works for file deployments (not MSDeploy).

Steven De Kock
  • 505
  • 4
  • 6