How to use Azure DevOps pipeline CI/CD with Dreamnix.com hosting

Programming, error messages and sample code > ASP.NET
**when reading this article, if you feel like the image texture is not very clear, please right-click on the image, and save it to your local to check.**
 
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.
ci_cd_1
 
Navigate to Pipelines at the left nav menu bar, then click Create Pipeline
ci_cd_2
 
 
Click Use the classic editor
ci_cd_3
 
 
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.
ci_cd_4
 
ci_cd_5
 
 
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.
ci_cd_6
 
 
Open the Publish pane, untick Zip published projects, and we can browse the published files later.
ci_cd_7
 
 
Open Publish Artifact pane, check the Artifact name * field, it is where the published files locate.
ci_cd_8
 
 
On the Variables page, you can update the configurations as you need, the default settings are enough to publish a standard asp.net core app.
ci_cd_9
 
 
On the Triggers page, tick the Enable continuous integration, this will build your project pipeline whenever a change is committed to your repository.
ci_cd_10
 
 
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.
ci_cd_12
 
 
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).
ci_cd_13
 
 
Next, navigate to the Releases page, and create a new release pipeline.
ci_cd_14
 
 
For the Stages, select an Empty job,
ci_cd_15
 
 
then close the Stage pane.
ci_cd_16
 
 
Next, add the Artifacts
ci_cd_17
 
 
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.
ci_cd_18
 
 
Enable Continuous deployment trigger, this will execute the subsequent Stage jobs when a pipeline is built.
ci_cd_19
 
 
Next, add a task for the deployment.
ci_cd_20
 
 
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.
ci_cd_21
 
 
Add a PowerShell task.
ci_cd_22
 
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
ci_cd_23
 
ci_cd_24
 
 
Now, let's Create release for the configured pipeline, this will execute the Stage Anget job to deploy your project.
 
ci_cd_26
 
 
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.
ci_cd_27
 
 
Please feel free to contact our support if you need assistance.