Skip to content

Conversation

yeelam-gordon
Copy link
Contributor

Description

  1. Build from any Command Prompt or PowerShell (no VS 2022 Developer Command Prompt required), helping folks who prefer VS Code
  2. UpdateVersion auto-resolves the correct NuGet package version (no more pre-downloading package folders)
  3. Copilot works seamlessly in both Visual Studio and VS Code with the new copilot-instructions.md

Build system modernization:

  • Introduced a new build.ps1 PowerShell script that replaces the logic previously in build.cmd, providing robust solution discovery, environment initialization, NuGet package management, and MSBuild invocation with improved diagnostics and usage documentation. (build.ps1)
  • Refactored build.cmd to become a thin wrapper that simply invokes build.ps1, removing all direct build, restore, and timing logic from the batch script. (build.cmd)

Versioning improvements:

  • Updated UpdateVersions.ps1 to require the WinAppSDKVersion parameter and add logic to ensure the necessary NuGet packages are downloaded and available before proceeding, improving reliability for version bumps. (UpdateVersions.ps1)

Contributor guidance:

  • Added a new .github/copilot-instructions.md file documenting build usage, versioning steps, coding guidelines, PR process, and design doc practices to ensure consistent and high-quality contributions. (.github/copilot-instructions.md)

Target Release

Please specify which release this PR should align >=1.8

Checklist

Note that /azp run currently isn't working for this repo.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR modernizes the build system for WindowsAppSDK-Samples by introducing a new PowerShell-based build script, improving version management, and adding contributor guidance.

  • Refactored build system from batch to PowerShell with automatic environment detection and improved diagnostics
  • Enhanced UpdateVersions.ps1 to require WinAppSDKVersion parameter and auto-download necessary NuGet packages
  • Added comprehensive contributor guidance in .github/copilot-instructions.md

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
build.ps1 New PowerShell build script with robust solution discovery, VS environment initialization, and MSBuild invocation
build.cmd Refactored to thin wrapper that calls build.ps1, removing complex batch logic
UpdateVersions.ps1 Made WinAppSDKVersion parameter mandatory and added automatic NuGet package installation
.github/copilot-instructions.md New contributor guidance covering build usage, versioning, coding guidelines, and PR processes

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

./build.ps1 -Platform arm64 -Configuration Debug -Sample AppLifecycle
(Build only the AppLifecycle sample solutions for arm64 Debug.)
#>
#[CmdletBinding()] parameters
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment '#[CmdletBinding()] parameters' is grammatically incorrect. It should be '#[CmdletBinding()] param' or a more descriptive comment like '# Parameters definition'.

Suggested change
#[CmdletBinding()] parameters
# Parameters definition

Copilot uses AI. Check for mistakes.

Comment on lines +112 to +125
# Restore-Solution: Perform NuGet restore for a solution (.sln) using repo nuget.exe.
function Restore-Solution { param([string]$SolutionPath)
Write-Host "Restoring: $SolutionPath" -ForegroundColor Cyan
& $nugetExe restore $SolutionPath -ConfigFile (Join-Path $samplesRoot 'nuget.config') -PackagesDirectory $packagesDir
if ($LASTEXITCODE -ne 0) { Write-Error 'NuGet restore failed.'; exit $LASTEXITCODE }
}

# Build-Solution: Invoke MSBuild on a solution with platform/config and emit binlog.
function Build-Solution { param([string]$SolutionPath,[string]$Platform,[string]$Configuration)
$binlog = Join-Path (Split-Path $SolutionPath -Parent) ("{0}.binlog" -f ([IO.Path]::GetFileNameWithoutExtension($SolutionPath)))
Write-Host "Building: $SolutionPath" -ForegroundColor Cyan
& msbuild /warnaserror /p:Platform=$Platform /p:Configuration=$Configuration /p:NugetPackageDirectory=$packagesDir /bl:"$binlog" "$SolutionPath"
if ($LASTEXITCODE -ne 0) { Write-Error 'MSBuild failed.'; exit $LASTEXITCODE }
}
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent indentation: this function and the following Build-Solution function have an extra leading space compared to other functions. All functions should use consistent indentation.

Suggested change
# Restore-Solution: Perform NuGet restore for a solution (.sln) using repo nuget.exe.
function Restore-Solution { param([string]$SolutionPath)
Write-Host "Restoring: $SolutionPath" -ForegroundColor Cyan
& $nugetExe restore $SolutionPath -ConfigFile (Join-Path $samplesRoot 'nuget.config') -PackagesDirectory $packagesDir
if ($LASTEXITCODE -ne 0) { Write-Error 'NuGet restore failed.'; exit $LASTEXITCODE }
}
# Build-Solution: Invoke MSBuild on a solution with platform/config and emit binlog.
function Build-Solution { param([string]$SolutionPath,[string]$Platform,[string]$Configuration)
$binlog = Join-Path (Split-Path $SolutionPath -Parent) ("{0}.binlog" -f ([IO.Path]::GetFileNameWithoutExtension($SolutionPath)))
Write-Host "Building: $SolutionPath" -ForegroundColor Cyan
& msbuild /warnaserror /p:Platform=$Platform /p:Configuration=$Configuration /p:NugetPackageDirectory=$packagesDir /bl:"$binlog" "$SolutionPath"
if ($LASTEXITCODE -ne 0) { Write-Error 'MSBuild failed.'; exit $LASTEXITCODE }
}
# Restore-Solution: Perform NuGet restore for a solution (.sln) using repo nuget.exe.
function Restore-Solution { param([string]$SolutionPath)
Write-Host "Restoring: $SolutionPath" -ForegroundColor Cyan
& $nugetExe restore $SolutionPath -ConfigFile (Join-Path $samplesRoot 'nuget.config') -PackagesDirectory $packagesDir
if ($LASTEXITCODE -ne 0) { Write-Error 'NuGet restore failed.'; exit $LASTEXITCODE }
}
# Build-Solution: Invoke MSBuild on a solution with platform/config and emit binlog.
function Build-Solution { param([string]$SolutionPath,[string]$Platform,[string]$Configuration)
$binlog = Join-Path (Split-Path $SolutionPath -Parent) ("{0}.binlog" -f ([IO.Path]::GetFileNameWithoutExtension($SolutionPath)))
Write-Host "Building: $SolutionPath" -ForegroundColor Cyan
& msbuild /warnaserror /p:Platform=$Platform /p:Configuration=$Configuration /p:NugetPackageDirectory=$packagesDir /bl:"$binlog" "$SolutionPath"
if ($LASTEXITCODE -ne 0) { Write-Error 'MSBuild failed.'; exit $LASTEXITCODE }
}

Copilot uses AI. Check for mistakes.

Comment on lines +119 to +120
# Build-Solution: Invoke MSBuild on a solution with platform/config and emit binlog.
function Build-Solution { param([string]$SolutionPath,[string]$Platform,[string]$Configuration)
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent indentation: this function has an extra leading space compared to other functions. All functions should use consistent indentation.

Suggested change
# Build-Solution: Invoke MSBuild on a solution with platform/config and emit binlog.
function Build-Solution { param([string]$SolutionPath,[string]$Platform,[string]$Configuration)
# Build-Solution: Invoke MSBuild on a solution with platform/config and emit binlog.
function Build-Solution { param([string]$SolutionPath,[string]$Platform,[string]$Configuration)

Copilot uses AI. Check for mistakes.

)

# Prerequisites
# If the NuGetPackagesFolder parameter wasn't provided,
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment has a trailing comma that should be removed for proper grammar.

Suggested change
# If the NuGetPackagesFolder parameter wasn't provided,
# If the NuGetPackagesFolder parameter wasn't provided

Copilot uses AI. Check for mistakes.

@yeelam-gordon yeelam-gordon changed the title User/yeelam/updateversions release experimental Refactor build/versioning: shell-agnostic builds, auto NuGet versioning, and Copilot-ready workflow Sep 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant