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
- List available targets to confirm the correct name.
- Fix the
/t:argument, or add the SDK/package that provides the target. - Re-run the build.
shell
dotnet msbuild App.csproj -t:Help # or inspect targets via the build logHow 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
MSBuild "MSB1003: specify a project or solution file" in CIFix MSBuild "MSB1003: Specify a project or solution file. The current working directory does not contain one"…
MSBuild "MSB4018: The X task failed unexpectedly" in CIFix MSBuild "MSB4018: The X task failed unexpectedly" in CI - a build task threw an unhandled exception, ofte…
MSBuild "MSB4181: task returned false but did not log an error" in CIFix MSBuild "MSB4181: The X task returned false but did not log an error" in CI - a wrapped task failed silen…