Skip to content
Latchkey

MSBuild "MSB1009: Project file does not exist" in CI

MSBuild was given a project or solution path that does not exist at that location. The named .csproj/.sln is wrong, the working directory is unexpected, or the file was never checked out.

What this error means

A dotnet build/restore/test step fails instantly with MSB1009: Project file does not exist and the Switch: line shows the path it tried. Nothing builds because MSBuild never found the project.

MSBuild output
MSBUILD : error MSB1009: Project file does not exist.
Switch: src/MyApp/MyApp.csproj

Common causes

Wrong path or working directory

The path passed to dotnet is relative to a different directory than the step runs in, or has a typo, so the file is not where MSBuild looks.

File not checked out or generated

A sparse checkout, a wrong working-directory, or a project meant to be generated by an earlier step means the .csproj/.sln is absent.

How to fix it

Pass a correct, repo-relative path

Point the command at the actual project/solution path from the repo root.

Terminal
dotnet build ./src/MyApp/MyApp.csproj -c Release
# verify it exists first
ls ./src/MyApp/MyApp.csproj

Set the working directory explicitly

Make the step run where the path resolves, or use an absolute path.

.github/workflows/ci.yml
- run: dotnet build MyApp.csproj -c Release
  working-directory: src/MyApp

How to prevent it

  • Reference projects/solutions by explicit repo-relative paths in CI.
  • Set working-directory deliberately for steps that build a subproject.
  • Ensure checkout includes the project files (watch for sparse/partial checkouts).

Frequently asked questions

What causes ""MSB1009: Project file does not exist""?
The path passed to dotnet is relative to a different directory than the step runs in, or has a typo, so the file is not where MSBuild looks.
How do I fix "MSB1009: Project file does not exist"?
Point the command at the actual project/solution path from the repo root.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card