Discover solution file explicitly in Stage 2 (Windows)#316
Closed
Chris-Wolfgang wants to merge 1 commit into
Closed
Discover solution file explicitly in Stage 2 (Windows)#316Chris-Wolfgang wants to merge 1 commit into
Chris-Wolfgang wants to merge 1 commit into
Conversation
Bare 'dotnet restore' / 'dotnet build --no-restore' in Stage 2 ran
from the repo root and failed in two scenarios:
1. MSB1003 ("Specify a project or solution file") — repos whose
solution lives in a subfolder (e.g. console-app-template's
src/ConsoleAppTemplate.sln). The repo root has no solution and
dotnet refuses to guess.
2. MSB1011 ("Specify which project or solution file to use") — repos
with multiple solution files at root (e.g. IEquatable-Extensions
has both 'IEquatable Extensions.slnx' and 'Solution.slnx').
Replace the bare commands with explicit solution discovery via
'git ls-files'. Preference order: .slnx (newer XML-based format)
first, then .sln. Among multiple candidates of the same extension,
pick the alphabetically-first via 'head -1' — git ls-files emits in
sorted order, so this naturally prefers root-level over nested
where extensions match.
Falls back to bare 'dotnet restore' if no solution file exists at
all (the build still has to fail loudly in that case — there is no
sensible default).
This subsumes the per-repo fix in Chris-Wolfgang/IEquatable-Extensions#61
which can be closed once this lands and propagates.
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.
Summary
Replaces bare
dotnet restore/dotnet build --no-restorein Stage 2 with explicit solution discovery viagit ls-files. Fixes failures across two related symptoms.Problem
Stage 2's restore/build steps run from the repo root with no solution argument.
dotnetthen has to guess what to build, which fails in two real scenarios:MSB1003: Specify a project or solution fileconsole-app-templatesrc/ConsoleAppTemplate.sln); repo root has nothingMSB1011: Specify which project or solution file to useIEquatable-ExtensionsIEquatable Extensions.slnx+Solution.slnx)Fix
Discover the solution file before running
dotnet:Preference order:
.slnx(newer XML-based format) before.slnhead -1(git emits in sorted order, so this naturally prefers root-level over nested when extensions match)dotnet restoreonly if no solution exists at all (the build still has to fail loudly in that case — there is no sensible default)Same logic in both
Restore dependenciesandBuild solutionsteps.shell: bashis set explicitly because Windows runners default topwsh, but bash quoting around space-containing solution names (e.g.IEquatable Extensions.slnx) is more reliable.Subsumes
IEquatable-Extensions#61 — the per-repo fix forMSB1011. Once this template change propagates, that PR can be closed.Test plan
.slnxconsole-app-template(nested solution)IEquatable-Extensions(multiple solutions)🤖 Generated with Claude Code