azure-devopsazure-pipelines-release-pipeline

Duplicate a VS Web Deploy Publish (.pubxml) in Azure DevOps


I have an ASP.NET web app that I host via an Internet Service Provider (NOT via Azure). I manually deploy this in Visual Studio using a “Web Deploy” publish profile (a .pubxml file). See below.

ISSUE: I’d like to duplicate this deployment in Azure DevOps, rather than publish through Visual Studio. Despite days of effort, I have not figured out how to do it, nor find good examples.

Here is my Visual Studio Publish profile, which works just fine:

enter image description here

WHAT I'VE TRIED

After the deploy I get this:

error: “No machine found in given deployment group.”

QUESTIONS:

  1. Am I taking the correct approach here?
  2. Is there a way to just link an Azure DevOps release to my *.pubxml file, since I know they already work?

Solution

  • Regarding the error:

    error: “No machine found in given deployment group.”
    

    It's caused by the deployment group agent is not created, your release pipeline cannot found the agent to run.

    When you create the deployment group, you need to follow the guide, tick the option to include personal access token, and go to local machine, open powershell with admin permission, past the script to run. It will automatically register the deployment group agent for you.

    enter image description here

    Back to your query:

    You are in the correct direction, you can build artifact and then deploy it from release pipeline.

    But since you have *.pubxml file, you can also consider to directly publish it from Build task, details below:

    1. Check-in Your .pubxml File to source control repository under the Properties\PublishProfiles folder of your project.

    2. Setup a self-hosted agent with local machine on which can communicate and deploy to your website.

    3. Create a Build Pipeline, use above self-hosted agent. Use the Visual Studio Build task or MSBuild task. Include the following MSBuild arguments to use your .pubxml file:

    /p:DeployOnBuild=True;PublishProfile=<YourProfileName>
    

    Yaml task sample below, you can use same argument for classic UI task:

    - task: VSBuild@1
      inputs:
        solution: '$(solution)'
        platform: '$(buildPlatform)'
        configuration: '$(buildConfiguration)'
        msbuildArgs: /p:DeployOnBuild=true;PublishProfile=Properties/PublishProfiles/DeploymentPackage.pubxml
    

    Here are some links which could be helpful:

    Windows Self-hosted agent setup

    deployment group setup

    Publish profiles