Search code examples
powershellwebdeploy

MsDeploy and PowerShell: getting 'Error: Unrecognized argument '"=Default Web Site/Folder"'. All arguments must begin with "-"'


I am attempting to use MsDeploy in an Azure DevOps release pipeline. Things were not going well, so I resorted to executing a PowerShell script line-by-line on my machine in order to troubleshoot. I narrowed it down to this one command:

& "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" `
    -source:package="C:\...\Web.zip" `
    -dest:auto,computerName='https://hostname:8172/msdeploy.axd?site=Default+Web+Site,username=foo,password=foo,authtype=Basic,includeAcls=False' `
    -verb:sync `
    -disableLink:AppPoolExtension `
    -disableLink:ContentExtension `
    -disableLink:CertificateExtension `
    -setParam:"IIS Web Application Name"="Default Web Site\Folder" `
    -allowUntrusted `
    -enableRule:AppOffline `
    -enableRule:EncryptWebConfig

I keep getting the following error:

Error: Unrecognized argument '"=Default Web Site\Folder"'. All arguments must begin with "-".
Error count: 1.

I am using:

  • Microsoft (R) Web Deployment Command Line Tool (MSDeploy.exe) Version 7.1.3802.2153
  • Windows 10
  • PowerShell 5.1.19041.1320

This is the same error I am getting on our build server, which is running Windows Server 2019.

I've look at this command for hours now, and it feels like this should be a silly syntax error.

Other questions I viewed, but had no luck with the answers:


Solution

  • There seems to be something wonky about the -setParam argument, and how PowerShell parses these arguments. I ended up putting the IIS Web Application Name parameter in a parameter file:

    & "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" `
        -source:package="C:\...\Web.zip" `
        -dest:auto,computerName='https://hostname:8172/msdeploy.axd?site=Default+Web+Site,username=foo,password=foo,authtype=Basic,includeAcls=False' `
        -verb:sync `
        -disableLink:AppPoolExtension `
        -disableLink:ContentExtension `
        -disableLink:CertificateExtension `
        -setParamFile:C:\path\to\file.xml `
        -allowUntrusted `
        -enableRule:AppOffline `
        -enableRule:EncryptWebConfig
    

    Changed the -setParam:... argument to -setParamFile:C:\path\to\file.xml, with the contents of the XML file being:

    <parameters>
        <setParameter name="IIS Web Application Name" value="Default Web Site/Folder" />
    </parameters>