Edit

Share via


MSB1004 diagnostic code

This article describes the MSB1004 error code.

Message text

MSB1004: Specify the name of the target.

Description

This error occurs when the MSBuild command line contains a -targets or -t switch, which is used to request a specific target to build, but no target was specified.

Resolution

Provide the target name that you want to build by putting it just after the -t or -targets switch. If that isn't the problem, check for typos in the command-line syntax, such as mismatched quotes or unintended shell escape characters. If you're constructing the MSBuild command line using an environment variable or shell script, check that the environment variable exists, has a value, and is referenced using the correct shell-specific syntax.

Possible targets might be defined in the project file itself. These appear with syntax like <Target Name="MyTarget">, which begins the specification of a target in the project file. Or, you can specify a target from of the system-provided target files. These are files, typically with the .targets extension, such as Microsoft.Common.targets, Microsoft.Common.CSharp.targets, and so on in the MSBuild installation folders. If you're using a project SDK (for example, you used the Sdk="Microsoft.Net.Sdk" attribute on the Project node in the project file), these system .targets files are imported implicitly.

If you don't know what the name of your desired target is, or what target you want to build, try issuing the command MSBuild.exe -targets, which generates a list of available targets, but doesn't run the build.

For more information, see MSBuild targets.

Applies to

All versions of MSBuild