Windows image updater

From rjmurillo/ai-agents · View interactive version

Windows image updater is an AI agent skill from the GitHub repository rjmurillo/ai-agents. Automates Windows container image migration for OneBranch pipelines. Bumps AdoPipelineGeneration package, regenerates pipeline configs via ConfigGen, and verifies old image reference is removed. Use for LTSC2019 to LTSC2022 migration, container image updates, OneBranch pipeline image upgrades. Do NO

How to use this skill

Skill file

Windows Image Updater

Automates the end-to-end workflow for migrating Windows container images (e.g., LTSC2019 → LTSC2022) in OneBranch pipeline repositories. Handles package bumping, config regeneration, build validation, and PR creation.


Triggers

Quick Reference

| Input | Output | Duration |

|-------|--------|----------|

| ADO repository (URL or local path) | Draft PR with updated pipeline ymls, passing pipelines | 30-60 min |


Prerequisites

Required Knowledge

| Term | Definition |

|------|------------|

| OneBranch | Microsoft's CI/CD build platform used for official builds and releases |

| ConfigGen | Configuration Generation tool that produces pipeline YAML files from package definitions |

| Topology project | A .NET project in resources repos that generates pipeline configs when run |

| LTSC | Long-Term Servicing Channel, a Windows release model (e.g., LTSC2019, LTSC2022) |

| Buddy build | Pre-merge validation pipeline that builds and tests changes before merge |

| Buddy release | Pre-merge pipeline that validates the release process before merge |

| CPM | Central Package Management, a NuGet feature where all versions are in Directory.Packages.props |

Required Tools

| Tool | Purpose | Verify |

|------|---------|--------|

| Git | Version control | git --version |

| .NET SDK | Build and run .NET projects | dotnet --version |

| ADO access | Repository write access, PR creation rights | az repos list |


Configuration

| Parameter | Default | Description |

|-----------|---------|-------------|

| Old image pattern | ltsc2019 | Pattern to detect in pipeline yml files |

| Expected new image | ltsc2022 | Expected replacement (for verification) |

| Package name | ConfigurationGeneration.AdoPipelineGeneration | NuGet package to bump |

| Branch name | feat/windows-image-update | Feature branch name |

| Props file | Directory.Packages.props | Primary package props file (fallback: Packages.props) |


Process

Phase 1: Repository Setup

Purpose: Establish a clean working environment with baseline build metrics.

  1. Clone or navigate to the repository

```bash

git clone <repo-url>

cd <repo-name>

```

  1. Ensure default branch with latest changes

```bash

git checkout main # or master, depending on repo

git pull origin main

```

  1. Create feature branch

```bash

git checkout -b feat/windows-image-update

```

  1. Run baseline build and record warnings

```bash

dotnet clean

dotnet build 2>&1 | tee build-baseline.log

dotnet test

```

  1. Capture baseline warnings for later comparison:

```powershell

dotnet build 2>&1 | Select-String "warning" | Out-File baseline-warnings.txt

```

Verification:

If build fails: STOP. The repository has pre-existing build issues. Report to user before proceeding.


Phase 2: Package Update

Purpose: Bump the AdoPipelineGeneration package and resolve any build conflicts.

  1. Find the package props file in the repository root

```bash

ls Directory.Packages.props 2>$null || ls Packages.props

```

  1. Locate ConfigurationGeneration.AdoPipelineGeneration in the props file

```bash

cd <path-to-topology-project-directory>

dotnet add package ConfigurationGeneration.AdoPipelineGeneration

cd <repo-root>

```

This will add the package reference. Then add a corresponding <PackageVersion> entry in the props file if using Central Package Management.

  1. Check latest available version

```bash

dotnet list package --outdated

```

Or check the NuGet feed directly for the latest version of ConfigurationGeneration.AdoPipelineGeneration.

  1. Update the version in the props file to the latest version
  1. Build and fix errors ONE AT A TIME

```bash

dotnet clean

dotnet build

```

CRITICAL: Incremental error resolution strategy.

Do NOT try to fix all errors at once. Fix one error at a time, then rebuild:

```

Loop:

1. Run dotnet build

2. If build succeeds → done, exit loop

3. Read the FIRST error in the output

4. Fix ONLY that first error (bump one package, fix one reference)

5. Go to step 1

```

Why one at a time? Fixing the first error (e.g., bumping one conflicting package) often resolves many transitive dependency errors downstream. If you try to fix all 20 errors at once, you may introduce new conflicts.

Common first-error fixes:

| Error | Fix |

|-------|-----|

| NU1605: Package downgrade detected | Bump the ONE conflicting package mentioned to the required version |

| NU1608: Detected package version outside of dependency constraint | Bump the ONE package mentioned in the constraint to latest version in the props file |

| NU1107: Version conflict detected | Pin the conflicting package directly in the project (add <PackageReference>) and/or bump the constraining package |

| CS0246: Type or namespace not found | A dependent package API changed; update the code reference |

After each single fix, rebuild. The error count should decrease significantly with each iteration.

Verification:

See: references/troubleshooting.md for detailed error resolution


Phase 3: Config Generation & Verification

Purpose: Regenerate pipeline files and verify the Windows container image reference is updated.

  1. Discover the ConfigGen/Topology project

Search for the project file:

```powershell

# Look for .csproj files with Topology or ConfigurationGeneration in the name

Get-ChildItem -Recurse -Filter "*.csproj" | Where-Object { $_.Name -match "Topology|ConfigurationGeneration" }

```

Decision guide, how to identify repo type:

| Repo Type | How to Identify | Project to Run |

|-----------|-----------------|----------------|

| Resources | Repo name contains .resources (e.g., MyService.resources) OR folder contains .resources in name | Topology project (e.g., *Topology*.csproj) |

| Service | Repo name does NOT contain .resources (e.g., MyService) | ConfigurationGeneration project (e.g., *ConfigurationGeneration*.csproj) |

| Combined | Single repo with a folder containing .resources in its name alongside service code | Run both if present; check which generates .pipelines/ output |

  1. Run the ConfigGen project

```bash

dotnet run --project <path-to-discovered-csproj>

```

This regenerates pipeline configuration files. Expect many file changes.

If the project targets multiple frameworks, specify the framework:

```bash

dotnet run --project <path-to-csproj> --framework net8.0

```

If Assembly.Load fails, build first and run from the output directory:

```powershell

dotnet build <path-to-csproj> --framework net8.0

Set-Location <path-to-csproj>\bin\Debug\net8.0

.\<ProjectName>.exe

```

  1. Verify the image update

Check that pipeline yml files no longer reference the old image:

```powershell

# Should return NO results

Get-ChildItem -Recurse -Path .pipelines -Filter "*.yml" | Select-String "ltsc2019"

Get-ChildItem -Recurse -Path .pipelines -Filter "*.yaml" | Select-String "ltsc2019"

```

The windowscontainerimage value should now contain ltsc2022 (or similar updated pattern).

  1. Run final validation

```bash

dotnet clean

dotnet build 2>&1 | tee build-final.log

dotnet test

```

  1. Compare warnings against Phase 1 baseline:

```powershell

dotnet build 2>&1 | Select-String "warning" | Out-File final-warnings.txt

Compare-Object (Get-Content baseline-warnings.txt) (Get-Content final-warnings.txt)

```

Empty diff or only resolved warnings = good. Any NEW warnings must be investigated.

Verification:

If image didn't change: Verify you bumped the correct package and ran the correct ConfigGen project. Re-run Phase 2 if needed.


Phase 4: PR Creation & Pipeline Validation

Purpose: Create a draft PR, validate through pipelines, and attach results.

  1. Stage and commit

```bash

git add -A

git commit -m "chore: update Windows container image from LTSC2019 to LTSC2022

Bumped ConfigurationGeneration.AdoPipelineGeneration to latest version

and regenerated pipeline configurations to use the updated Windows

container image, resolving the LTSC2019 end-of-life warning."

```

  1. Push to origin

```bash

git push -u origin feat/windows-image-update

```

  1. Create draft PR targeting the default branch

```

## Summary

Updated the Windows container image used in OneBranch pipelines from LTSC2019

(end-of-life) to LTSC2022.

## Changes

## Validation

## Work Items

```

  1. Attach work items (if provided by user)
  1. Invoke pipeline-validator skill for automated pipeline validation.

After the PR is created, the pipeline-validator skill takes over to:

1. Find the PR for the current branch

2. Validate the PR description has required sections (Summary, Changes, Validation)

3. Discover and trigger all associated pipelines (PR Build → Buddy Build → Buddy Release)

4. Auto-diagnose and fix any pipeline failures (up to 3 retries per pipeline)

5. Update the PR description with pipeline run links and results

6. Report final status

> Do not proceed manually. The pipeline-validator handles all pipeline monitoring, failure diagnosis, fix-and-retry loops, and PR description updates autonomously.

Verification:


Anti-Patterns

| Avoid | Why | Instead |

|-------|-----|---------|

| Manually editing pipeline yml files | They are generated by ConfigGen; manual edits will be overwritten | Always use package bump → ConfigGen workflow |

| Skipping baseline build | Cannot distinguish pre-existing vs new errors | Always run Phase 1 baseline first |

| Ignoring package downgrade errors | Downstream build will fail unpredictably | Fix all NU1605/NU1608 errors before ConfigGen |

| Creating non-draft PR | Premature review notifications before pipeline validation | Always create as draft first |

| Fixing all errors at once | One fix often resolves many downstream errors | Fix FIRST error, rebuild, repeat |

| Hardcoding ltsc2022 as the target | Next migration cycle will need different target | Use parameterized image names |


Verification

After complete execution:


Aborting / Rollback

| Failed At | Rollback Command |

|-----------|-----------------|

| Phase 1-2 (not pushed) | git checkout main && git branch -D feat/windows-image-update |

| Phase 3 (not pushed) | git reset --hard origin/main |

| Phase 4 (pushed, PR created) | Close the draft PR in ADO, delete the remote branch |


Extension Points

  1. Image name parameters: Change --old-image for future LTSC migrations (e.g., ltsc2022 → ltsc2025)
  2. Package name: Update the target package if ConfigGen is renamed
  3. Pipeline types: Add new pipeline validation steps as OneBranch evolves
  4. Multi-repo batch: Extend to process multiple repositories in sequence

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.