Azure DevOps - Deployments using a Publish Profile (*.pubxml)

6/23/2024

I have four personal websites (including one REST API) that I maintain. I host these through an Internet Service Provider. Historically I've deployed to these via Visual Studio Web Deploy publish profiles (*.pubxml files). However recently I decided to deploy these within Azure DevOps (AD). Although there's a variety of means to do this within AD, I found just using the existing publish profiles themselves to be easiest.

Deploying in AD via Publish Profile .pubxml files

Here are the general steps (some details left out)

  1. Ensure your publish profiles are working from within Visual Studio, and are checked into source code.
  2. In Azure DevOps, start a new Build Pipeline
    1. Select “Where is your code (Git, TFS, etc)”
    2. Select “ASP.NET” Template, and “Apply”
  3. In the Pipeline settings, under Parameters, Specify the solution’s .sln file
  4. Under the Agent job, a number of steps were created by the template. Remove the last three steps: “Test Assemblies”, “Publish symbols path” and “Publish Artifacts.” This pipeline won't be creating Artifacts.
  5. (Optional) In the "Use Nuget x.1" step, you may need to increase that to the latest version. Or use 'x' as the wildcard.
  6. In the Build Solution step (a “Visual Studio build”), set these MSBuild Arguments:
  7. /p:DeployOnBuild=true;PublishProfile=[your path here]/PublishProfiles/YourPubFile.pubxml /p:Password=YourPwdHere

    Note: When publishing via Visual Studio, you are prompted for the login password (rather than including it in your .pubxml). In AD, it must be a build argument, which is why it's added here.

  8. Queue it up!

That should be all you need. Rather than this pipeline creating an Artifact that is later deployed in a Release step, this does the build and publish all in one step. The details on the deployment are all within the .pubxml file, which is checked in, and under version control.


PS: If you get an untrusted SSL Certificate error, you can temporarily get around that by placing the following line in your .pubxml:
<AllowUntrustedCertificate>True</AllowUntrustedCertificate>


Please register or login to add a comment.

Comments (displaying 1 - 1):
No comments yet! Be the first...


  • C#/.NET
  • T-SQL
  • HTML/CSS
  • JavaScript/jQuery
  • .NET 8
  • ASP.NET/MVC
  • Xamarin/MAUI
  • WPF
  • Windows 11
  • SQL Server 20xx
  • Android
  • XBox
  • Arduino
  • Skiing
  • Rock Climbing
  • White water kayaking
  • Road Biking