Cloud Native 14 min read

How to Build and Deploy a .NET App with Cloud‑Native CI/CD and NuGet Packages

This step‑by‑step guide shows how to set up a Windows build environment, configure IIS and Web Deploy, create a private Cloud Native build machine, and use Alibaba Cloud's Flow pipeline together with a NuGet Packages repository to continuously build, publish, and deploy a .NET application.

Alibaba Cloud Native
Alibaba Cloud Native
Alibaba Cloud Native
How to Build and Deploy a .NET App with Cloud‑Native CI/CD and NuGet Packages

Overview

The article provides a hands‑on tutorial for developing and deploying a .NET application using Alibaba Cloud's Flow CI/CD pipeline and Packages NuGet repository. It covers environment preparation, Windows Server configuration, local build verification, pipeline setup, and dependency management.

Architecture

Two machines are used: a Windows build agent added to the Flow pipeline, and a Windows Server that serves as the target for msdeploy publishing. The overall architecture is illustrated in the diagram below.

1. Environment Preparation

1.1 Install and configure IIS on Windows Server

Open Server Manager .

Choose Add Roles and Features from the Manage menu.

Select Role‑based or feature‑based installation .

Pick the local machine as the server.

Under Server Roles select Web Server (IIS) and ensure the following sub‑features are checked: IIS Management Scripts and Tools , Management Service , IIS Management Console .

Leave Features unchecked.

Accept default settings for IIS Role Service and complete the installation.

1.2 Install Web Deploy 4.0

Download Web Deploy 4.0 installer.

Run the installer and choose a full (not typical) installation to ensure all components are installed.

Verify that the services Web Deployment Agent Service and Web Management Service are running.

1.3 Install ASP.NET Core Windows‑hosting bundle

Download and install the windows‑hosting‑bundle to provide AspNetCoreModuleV2, which prevents 500.19 errors during service startup.

1.4 Create IIS website and enable Web Deploy publishing

Open IIS Manager and select Add Website . Name it DemoWin and set the physical path.

Right‑click the new site, choose Deploy → Config Web Deploy Publishing .

In the publishing dialog, keep the default port 8172 (or change as needed) and note the URL for later use.

2. Configure Windows Build Machine

2.1 Install build tools

Install Visual Studio , Web Deploy , and .NET 6.0 SDK . After installation, add the following directories to the system PATH:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319

C:\Program Files\IIS\Microsoft Web Deploy V3

C:\Program Files\dotnet (if not added automatically)

Verify that msbuild, msdeploy, and dotnet are accessible from a command prompt.

2.2 Local build and publish

Clone the demo repository and build it locally before configuring the pipeline.

git clone https://atomgit.com/oauth2_o72n54/FlowDemoWin
# Build the project</code>
<code>dotnet msbuild /p:Configuration=Debug /t:Publish</code>
<code># Publish with msdeploy</code>
<code>msdeploy -verb:sync -source:contentPath="C:\Users\Administrator\source\repos\FlowDemoWin\bin\Debug
et6.0\publish" -dest:contentPath=DemoWin,computerName=https://<Windows Server IP>:8172/MsDeploy.axd?site=DemoWin,userName=YOURUSERNAME,password=YOURPASSWORD,authtype="Basic",includeAcls="False" -allowUntrusted -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -verbose

Opening the server’s public IP in a browser should display the running application, confirming a successful local build and deployment.

3. Set Up Flow CI/CD Pipeline

3.1 Add a private Windows build agent

In the Flow console, create a new private build cluster, then copy the generated Runner installation command and execute it on the prepared Windows build machine via PowerShell. After successful installation, the machine appears in the cluster list.

3.2 Configure the Flow pipeline

Add the Git repository as the pipeline source (SSH key authentication).

Add a build step: select the Windows build agent and run the same dotnet msbuild /p:Configuration=Debug /t:Publish command.

Add a deploy step: execute a PowerShell script that resolves the publish folder and runs msdeploy with the same parameters used locally.

Run the pipeline; on success, the site on the Windows Server shows the deployed .NET application.

4. Manage Dependencies with Packages NuGet Repository

Switch the code source to the PackagesDemo repository, which includes a reference to Newtonsoft.Json. The build will fail until the package is available in a NuGet repository. [email protected]:oauth2_o72n54/PackagesDemo.git Create a NuGet repository in Cloud Efficient Packages, push the required Newtonsoft.Json package, and configure the pipeline to use this repository.

# Add NuGet source credentials
dotnet nuget add source http://yunxiao-poc.devops.aliyuncs.com:80/packages/02e873bb-f911-48ac-ad73-ec2298c5385d/nuget/repo-hzaul/index.json -n repo-hzaul -u "xxxxxxxxxxx" -p "xxxxxxxxx"
# Pull the package
dotnet add package Newtonsoft.Json --source http://yunxiao-poc.devops.aliyuncs.com:80/packages/02e873bb-f911-48ac-ad73-ec2298c5385d/nuget/repo-hzaul/index.json
# Build
dotnet msbuild /p:Configuration=Debug /t:Publish

After saving and running the pipeline, the build succeeds, pulling the dependency from the private NuGet repository.

Conclusion

The guide walks through the complete process of setting up a Windows‑based .NET development environment, configuring IIS and Web Deploy, creating a private Cloud Native build agent, defining a Flow CI/CD pipeline, and managing third‑party dependencies with a NuGet Packages repository, enabling end‑to‑end continuous delivery of a .NET application.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

ci/cdWindows servernetNuGetmsdeploy
Alibaba Cloud Native
Written by

Alibaba Cloud Native

We publish cloud-native tech news, curate in-depth content, host regular events and live streams, and share Alibaba product and user case studies. Join us to explore and share the cloud-native insights you need.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.