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

2

15

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.

Thaler answered 24/2, 2014 at 10:25 Comment(4)
A post build copy of the original output would be preferable here. Why would you want to execute the entire build and publishing pipeline for both locations?Rai
I don´t, I want to include multiple paths to publish locations. Maybe I was unclear. The point I am making is that I wish to avoid unnecessary scripting hell and a complicated deploy chain if possible.Thaler
What did you end up doing?Holmen
Finally entered scriptinfghellThaler
B
0

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
Burrell answered 4/3, 2014 at 23:14 Comment(1)
That is exactly what I was trying to avoid, as described in my question.Thaler
S
0

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

Subtilize answered 16/4, 2014 at 14:54 Comment(1)
As far as I know, MSBUILD does not allow multiple publish profiles as parameters. I wish to automate, not to manually go and publish. This is a part of a larger deploy chain.Thaler

© 2022 - 2024 — McMap. All rights reserved.