如何将额外文件添加到由 Visual Studio 中的 Azure 资源组项目调用的 msbuild 生成的包中

How to add extra files to the package that is generated by msbuild called by an Azure Resource Group Project in Visual Studio

所以我有一个由 Web 项目和 Azure 资源组项目组成的解决方案,就像这里描述的一样:https://blogs.technet.microsoft.com/georgewallace/2015/05/10/deploying-a-website-with-content-through-visual-studio-with-resource-groups/

我遇到的问题是 Web 项目需要在其 bin 目录中包含一些 EXTRA 文件才能运行。现在通过 web 项目本身的正常打包过程,我通过添加自定义目标并挂钩到 CopyAllFilesToSingleFolderforPackageDependsOn 来完成此操作,例如:

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

  <Target Name="CustomCollectFiles">
    <ItemGroup>
      <_CustomFiles Include="bin\SlimKIA.WebApi.xml" />
      <FilesForPackagingFromProject  Include="%(_CustomFiles.Identity)">
        <DestinationRelativePath>bin\SlimKIA.WebApi.xml</DestinationRelativePath>
      </FilesForPackagingFromProject>
    </ItemGroup>
  </Target>

当我右键单击 Web 项目并对文件系统说 "publish" 时,我的文件将被包含在内。一切都很好。

问题是当我从部署项目部署时,这不会发生。我有一个自己做事的 MsDeploy 资源。我需要以某种方式从该项目中执行我的 CustomCollectFiles。

有人知道如何完成这个吗?否则我无法将我的解决方案自动部署到 Azure。

谢谢!

我一时兴起做了这个:

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

关键是 CopyAllFilesToSingleFolderForMsdeployDeployDependsOn 而不是 CopyAllFilesToSingleFolderForPackageDependsOn。只需更改它就可以了,我猜这触发了 msdeploy 以包含自定义目标。