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

无人久伴 提交于 2021-02-10 06:46:44

问题


So I have a solution made up of a web project and an Azure Resource Group project much like what is described here: https://blogs.technet.microsoft.com/georgewallace/2015/05/10/deploying-a-website-with-content-through-visual-studio-with-resource-groups/

The issue I am having is that the web project needs to include some EXTRA files in its bin directory in order to function. Now through the normal package process on the web project itself I accomplish this by adding a custom target and hook into CopyAllFilesToSingleFolderforPackageDependsOn, like:

  <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>

And when I right-click on the web project and say "publish" to, say, a file system, my file gets included. All is well and good.

The problem is that this does not happen when I deploy from the deployment project. I have an MsDeploy resource that does its own thing. I need to somehow do my CustomCollectFiles from within this project.

Anyone have any ideas as to how to accomplish this? Without this I am unable to automate the deployment of my solution to Azure.

Thanks!


回答1:


On a whim I ended up doing this:

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

The key being the CopyAllFilesToSingleFolderForMsdeployDependsOn instead of CopyAllFilesToSingleFolderForPackageDependsOn. Just changing this did the trick, which I guess triggered msdeploy to include the custom target.



来源:https://stackoverflow.com/questions/40293668/how-to-add-extra-files-to-the-package-that-is-generated-by-msbuild-called-by-an

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