需要帮助理解MSbuild中的CustomFilesToInclude属性

时间:2014-03-17 04:59:16

标签: visual-studio-2010 msbuild customization build-script

我在使用MSBuild复制html文件以部署位置时遇到问题。

请帮助我理解以下内容:

<Target Name="CustomCollectFiles">
  <ItemGroup>
    <FilesForPackagingFromProject Include="@(CustomFilesToInclude)">
      <DestinationRelativePath>%(CustomFilesToInclude.Dir)\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
    </FilesForPackagingFromProject>
  </ItemGroup>
</Target>


<Target Name="CustomCollectFiles">
  <ItemGroup>
    <FilesForPackagingFromProject Include="@(CustomFilesToInclude)">
      <DestinationRelativePath>%(CustomFilesToInclude.Dir)\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
    </FilesForPackagingFromProject>
    <FilesForPackagingFromProject Include="@(CustomFilesToIncludeSkipExistingCheck)">
      <DestinationRelativePath>%(CustomFilesToIncludeSkipExistingCheck.Dir)\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
    </FilesForPackagingFromProject>
  </ItemGroup>
  <Error Text="Custom file exists in project files already: %(CustomFilesToInclude.FullPath)"
    Condition="Exists('$(MainProjectRootDir)\%(CustomFilesToInclude.Dir)\%(RecursiveDir)%(Filename)%(Extension)')" />
</Target>

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

1 个答案:

答案 0 :(得分:0)

我从未使用过MSDeploy。 但我要说它只是将DestinationRelativePath元数据添加到item并注入目标DefineCustomFiles和CustomCollectFiles,以便在现有CopyAllFilesToSingleFolderForPackageDependsOn目标之前调用。 我看到它可以被Microsoft.Web.Publishing.targets使用。

您提供的代码示例并不完整,无法说明发生了什么。

看起来像这样:http://sedodream.com/2010/03/10/WebDeploymentToolIncludingOtherFiles.aspx