Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CopyAllFilesToSingleFolderForPackageDependsOn and Web Deploy

I am using Web Deploy feature of Visual Studio 2015 to deploy my Type Script SPA project to my staging server.

I want the deployment process to copy (and rename) some deployment specific files from /Deployment folder of my project to other specific locations of the project.

One such example is:

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

I managed to achieve this using the following section in my publish profile (.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>

But this works only when publishing to file system with 'File System' option. When publishing to my staging server using 'Web Deploy' option, I see no effect. The application is correctly deployed but respective files don't get copied/renamed.

There is also no error message in Visual Studio output related to such a web deploy.

It makes no difference if I deploy as non-admin or admin.

Does anybody know, where is the problem?

With respect to MSBuild I am a total layman and this is my first encounter. I've put this together only with help of other people's online experience.

like image 799
TyphoonOfDvina Avatar asked Jan 25 '16 19:01

TyphoonOfDvina


2 Answers

You need an element with a slightly different name. You have:

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

Try having a nearly identical section but with this tag:

  <CopyAllFilesToSingleFolderForMsdeployDependsOn>

Notice it is ForMsdeploy not ForPackage

like image 160
Rhyous Avatar answered Oct 06 '22 22:10

Rhyous


In addition to Rhyous's excellent answer, note that the MS docs indicate you should have both CopyAllFilesToSingleFolderForPackageDependsOn and CopyAllFilesToSingleFolderForMsdeployDependsOn, e.g.

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

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

I have gotten this to work by editing the project file, but the referenced doc has this edit made in the publish profile file, which I suppose is more efficient.

like image 33
Bondolin Avatar answered Oct 06 '22 20:10

Bondolin