Skip to content

feat(build-tools): detect .NET SDK version from csproj and migrate copilot setup to Linux#2091

Merged
Belphemur merged 3 commits into
devfrom
copilot/update-install-script-for-dependencies
May 6, 2026
Merged

feat(build-tools): detect .NET SDK version from csproj and migrate copilot setup to Linux#2091
Belphemur merged 3 commits into
devfrom
copilot/update-install-script-for-dependencies

Conversation

Copilot AI commented May 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Two related improvements to the local dev setup and Copilot cloud agent environment:

tools/Install-BuildTools.ps1

  • Adds a new Get-DotNetSdkVersion helper function that reads the TargetFramework from SoundSwitch/SoundSwitch.csproj using the same regex pattern already used by the CI workflows (reusable-build.yml, test-installer-build.yml).
  • Maps the detected major version to the winget package ID Microsoft.DotNet.SDK.<major> (e.g. Microsoft.DotNet.SDK.10 for net10.0-windows), so the correct SDK is always installed without hardcoding.
  • Adds step 6 in the install sequence to install the detected .NET SDK via winget.
  • Updates the synopsis/description and the post-install summary to reflect the new tool.

tools/Install-BuildTools.Tests.ps1

  • Adds 5 new Pester tests for Get-DotNetSdkVersion covering: net<major>.<minor>-windows TFM, plain net<major>.<minor> TFM, missing csproj, unparseable TFM, and file-read failure.
  • Updates the "defines expected helper functions" assertion to include Get-DotNetSdkVersion.
  • All 42 tests pass.

.github/workflows/copilot-setup-steps.yml

  • Migrates from windows-latest to ubuntu-latest.
  • Replaces the PowerShell XML-based framework detection with native bash grep -oP (same version output format).
  • Removes all shell: pwsh directives — all steps now use the default bash shell.

@Belphemur

Copy link
Copy Markdown
Owner

@copilot fix the copilot setup. Check CI/CD failure.

Copilot AI commented May 5, 2026

Copy link
Copy Markdown
Contributor Author

@copilot fix the copilot setup. Check CI/CD failure.

Fixed in d855493. The issue was GNU grep on Ubuntu doesn't support variable-length lookbehind assertions (\d{1,3}). Replaced the two-grep approach with a single sed -E 's/^net([0-9]+\.[0-9]+).*/\1.x/' which works correctly on all Linux/macOS variants.

@Belphemur

Copy link
Copy Markdown
Owner

@copilot do the right update for this to work:


Error: /usr/share/dotnet/sdk/10.0.203/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(120,5): error NETSDK1100: To build a project targeting Windows on this operating system, set the EnableWindowsTargeting property to true. [/home/runner/work/SoundSwitch/SoundSwitch/SoundSwitch.Common/SoundSwitch.Common.csproj]
Error: /usr/share/dotnet/sdk/10.0.203/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(120,5): error NETSDK1100: To build a project targeting Windows on this operating system, set the EnableWindowsTargeting property to true. [/home/runner/work/SoundSwitch/SoundSwitch/SoundSwitch.UI.Menu/SoundSwitch.UI.Menu.csproj]
Error: /usr/share/dotnet/sdk/10.0.203/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(120,5): error NETSDK1100: To build a project targeting Windows on this operating system, set the EnableWindowsTargeting property to true. [/home/runner/work/SoundSwitch/SoundSwitch/SoundSwitch/SoundSwitch.csproj]

Copilot AI commented May 6, 2026

Copy link
Copy Markdown
Contributor Author

@copilot do the right update for this to work:


...

Fixed in be066dc. Added -p:EnableWindowsTargeting=true to the dotnet restore step so Windows-targeting projects (net10.0-windows) build correctly on the Linux runner.

Copilot AI and others added 3 commits May 6, 2026 09:26
…pilot setup to Linux

- Add Get-DotNetSdkVersion to Install-BuildTools.ps1 that reads TargetFramework
  from SoundSwitch.csproj (same regex pattern as CI) and maps it to the winget
  package ID Microsoft.DotNet.SDK.<major>
- Install the detected .NET SDK as step 6 in Install-BuildTools.ps1
- Add 5 Pester tests for Get-DotNetSdkVersion; all 42 tests pass
- Migrate copilot-setup-steps.yml from windows-latest to ubuntu-latest with
  native bash framework detection (grep -oP) replacing the pwsh XML parsing

Agent-Logs-Url: https://github.com/Belphemur/SoundSwitch/sessions/49501ace-3311-42d4-ab6a-2efb42ad9da0

Co-authored-by: Belphemur <197810+Belphemur@users.noreply.github.com>
…NET version extraction

GNU grep on Ubuntu does not support variable-length lookbehinds (e.g.
(?<=^net\d{1,3}\.)). Replace the two-grep approach with a single sed
substitution: sed -E 's/^net([0-9]+\.[0-9]+).*/\1.x/' which is
portable across macOS and all Linux grep/sed versions.

Agent-Logs-Url: https://github.com/Belphemur/SoundSwitch/sessions/d93fc16a-0054-4e64-b394-eeeef35b11aa

Co-authored-by: Belphemur <197810+Belphemur@users.noreply.github.com>
@Belphemur Belphemur force-pushed the copilot/update-install-script-for-dependencies branch from be066dc to 8af7cce Compare May 6, 2026 13:26
@Belphemur Belphemur marked this pull request as ready for review May 6, 2026 13:26
Copilot AI review requested due to automatic review settings May 6, 2026 13:26
@Belphemur Belphemur merged commit 798f92c into dev May 6, 2026
12 of 14 checks passed
@Belphemur Belphemur deleted the copilot/update-install-script-for-dependencies branch May 6, 2026 13:29
Copilot AI removed the request for review from Copilot May 6, 2026 13:48
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.

2 participants