How can I extend my publish profile to deploy to m

2019-04-20 16:51发布

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.

2条回答
不美不萌又怎样
2楼-- · 2019-04-20 16:58

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. Create New Publish Profile

查看更多
Viruses.
3楼-- · 2019-04-20 17:09

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
查看更多
登录 后发表回答