# MSBuild "MSB4057: target does not exist in the project" in CI

> Fix MSBuild "MSB4057: The target X does not exist in the project" in CI - a /t: target name that is not defined for the project being built.

Source: https://latchkey.dev/learn/dotnet/dotnet-msb4057-target-does-not-exist-in-ci  
Updated: 2026-06-26

MSB4057 means a build invoked a target by name that the project (or its imports) does not define. It is a wiring problem: a typo in the /t: argument, a missing import that should provide the target, or invoking a target on the wrong project.

## Diagnose it: SDK version and restore first

Most .NET CI failures are an SDK mismatch or a restore that did not happen. `global.json` pins the SDK, and if the runner does not have that exact version the failure message is about the project rather than the SDK.

```Terminal
dotnet --info
cat global.json 2>/dev/null

# restore explicitly so a restore failure is not reported as a build failure
dotnet restore --verbosity normal
dotnet build --no-restore -warnaserror
```

> Pin the SDK with `global.json` and install exactly that version with `actions/setup-dotnet`. A floating SDK turns a runner image update into a build break on unchanged code.

## FAQ

### What causes MSBuild "MSB4057: target does not exist in the project" in CI?

There are 2 common causes: a typo or wrong target name and a missing import that defines the target. The /t: (or dotnet msbuild -t:) argument names a target that is spelled wrong or does not apply to this project type.

### How do I fix MSBuild "MSB4057: target does not exist in the project" in CI?

Use a defined target or add the import. List available targets to confirm the correct name.

### What does MSBuild "MSB4057: target does not exist in the project" in CI actually mean?

The build fails with MSB4057 naming the missing target.

### How do I stop MSBuild "MSB4057: target does not exist in the project" in CI happening again?

Reference target names from documentation rather than memory. The prevention section lists 2 changes that keep it from recurring.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
