Repository navigation
fix(tool): detect dotnet packs cross-platform - #241
Closed
VanHerckArnaud wants to merge 1 commit into
Closed
VanHerckArnaud wants to merge 1 commit into
VanHerckArnaud wants to merge 1 commit into
Conversation
Author
|
Verified this against a real project as well, in addition to the smoke test above. Setup
Result
So the default packs-path detection also works with the Homebrew install layout, not just the standard |
VanHerckArnaud
force-pushed
the
fix/macos-packs-path
branch
from
October 9, 2026 10:02
995a602 to
e66d0da
Compare
PerfectlyNormal
added a commit
that referenced
this pull request
Oct 11, 2026
Fixes #241 Co-authored-by: Arnaud Van Herck <me@nobody.com> Co-authored-by: VanHerckArnaud
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
On macOS (and Linux), the tool exits with:
Two root causes, both in
TypeContractor.Tool:ReflectionContextHelper.GetNetCorePackjoined paths with a literal backslash (@$"{packPath}\{packName}"). On Unix a backslash is a filename character, not a directory separator, so the lookup directory never exists.--packs-pathoption inProgram.csdefaulted to the Windows-only pathC:\Program Files\dotnet\packs\.Fix
ReflectionContextHelper.cs:47— join withPath.Combine(packPath, packName), which uses the host separator and preserves Windows behavior.ReflectionContextHelper.GetDefaultPacksPath(), which derives<dotnet-root>/packsfromRuntimeEnvironment.GetRuntimeDirectory()(up three levels fromshared/Microsoft.NETCore.App/<version>/, thenpacks). This matches the standard layout on Windows, macOS, and Linux.Program.cs—--packs-pathnow falls back toGetDefaultPacksPath(). Explicit--packs-pathandpacks-pathconfig-file values keep precedence as before.InternalsVisibleTo("TypeContractor.Tests")on the tool project plus a project reference from the test project. No public API changes.Tests
New
TypeContractor.Tests/Tool/ReflectionContextHelperTests.cs:GetNetCorePack_Joins_Pack_Path_Without_Backslash— builds a fakeMicrosoft.NETCore.App.Ref/10.0.1/ref/net10.0tree under a temp dir withPath.Combineand asserts the resolved path. Verified it fails against the old backslash implementation and passes with the fix.GetDefaultPacksPath_Exists_And_Contains_NetCore_Ref_Pack— asserts the auto-detected packs dir exists and containsMicrosoft.NETCore.App.Refagainst the real SDK layout.Full suite green locally on macOS, Ubuntu CI expected to match since CI installs the SDKs before running tests.
Smoke test (macOS, no
--packs-path)Packed
0.22.2-local.1locally (dotnet pack+dotnet tool installfrom a temp source), then ran it against a minimal net10.0 DTO controller assembly:0, noMicrosoft.NETCore.App.Ref/Microsoft.AspNetCore.App.Referrors; debug log shows both resolved from the detected default (~/.dotnet/packs/...).smoke/weather-dto.tswith the expected interface.--packs-pathoverride re-run also exits0.