CopyAllFilesToSingleFolderForPackageDependsOn和Web Deploy

Typ*_*ina 7 deployment msbuild visual-studio-2015

我正在使用Visual Studio 2015的Web Deploy功能将我的Type Script SPA项目部署到我的登台服务器.

我希望部署过程将一些特定于部署的文件从项目的/ Deployment文件夹复制(并重命名)到项目的其他特定位置.

一个这样的例子是:

[project_root] /Deployment/index.remote.debug.html ---> [project_root] /index.html

我设法使用我的发布配置文件(.pubxml)中的以下部分实现此目的:

<Target Name="index_html">
  <ItemGroup>
    <_CustomFiles Include="Deployment/index.remote.debug.html" />
    <FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
      <DestinationRelativePath>index.html</DestinationRelativePath>
    </FilesForPackagingFromProject>
  </ItemGroup>
</Target>
<Target Name="extractor_config">
  <ItemGroup>
    <_CustomFiles Include="Deployment/extractor.config.remote.debug.js" />
    <FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
      <DestinationRelativePath>extractor.config.js</DestinationRelativePath>
    </FilesForPackagingFromProject>
  </ItemGroup>
</Target>

<PropertyGroup>
  <CopyAllFilesToSingleFolderForPackageDependsOn>
    index_html;
    $(CopyAllFilesToSingleFolderForPackageDependsOn);
  </CopyAllFilesToSingleFolderForPackageDependsOn>
  <CopyAllFilesToSingleFolderForPackageDependsOn>
    extractor_config;
    $(CopyAllFilesToSingleFolderForPackageDependsOn);
  </CopyAllFilesToSingleFolderForPackageDependsOn>

</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)

但这仅在使用"文件系统"选项发布到文件系统时才有效.使用"Web Deploy"选项发布到我的登台服务器时,我看不到任何效果.应用程序已正确部署,但不会复制/重命名相应的文件.

Visual Studio输出中也没有与此类Web部署相关的错误消息.

如果我部署为非管理员或管理员,则没有任何区别.

有谁知道,问题出在哪里?

关于MSBuild我是一个完全的门外汉,这是我第一次遇到.我只是在其他人的在线体验的帮助下把它放在一起.

Rhy*_*ous 11

您需要一个名称略有不同的元素.你有:

  <CopyAllFilesToSingleFolderForPackageDependsOn>
    index_html;
    $(CopyAllFilesToSingleFolderForPackageDependsOn);
  </CopyAllFilesToSingleFolderForPackageDependsOn>
  <CopyAllFilesToSingleFolderForPackageDependsOn>
    extractor_config;
    $(CopyAllFilesToSingleFolderForPackageDependsOn);
  </CopyAllFilesToSingleFolderForPackageDependsOn>
Run Code Online (Sandbox Code Playgroud)

尝试使用几乎相同的部分,但使用此标记:

  <CopyAllFilesToSingleFolderForMsdeployDependsOn>
Run Code Online (Sandbox Code Playgroud)

注意它是ForMsdeploy而不是ForPackage


Bon*_*lin 5

除了 Rhyous 的出色回答之外,请注意MS 文档表明您应该同时拥有CopyAllFilesToSingleFolderForPackageDependsOnCopyAllFilesToSingleFolderForMsdeployDependsOn,例如

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

    <CopyAllFilesToSingleFolderForMsdeployDependsOn>
      CustomCollectFiles;
      $(CopyAllFilesToSingleFolderForMsdeployDependsOn);
    </CopyAllFilesToSingleFolderForMsdeployDependsOn>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)

我已经通过编辑项目文件来实现此目的,但引用的文档在发布配置文件中进行了此编辑,我认为这更有效。