Search code examples
asp.netteamcitymsdeploywebdeploy

How to copy files into main directory and deploying


I have gone through every question I have found on StackOverflow and various Google links and not finding this.

We have 3 different servers that require one of the last 3 versions to be deployed to it. This is how I have been handling it on a local build level:

<PostBuildEvent>
  start xcopy /Y /Q "$(TargetDir)EncompassSDKDlls\$(ConfigurationName)\*.*" "$(TargetDir)"
</PostBuildEvent>

And that works great. However, when it tries to do a deploy, it runs it before that. I did try doing some things like: MSDeploy Extra Files but that does not seem to copy the files on the deploy, just the original files that were in the bin directory.

Here was what I tried last:

<PropertyGroup>
    <CopyAllFilesToSingleFolderForPackageDependsOn>
        CustomCollectFiles;
        $(CopyAllFilesToSingleFolderForPackageDependsOn);
    </CopyAllFilesToSingleFolderForPackageDependsOn>
    <CopyAllFilesToSingleFolderForMsdeployDependsOn>
        CustomCollectFiles;
        $(CopyAllFilesToSingleFolderForPackageDependsOn);
    </CopyAllFilesToSingleFolderForMsdeployDependsOn>
</PropertyGroup>
<Target Name="CustomCollectFiles">
    <ItemGroup>
        <_CustomFiles Include="Dlls\$(ConfigurationName)\*" />

        <FilesForPackagingFromProject  Include="%(_CustomFiles.Identity)">
            <DestinationRelativePath>(Filename)%(Extension)</DestinationRelativePath>
        </FilesForPackagingFromProject>
    </ItemGroup>
</Target>
<PropertyGroup>

Solution

  • Got it to work. The copy did need to be in the post build event, however the FilesForPackagingProject did not have all of the proper settings to recognize the new files. I wanted to post this encase it helps out anyone in the future:

    <ItemGroup>
      <_CustomFiles Include="EncompassSDKDlls\$(ConfigurationName)\*" />
      <FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
        <DestinationRelativePath>%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
      </FilesForPackagingFromProject>
    </ItemGroup>