Include files in MSBuild that are not part of the project

I am trying to create an automatic assembly for my web application project. We use the standard CMS project and changed some parts of it. Only modified files are part of our project, but I want to include a complete CMS in the deployment package.

So, I created my own .targets file to define the task for including CMS files during build:

 <Target Name="GetCMSFiles"> <ItemGroup> <!-- Include the CMS files into the package --> <_CMSFiles Include="..\packages\CMSFiles\**\*" /> <FilesForPackagingFromProject Include="%(_CMSFiles.Identity)"> <DestinationRelativePath> %(RecursiveDir)%(Filename)%(Extension) </DestinationRelativePath> </FilesForPackagingFromProject> </ItemGroup> </Target> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'"> <!-- VS2010 --> <CopyAllFilesToSingleFolderForPackageDependsOn> GetCMSFiles; $(CopyAllFilesToSingleFolderForPackageDependsOn); </CopyAllFilesToSingleFolderForPackageDependsOn> <!-- VS2012 --> <CopyAllFilesToSingleFolderForMsdeployDependsOn> GetCMSFiles; $(CopyAllFilesToSingleFolderForMsdeployDependsOn); </CopyAllFilesToSingleFolderForMsdeployDependsOn> </PropertyGroup> 

This works fine, but the problem is that the files from our project are not copied to the deployment folder. In other words, it does not overwrite files that already exist after I copied them with the GetCMSFiles task.

As I see, there are two options:

  • Make CopyAllFilesToSingleFolder overwrite all existing files in the deployment folder.

  • You have a condition in the GetCMSFiles task to include only files that do not already exist in the project.

But I'm not sure that this is possible and how to achieve this. Any ideas?

0
source share

Source: https://habr.com/ru/post/1204007/


All Articles