Microsoft Windows
Use a CI pipeline to build and test a Microsoft Windows application.
You can build and test a Microsoft Windows application using a Windows platform on Harness Cloud or a self-managed Kubernetes cluster build infrastructure.
This guide assumes you've created a Harness CI pipeline.
Specify architecture
stages:
- stage:
name: build
identifier: build
type: CI
spec:
cloneCodebase: true
platform:
os: Windows
arch: Amd64
runtime:
type: Cloud
spec: {}There are several self-managed build infrastructure options. This example uses a Kubernetes cluster build infrastructure. For instructions and important information, go to Run Windows builds in a Kubernetes cluster build infrastructure.
stages:
- stage:
name: build
identifier: build
description: ""
type: CI
spec:
cloneCodebase: true
infrastructure:
type: KubernetesDirect
spec:
connectorRef: YOUR_K8S_CLUSTER_CONNECTOR_ID
namespace: YOUR_K8S_NAMESPACE
automountServiceAccountToken: true
nodeSelector:
kubernetes.io/os: windows
os: WindowsInstall dependencies
Harness Cloud runners include pre-installed libraries and tools, and you can use Run steps to install additional dependencies or additional versions. For details about pre-installed tools and versions, go to Platforms and image specifications.
- step:
type: Run
identifier: dependencies
name: Dependencies
spec:
shell: Powershell
command: |-
dotnet add package Newtonsoft.json --version 12.0.1You can use Run steps to install dependencies.
- step:
type: Run
identifier: dependencies
name: Dependencies
spec:
connectorRef: YOUR_IMAGE_REGISTRY_CONNECTOR
image: mcr.microsoft.com/dotnet/sdk:7.0
shell: Powershell
command: |-
dotnet add package Newtonsoft.json --version 12.0.1Cache dependencies
Add caching to your Build stage.
Cache your Windows app dependencies with Cache Intelligence. Add caching to your stage.spec and specify the paths to cache:
You can use built-in steps to:
Build and run tests
Add Run steps to build and run your tests.
Visualize test results
You can view test results on the Tests tab of your pipeline executions. Harness supports JUnit XML and TRX test report formats. TRX reports are automatically converted to JUnit XML.
For your pipeline to produce test reports, you need to modify the Run step that runs your tests. Make sure the command generates test reports and add the reports specification.
For .NET projects, you can generate TRX reports natively using dotnet test -l:trx without needing a converter. If your test tool does not produce JUnit XML or TRX formatted reports by default, you can use a converter to output compatible JUnit XML reports, such as NUnit to JUnit or .NET trx2JUnit.
Install Visual Studio
Visual Studio 2019 Enterprise is pre-installed on Hosted Cloud runners. For details about all available tools and versions, go to Platforms and image specifications.
You can use a Run step to install a different version or edition of Visual Studio.
If not already included on your build machine, you can specify a container image that has the necessary binaries or use a Run step to install Visual Studio.
Specify shell
In steps that allow you to supply your own commands, such as Run steps and Background steps, you specify the shell in the step's settings.
Several shell binaries are pre-installed on Hosted Cloud runners, including Bash and PowerShell. For details about all available tools and versions, go to Platforms and image specifications.
You can also use Run steps to install different shell tools into the build environment, or specify a container image that has the necessary binaries for the command you want to run.
In steps that allow you to supply your own commands, such as Run steps and Background steps, you specify the shell in the step's settings.
You can also use Run steps to install different shell tools into the build environment, or specify a container image that has the necessary binaries for the command you want to run.
Setup .NET SDK
For details about building and testing .NET with Harness CI, including how to setup different versions of the .NET SDK, go to the C# (.NET Core) guide.
Full pipeline examples
The following full pipeline examples are based on the partial examples above.
If you copy this example, replace the placeholder values with appropriate values for your code repo connector and repository name. Depending on your project and organization, you may also need to replace projectIdentifier and orgIdentifier.
If you copy this example, replace the placeholder values with appropriate values for your code repo connector, Kubernetes cluster connector, Kubernetes namespace, and repository name. Depending on your project and organization, you may also need to replace projectIdentifier and orgIdentifier.
Next steps
Now that you have created a pipeline that builds and tests a Windows app, you could:
Create triggers to automatically run your pipeline.
Add steps to build and upload artifacts.
Add a step to build and push an image to a Docker registry.
Last updated
Was this helpful?