TX Text Control .NET for WPF

CI/CD

Topic

Continuous integration builds your WPF application on every push, and a publish step at the end of the pipeline turns the build into a deployable folder. With TX Text Control .NET for WPF, the pipeline has to restore TXTextControl.TextControl.WPF.SDK from a feed with credentials, run on Windows and publish for the platform you ship. Build Servers covers the restore and the license rules; what follows adds a complete workflow and the publish step.

Requirements of a Build Server

  • Windows. Text Control's pipelines for WPF and Windows Forms projects run on a Windows image, such as windows-latest.
  • Feed credentials as secrets. The package comes from the Text Control Private NuGet Feed or from a feed of your own, never from nuget.org. The pipeline writes nuget.config from secrets, so the credentials stay out of the repository.
  • No developer license. A build server needs no license of its own, under the conditions listed in What the License Agreement Allows.

A GitHub Actions Workflow

This workflow runs on windows-latest, restores the package from the private feed, publishes the WPF project for win-x64 and keeps the result as an artifact of the run. Add the repository secrets TEXTCONTROL_FEED_URL (the feed URL https://www.textcontrol.com/nuget/v3/index.json), TEXTCONTROL_EMAIL (the email address of a licensed developer) and TEXTCONTROL_API_TOKEN (that developer's API token), save the workflow as .github/workflows/publish.yml, and change WpfApp/WpfApp.csproj to your project:

name: Publish

on:
  push:
    branches: [ "master" ]

jobs:
  publish:
    runs-on: windows-latest

    steps:
    - uses: actions/checkout@v4

    - name: Setup .NET
      uses: actions/setup-dotnet@v4
      with:
        dotnet-version: 8.0.x

    - name: Create nuget.config
      shell: pwsh
      run: |
        $content = @"
        <?xml version="1.0" encoding="utf-8"?>
        <configuration>
          <packageSources>
            <clear />
            <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
            <add key="TextControl" value="${{ secrets.TEXTCONTROL_FEED_URL }}" />
          </packageSources>
          <packageSourceCredentials>
            <TextControl>
              <add key="Username" value="${{ secrets.TEXTCONTROL_EMAIL }}" />
              <add key="ClearTextPassword" value="${{ secrets.TEXTCONTROL_API_TOKEN }}" />
            </TextControl>
          </packageSourceCredentials>
        </configuration>
        "@
        Set-Content -Path "nuget.config" -Value $content -Encoding utf8

    - name: Publish
      run: dotnet publish WpfApp/WpfApp.csproj -c Release -r win-x64 --self-contained false -o publish

    - name: Upload artifact
      uses: actions/upload-artifact@v4
      with:
        name: wpfapp-win-x64
        path: publish

What each step contributes:

  • runs-on: windows-latest selects a Windows agent for the WPF project.
  • Setup .NET installs the SDK. Set dotnet-version to the version your project targets, such as 10.0.x.
  • Create nuget.config writes the package sources and the credentials into the root of the repository at run time; neither appears in the repository or the log. The package the feed delivers carries your license, so no other license step is needed.
  • Publish restores, builds and publishes in one command. -r win-x64 places the 64-bit native libraries of TX Text Control in publish; use -r win-x86 for a 32-bit build.
  • Upload artifact keeps the publish folder, which holds no license file and no nuget.config.

Text Control's article Building a TX Text Control Project with GitHub Actions and the Text Control NuGet Feed shows where to find the email address and the token, how to add the secrets and how to run tests in the workflow.

Azure Pipelines

For Azure Pipelines, Text Control describes a pipeline for WPF and Windows Forms projects on a windows-latest agent that restores the package from Azure Artifacts with NuGetCommand@2 and builds with VSBuild@1. Build With Your Own Feed summarizes it, and the blog article Azure Pipelines with TX Text Control .NET for WPF and Windows Forms 32.0 with Azure DevOps and Artifacts has the complete YAML. Add the dotnet publish command of the workflow above as a script step to get a deployable folder.

.NET Framework Projects

A WPF project for the .NET Framework is licensed through licenses.licx and the license compiler, which needs the assemblies of an installed setup. Hosted agents can't run the setup, so the license is compiled once on a development machine and added to the project as an embedded resource; see .NET Framework Projects. Collect the files for deployment as Deploying .NET Framework Applications describes.

Pin the Package Version

Every build should restore the same package, so reference a fixed version of TXTextControl.TextControl.WPF.SDK, such as 34.0.5, and raise it deliberately when a service pack is released. Update to a New Service Pack describes the update.

Next Steps