Skip to content
Latchkey

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

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.

What this error means

The build fails with MSB4057 naming the missing target. It reproduces deterministically.

dotnet
error MSB4057: The target "PublishContainer" does not exist in the project.

Common causes

A typo or wrong target name

The /t: (or dotnet msbuild -t:) argument names a target that is spelled wrong or does not apply to this project type.

A missing import that defines the target

The target comes from an SDK or package import that is not referenced, so the target name resolves to nothing.

How to fix it

Use a defined target or add the import

  1. List available targets to confirm the correct name.
  2. Fix the /t: argument, or add the SDK/package that provides the target.
  3. Re-run the build.
shell
dotnet msbuild App.csproj -t:Help # or inspect targets via the build log

How to prevent it

  • Reference target names from documentation rather than memory.
  • Keep custom targets in imported .props/.targets that travel with the project.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →