How to use Azure DevOps pipeline CI/CD with hosting

Programming, error messages and sample code > ASP.NET
Login to your Azure DevOps panel, if you don't have an Azure account, please create it.
Select your target project on the home page, if you just register a new account, please create a new project at the upper right.
Navigate to Pipelines at the left nav menu bar, then click Create Pipeline
Click Use the classic editor
In my case, I use Azure Repos Git and ASP.NET Core project. You can choose the other options as you need, they have the same procedures, but few fields are different.
In the Name * field, do not leave any white space in the name, to prevent any unexpected problems. In the Agent Specification * field, choose "windows" since we are going to build and publish the project to a Windows platform.
Open the Publish pane, untick Zip published projects, and we can browse the published files later.
Open Publish Artifact pane, check the Artifact name * field, it is where the published files locate.
On the Variables page, you can update the configurations as you need, the default settings are enough to publish a standard core app.
On the Triggers page, tick the Enable continuous integration, this will build your project pipeline whenever a change is committed to your repository.
Now, you can Save & queue your pipeline.
After Save and run, the page will navigate to the Summary pane automatically. You can check the job status and our published results.
Here are the published project production files, write down the path drop\s, we will need to use it later(directory name is case-sensitive).
Next, navigate to the Releases page, and create a new release pipeline.
For the Stages, select an Empty job,
then close the Stage pane.
Next, add the Artifacts
choose the Source(build pipeline) * that we created in the previous. If there is no other specific reason, do NOT update the Source alias * field.
Enable Continuous deployment trigger, this will execute the subsequent Stage jobs when a pipeline is built.
Next, add a task for the deployment.
Open the Agent job pane, in the Agent pool, choose Hosted Windows 2019 with VS2019, because we will have to use msdeploy.exe later. Make sure the Artifact download is configured with the matched build pipeline.
Add a PowerShell task.
Get your Web Deploy Info from your Control Panel. Pair all the necessary information like this
SourcePath your pipeline published path, default is "drop\s"
ServiceUrl your web deploy URL
SiteName your web deploy site name
UserName your web deploy user name
Password your web deploy password
Open PowerShell Script task, expand the Environment Variables tab, and add the above information. Then change Type to Inline, copy & paste the following script to Script * filed, you don't need to update anything in the script. Finally, Save all things.
$sourcePath = Join-Path -Path "$($Env:AGENT_RELEASEDIRECTORY)\$($Env:RELEASE_PRIMARYARTIFACTSOURCEALIAS)" -ChildPath $Env:SourcePath

& "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:contentPath=$sourcePath -dest:contentPath=$Env:SiteName,computerName=$Env:ServiceUrl,userName=$Env:UserName,password=$Env:Password,authtype="Basic",includeAcls="False" -allowUntrusted -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -verbose
Now, let's Create release for the configured pipeline, this will execute the Stage Anget job to deploy your project.
Cheers. We have completed all the procedures. Check your Stage status for the release pipeline, if it fails, check the error log to troubleshoot. Next, check your site URL, all changes committed to your repository have been built and published to your production server.
Please feel free to contact our support if you need assistance.