Include files in MSBuild that are not part of project

谁说我不能喝 提交于 2019-12-13 06:27:28

问题


I'm trying to create an automated build for my web application project. We use a standard CMS project and have tweaked some parts of it. Only the tweaked files are part of our project, but I want to include the full CMS in the deployment package.

So I've created a custom .targets file to define a task to include the CMS files during the 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 do not get copied to the deployment folder. So in other words, it does not overwrite the files that already exist after I copied them with the GetCMSFiles task.

The way I see it there are two options:

  1. Force the CopyAllFilesToSingleFolder to overwrite any existing files in the deployment folder.

  2. Have a condition in the GetCMSFiles task to only include files that don't already exist in the project.

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

来源:https://stackoverflow.com/questions/17238218/include-files-in-msbuild-that-are-not-part-of-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!