none
Customising WebDeploy URL used by Visual Studio (2015) during publishing

    Question

  • Hello,

    I'm using (and administering) WebsitePanel hosting software which is generating publishing profiles for websites WebDeploy publishing functionality. 

    It generates XML document similar ro this structure:

    <?xml version="1.0" encoding="utf-8"?>
    <publishData>
    
    	<publishProfile
    ...
    		publishMethod="MSDeploy"
    		publishUrl="SERVERURL:8172"
    ....
    	/>
    </publishData>

    and this file imported to Visual Studio is validated as correct (green icon) BUT when I'm trying to use Preview button or publish I'm getting this kind of error:

    Web deployment task failed. (Connected to the remote computer ("SERVERURL") using the Web Management Service, but could not authorize. Make sure that you are using the correct user name and password, that the site you are connecting to exists, and that the credentials represent a user who has permissions to access the site.  Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_USER_UNAUTHORIZED.)

    NOW when I modify profile XML file and add:

    /msdeploy.axd?site=PUBLISHEDWEBSITENAME

    to publishUrl I can use preview function which is last step before publishing and it works correctly but when I'm pressing Publish button I'm still getting error in Error list window:

    ERROR_USER_UNAUTHORIZED

    and checking Visual Studio 2015 Output windows gives clue why:

    .....
    Executing command ["C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe" -source:IisApp='C:\Users\...\TestWebApp68\wwwroot' -dest:IisApp='PUBLISHEDWEBSITENAME',ComputerName='https://SERVERURL:8172/msdeploy.axd?site=PUBLISHEDWEBSITENAME/msdeploy.axd',UserName='WDUSERNAME',Password='{PASSWORD-REMOVED-FROM-LOG}',IncludeAcls='False',AuthType='Basic' -verb:sync -enableLink:contentLibExtension  -enableRule:DoNotDeleteRule -retryAttempts:2]
    C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(386,5): Error ERROR_USER_UNAUTHORIZED

    Take a look how Visual Studio 2015 is generatin WebDeploy URL:

    https://SERVERURL:8172/msdeploy.axd?site=PUBLISHEDWEBSITENAME/msdeploy.axd

    It is forcibly adding msdeploy.axd at the end of WebDeploy URL. IMHO this is a bug. Can someone confirm similar issues? Does anyone have any idea how to fix this? Is there any special param to publishing settings file which allows to provide WebDeploy URL attribs?

    Thanks


    Monday, January 25, 2016 1:37 PM

Answers

  • Since I think this is a bug (or at least TODO item according to comment in one file) I've added this also to MS Connect page:

    https://connect.microsoft.com/VisualStudio/feedback/details/2282058/customising-webdeploy-url-used-by-visual-studio-2015-during-publishing

    here is entry which will allow fixing this issue:

    I think I've found a place where it can be fixed:
    
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\Publish\Scripts\1.0.1\publish-module.psm1
    
    function Get-MSDeployFullUrlFor{
        [cmdletbinding()]
        param($msdeployServiceUrl)
        process{
            # Convert contoso.scm.azurewebsites.net:443 to https://contoso.scm.azurewebsites.net/msdeploy.axd
            # TODO: This needs to be improved, it only works with Azure Websites currently.
        'https://{0}/msdeploy.axd' -f $msdeployServiceUrl.TrimEnd(':443')
        }
    }

    As you can see this has been marked as TODO by Visual Studio dev team...

    Monday, January 25, 2016 7:54 PM

All replies

  • Since I think this is a bug (or at least TODO item according to comment in one file) I've added this also to MS Connect page:

    https://connect.microsoft.com/VisualStudio/feedback/details/2282058/customising-webdeploy-url-used-by-visual-studio-2015-during-publishing

    here is entry which will allow fixing this issue:

    I think I've found a place where it can be fixed:
    
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\Publish\Scripts\1.0.1\publish-module.psm1
    
    function Get-MSDeployFullUrlFor{
        [cmdletbinding()]
        param($msdeployServiceUrl)
        process{
            # Convert contoso.scm.azurewebsites.net:443 to https://contoso.scm.azurewebsites.net/msdeploy.axd
            # TODO: This needs to be improved, it only works with Azure Websites currently.
        'https://{0}/msdeploy.axd' -f $msdeployServiceUrl.TrimEnd(':443')
        }
    }

    As you can see this has been marked as TODO by Visual Studio dev team...

    Monday, January 25, 2016 7:54 PM
  • Hi Webio,

    Since you have found a workaround and submit this issue to Visual Studio Connect, I think the report team experts will evaluate this problem seriously. Thanks for your feedback for the VS products.

    I will mark your reply as answer to close this thread. If any other questions about Visual Studio IDE, please feel free to come back to our forum.

    Best Regards,
    Weiwei

    Wednesday, January 27, 2016 5:37 AM
    Moderator