Skip to content

[Repo Assist] Fix project restore detection for nonstandard artifact locations#1040

Merged
nojaf merged 3 commits intomainfrom
repo-assist/fix-issue-592-restore-check-c9128fafc71d4d70
Feb 27, 2026
Merged

[Repo Assist] Fix project restore detection for nonstandard artifact locations#1040
nojaf merged 3 commits intomainfrom
repo-assist/fix-issue-592-restore-check-c9128fafc71d4d70

Conversation

@github-actions
Copy link
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

Fixes #592.

Root Cause

ensureProjectWasRestored in ProjectCracker.fs checks for project.assets.json at the conventional (projDir)/obj/project.assets.json path. If not found, it falls back to dotnet msbuild --getProperty:ProjectAssetsFile to ask MSBuild for the real path. However, there were two bugs:

  1. Logic bug: the try/with block wrapped both the MSBuild call and the subsequent failwithf for "not restored". So a "definitely not restored" error was caught and replaced with the less-informative "Failed to detect..." message.
  2. Overly strict: if the MSBuild call itself failed for any reason (e.g. old SDK without --getProperty support, or a non-standard project like dotnet/fsharp with custom artifact output), it hard-failed instead of proceeding. This made fsdocs unusable on such projects, even if the project was actually restored.

Fix

Restructure the detection to distinguish three cases:

  • MSBuild succeeds and assets file exists → OK, proceed
  • MSBuild succeeds but assets file doesn't exist → fail fast (project definitely not restored)
  • MSBuild call itself fails → emit a warning and proceed, letting the cracking step produce the definitive error

This follows the maintainer's suggestion on the issue: "make that failure a warning and let it fail hard later".

Changes

  • src/fsdocs-tool/ProjectCracker.fs: refactor ensureProjectWasRestored to separate the "can't detect" case from the "definitely not restored" case
  • RELEASE_NOTES.md: add entry under ### Fixed

Test Status

Build succeeded with dotnet build src/fsdocs-tool/fsdocs-tool.fsproj --configuration Release (0 errors, 2 pre-existing vulnerability warnings unrelated to this change).

This fix is behavioural and not easily covered by the existing unit-test suite (which doesn't test process-level restore detection). The change is safe: the only new behaviour is emitting a warning instead of throwing when MSBuild detection fails, so existing correctly-restored projects are unaffected.

Generated by Repo Assist for issue #592

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@afb00b92a9514fee9a14c583f059a03d05738f70

When a project doesn't place project.assets.json under <projDir>/obj/
(e.g. UseArtifactsOutput or projects like dotnet/fsharp with custom
output layout), the fallback MSBuild --getProperty call may itself fail.
Previously that failure was hard-coded to throw, making it impossible
to use fsdocs on such repos.

Following the maintainer suggestion from issue #592, change the
fallback so that:
- If MSBuild succeeds and reports an assets path that exists -> OK
- If MSBuild succeeds but the assets file doesn't exist -> fail fast
  (project definitely not restored)
- If MSBuild fails (e.g. old SDK, nonstandard project) -> warn and
  proceed, letting the cracking step produce the definitive error

Closes #592

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dsyme dsyme marked this pull request as ready for review February 26, 2026 19:11
@nojaf nojaf merged commit 90c087c into main Feb 27, 2026
4 checks passed
@nojaf nojaf deleted the repo-assist/fix-issue-592-restore-check-c9128fafc71d4d70 branch February 27, 2026 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The 'is project restored' check doesn't work for projects that use nonstandard locations

2 participants