How can I extend my publish profile to deploy to multiple locations?

帅比萌擦擦* 提交于 2019-12-06 20:40:20

问题


The following is the generated publish profile for my dev environment:

<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit http://go.microsoft.com/fwlink/?LinkID=208121. 
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish />
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <publishUrl>\\dev\webroot</publishUrl>
    <DeleteExistingFiles>False</DeleteExistingFiles>
  </PropertyGroup>
</Project>

What I want to do I would imagine is very easy, I simply want to add an additional publish url where I want to publish the same project. Unfortunately I haven´t been able to find anything on how to do this in a straightforward manner. All suggests that I need to implement some complex msdeploy solution or simply fallback to scripting (i.e. ps/batch + robocopy/xcopy) which is undesirable.

I imagined one could simply do something like:

<publishUrl>\\dev\webroot;\\dev2\webroot2</publishUrl>

or

<itemGroup>
<publishUrl>\\dev\webroot;</publishUrl>
<publishUrl>\\dev2\webroot;</publishUrl>
</itemGroup>

The main question is: How can I extend my publish profile to deploy to multiple locations via FTP or the file system?

In case of RTFM responses - please refer to somewhere I can read up on this.

UPDATE If it is possible to do multiple deploy with FTP I would be interested in such a solution as well.


回答1:


I'm using VS 2012; not sure what version of VS you are using - but you are using publish profiles so below should work.

I think that you simply need to create a new publish profile that you will then configure to use your additional publish URL. Seems simple so I hope I'm not missing something in your question.




回答2:


I'm not sure the publish option in VS was developed with that in mind. The only thing I might suggest is that when your project is deployed to the first destination you use a tool like robocopy to copy everything over to a new folder, it's quite simple to use, here is a sample command line use:

robocopy <SRCFOLDER> <TGTFOLDER> /E /XO /XF *.config

rem /E  : Copy Subfolders, including Empty Subfolders.
rem /XO : eXclude Older - if destination file exists and 
          is the same date or newer than     the source - don't overwrite it.
rem /XF *.config : excludes all .config files from copy operation


来源:https://stackoverflow.com/questions/21984967/how-can-i-extend-my-publish-profile-to-deploy-to-multiple-locations

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