Deploy from the command line

Synchronise a local folder with your website using the Web Deploy (MSDeploy) command line.

Web Deploy (MSDeploy) can also be run from the command line. It is the fastest and most reliable way to upload the content of a website, and it is especially useful for projects with many files — Node.js or Laravel applications, for example — because it synchronises the folders and uploads only the files that changed.

Before you start

  • A website created in the Control Panel.
  • A Windows computer with Web Deploy installed (see the first step below).
  • The content you want to publish in a local folder. Everything in that folder is uploaded into /wwwroot on the server.

Set up the deployment

  1. Check that Web Deploy is installed

    Check that this folder exists on your computer:

    C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\
    

    If the folder is missing or empty, download Web Deploy from the official Microsoft page https://aka.ms/webdeploydownload and install it. We recommend the Typical installation.

  2. Enable WebDeploy for your website

    Sign in to the Control Panel, go to Websites, select your website and choose Deploy in the left menu. On the Visual Studio access card switch WebDeploy to Enabled. Keep the page open — you will need the Site, Login and Password values from this card.

  3. Create the batch file

    Copy the following code into a new file and save it as webdeploy_to_monsterasp.bat:

    @echo off
    REM ====== MSDeploy: MonsterASP.NET command-line deploy ======
    
    setlocal
    
    REM ### Please fill necessary WebDeploy settings:
    
    REM Local path to your project. All these files will be uploaded inside /wwwroot folder on server.
    set SOURCE_PATH=C:\FULL_PATH_TO_YOUR_PROJECT\
    
    REM Your website name like: siteXXXXXX
    set DEST_SITE=siteXXXXX
    
    REM Your website WebDeploy URL like: https://siteXXXX.siteasp.net:8172/msdeploy.axd?site=siteXXXX
    set DEST_URL=https://siteXXXXX.siteasp.net:8172/msdeploy.axd?site=siteXXXXX
    
    REM Your website name like: siteXXXXXX
    set USERNAME=siteXXXXX
    
    REM Your WebDeploy password
    set PASSWORD=*****
    
    "C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe" ^
      -verb:sync ^
      -source:contentPath="%SOURCE_PATH%" ^
      -dest:contentPath="%DEST_SITE%",computerName="%DEST_URL%",userName="%USERNAME%",password="%PASSWORD%",authtype="Basic",includeAcls="False" ^
      -allowUntrusted ^
      -disableLink:AppPoolExtension ^
      -disableLink:ContentExtension ^
      -disableLink:CertificateExtension ^
      -verbose
    
    endlocal
    pause
    
  4. Fill in your values

    Replace the variables at the top of the file with the Web Deploy details of your website:

    Variable Value
    SOURCE_PATH Full path to the local folder with your application. The whole content of the folder is uploaded into /wwwroot on the server.
    DEST_SITE The ID of your website: siteXXXXX.
    DEST_URL The Web Deploy publishing URL. Replace both occurrences of siteXXXXX in the URL.
    USERNAME The same as the website ID: siteXXXXX.
    PASSWORD The Web Deploy password. Click Show next to Password on the Visual Studio access card to see it.
  5. Run the batch file

    Double-click webdeploy_to_monsterasp.bat.

What a successful run looks like

If everything is configured correctly, the output ends like this:

Info: Using ID 'b9e156f1-5bc9-44ce-a42f-27273dc6ab35' for connections to the remote server.
Verbose: Pre-authenticating to remote agent URL 'https://site12345.siteasp.net:8172/msdeploy.axd?site=site12345' as 'site12345'.
Verbose: Performing synchronization pass #1.
Verbose: Pre-authenticating to remote agent URL 'https://site12345.siteasp.net:8172/msdeploy.axd?site=site12345' as 'site12345'.
Verbose: No backup was executed.
Verbose: Received response from agent (HTTP status 'OK').
Verbose: The dependency check 'DependencyCheckInUse' found no issues.
Verbose: The synchronization completed in 1 pass(es).
Total changes: 0 (0 added, 0 deleted, 0 updated, 0 parameters changed, 0 bytes copied)
Press any key to continue . . .

The Total changes line tells you how many files were added, deleted and updated. From now on you update the website by running the batch file again — only modified files are transferred.

Important

The batch file contains your Web Deploy password in plain text. Do not commit it to a public repository and do not share it.

Something went wrong?

  • The connection times out. Web Deploy uses TCP port 8172. See Visual Studio cannot connect to the server in Deploy from Visual Studio (Web Deploy).
  • The login is refused. Check that WebDeploy is still Enabled and that the password in the batch file matches the one on the Deploy page. The Test connection button on the Visual Studio access card verifies the credentials on the server side.
Still stuck? Our support team is happy to help.
Ask the community Open a support ticket