GeezerVison is showing github.com — Preserve archive links during installation (hardlinks on Windows, symlinks on Linux) by MichaelSimons · Pull Request #697 · dotnet/install-scripts
Conversation
Summary
Adds tar.gz archive support to dotnet-install.ps1 on Windows for .NET 11.0+, enabling archive-level optimizations like hard links that reduce disk footprint. Falls back to .zip for older versions or when tar is unavailable.
Fixes a bug in dotnet-install.sh where symbolic links in tarballs were silently dropped during extraction.
PowerShell script changes (dotnet-install.ps1)
- Tar detection —
Test-TarAvailable checks if tar is on PATH (skippable via DOTNET_INSTALL_SKIP_TAR=1 env var)
- Version-aware format selection —
Get-FileExtension-For-Version returns .tar.gz for .NET 11.0 preview 3+ and .zip for everything else
- Download URL construction — all download paths (SDK, runtime, aspnetcore, windowsdesktop) use the selected extension
- aka.ms link resolution — tries
.tar.gz first, falls back to .zip for symbolic channels (STS/LTS) where the version is not known upfront
- Tar extraction —
Extract-Dotnet-Package-Tar extracts with tar preserving hard links, applying the same versioned-directory skip and non-versioned file override logic as the existing zip extraction
Note on -KeepZip / -ZipPath parameter names
The existing -KeepZip and -ZipPath parameters now apply to both .zip and .tar.gz archives. The parameter names are intentionally not renamed to preserve backwards compatibility — existing scripts and automation that pass these parameters will continue to work without changes. The help text has been updated to clarify they apply to both formats.
Bash script changes (dotnet-install.sh)
The existing extract_dotnet_package function used find -type f to discover files after extracting to a temp directory. This skipped symbolic links (-type l) entirely, silently dropping them from the installation. On Linux, .NET tarballs contain relative symlinks that are important for the runtime layout.
Changes:
find -type f → find \( -type f -o -type l \) — symlinks are now discovered and copied
cp -R → cp -RP — explicitly preserves symlinks during copy (portable across GNU/BSD)
- Destination existence checks now detect dangling symlinks via
[ -L "$target" ]
Test changes
WindowsTarExtractionTests.cs (Windows-only)
Combined test class for all Windows tar extraction and format-selection scenarios:
- Synthetic tarball extraction with hard link preservation (verified via link count, not just content)
- Format selection: .NET 11.0+ →
.tar.gz; below 11.0 → .zip
- 11.0 preview 1-2 →
.zip; preview 3+ and RC → .tar.gz
DOTNET_INSTALL_SKIP_TAR=1 → .zip
- Channel-based and symbolic channel (LTS) aka.ms resolution
- windowsdesktop runtime support
- Verbose output reports tar availability
BashTarExtractionTests.cs (Unix-only)
Tests the bash script's extract_dotnet_package function directly using synthetic tarballs with symlinks:
- Symlinks in versioned directories are preserved
- Symlinks in non-versioned (root) locations are preserved
- Versioned directories containing only symlinks are extracted (key regression test — proves
find -type l is required)
- Cross-directory relative symlinks are preserved
TarExtractionTestsBase.cs (shared base class)
Abstract base class providing shared extraction test scenarios that run on both platforms:
- Basic extraction of versioned and non-versioned files
- Versioned directory skip logic (existing installs not overwritten)
- Non-versioned file override behavior (
OverrideNonVersionedFiles flag)
Test infrastructure
- Platform/prerequisite checks use
Assert.SkipWhen/Assert.SkipUnless so tests report as skipped (not passed) on non-applicable platforms
- Tarball creation uses .NET
TarWriter API (no subprocess dependencies for test setup)
Open questions
- Should we keep the 11.0 preview 1-2 special case? The script currently detects .NET 11.0 preview 1 and preview 2 and falls back to
.zip since Windows tarballs were not published until preview 3. An alternative is to simplify the version logic to treat all 11.0+ the same and require users installing those old previews to set DOTNET_INSTALL_SKIP_TAR=1. This would reduce long-term maintenance of version-specific edge cases. Note: the direct-version download path (as opposed to aka.ms) does not have a .tar.gz → .zip fallback, so removing this guard would cause failures for those specific versions without the env var override.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
MichaelSimons
changed the title
Support tar.gz archives on Windows for .NET 11.0+
Preserve archive links during installation (tar.gz on Windows, symlinks on Linux)
May 4, 2026
MichaelSimons
changed the title
Preserve archive links during installation (tar.gz on Windows, symlinks on Linux)
Preserve archive links during installation (hardlinks on Windows, symlinks on Linux)
May 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Enables better preservation of archive-level link semantics during installation: adds .tar.gz usage on Windows for .NET 11+ (when tar is available) and fixes Linux/macOS extraction so symlinks in tarballs aren’t silently dropped.
Changes:
- Add tar availability detection + version-aware archive format selection (
.tar.gz vs .zip) and tar extraction path to dotnet-install.ps1.
- Fix
dotnet-install.sh tar extraction to include symlinks in the file discovery step and preserve symlinks during copy.
- Add new test coverage for tar extraction behaviors (hard links on Windows, symlinks on Unix) and allow tests to inject environment variables into the install command runner.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File |
Description |
| tests/Install-Scripts.Test/WindowsTarExtractionTests.cs |
Adds Windows tar extraction tests and format-selection (dry-run) coverage, plus a tar-vs-zip layout comparison. |
| tests/Install-Scripts.Test/Utils/DotNetCommand.cs |
Extends the test command runner to accept and apply extra environment variables. |
| tests/Install-Scripts.Test/TestUtils.cs |
Adds a helper overload to create an install command with environment variables. |
| tests/Install-Scripts.Test/TarExtractionTestsBase.cs |
Introduces shared base tests for tar extraction behaviors (skip versioned dirs, override non-versioned files, etc.). |
| tests/Install-Scripts.Test/BashTarExtractionTests.cs |
Adds Unix-only tests validating symlink preservation via dotnet-install.sh’s extraction logic. |
| src/dotnet-install.sh |
Fixes extraction to discover symlinks and preserve them when copying into the install root; improves handling of existing/dangling symlinks. |
| src/dotnet-install.ps1 |
Adds tar detection, .tar.gz URL selection for .NET 11+, aka.ms extension fallback logic, and a tar extraction implementation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Fix symlink preservation in dotnet-install.sh by including -type l in find
- Add Windows tar extraction support with hard link preservation
- Restructure tar extraction tests with shared base class pattern:
WindowsTarExtractionTests (PowerShell, hard links) and
BashTarExtractionTests (bash, symlinks)
- Use .NET TarWriter API for test tarball creation instead of bash subprocesses
- Use Assert.SkipWhen/SkipUnless for platform-specific test skipping
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
v-HarithaVattikuti
pushed a commit
to actions/setup-dotnet
that referenced
this pull request
May 26, 2026
Update externals/install-dotnet.ps1 and externals/install-dotnet.sh to
the v2026.05.19 release of dotnet/install-scripts. This uptakes the
changes from dotnet/install-scripts#697 which preserves archive links
during installation (hardlinks on Windows, symlinks on Linux) as part
of dotnet/sdk#52182.
On Windows, .NET 11.0+ is now installed via tar.gz archives which
preserves hardlinks, significantly reducing disk space usage.
Co-authored-by: Copilot <[email protected]>
ellahathaway
added a commit
that referenced
this pull request
Jul 7, 2026
The signed PowerShell script contained two non-ASCII em dash characters (U+2014) in comments, introduced by #697. When Authenticode-signed without a BOM, non-ASCII content causes the file hash to fail validation across differing code pages, producing the 'hash does not match the digital signature' error under AllSigned policy. This is a recurrence of #541 (fixed in #543 by removing an emoji).
Replace the em dashes with ASCII hyphens and add a regression test that asserts both install scripts contain only ASCII bytes, guarding against a third recurrence.
Fixes #729
Co-authored-by: Copilot App <[email protected]>
Reviewers
+2 more reviewers
Reviewers whose approvals may not affect merge requirements
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|