25

MSBuild allows you to specify build-targets such as Build or Clean with -target:<build-target> (Example: MSBuild.exe -target:Clean).

Of course, a developer can define their own target using a .targets xml file.

However, some targets, such as Build or Clean, are pre-defined by Microsoft.

What is the list of all default pre-defined build-targets that are common for all .NET languages?

2
  • Good hint! So the default BeforeBuild and AfterBuild targets actually don't do anything unless we override them?
    – Pod Mo
    Commented Aug 30, 2019 at 5:20
  • 1
    Correct. BeforeBuild is defined as <Target Name="BeforeBuild"/>. AfterBuild is defined as <Target Name="AfterBuild"/>. They are just empty xml elements.
    – cowlinator
    Commented Aug 30, 2019 at 20:14

2 Answers 2

44

The standard build-targets that are common for all .NET languages are defined at Microsoft.Common.CurrentVersion.targets.

Here is the full list of build targets (as of Nov 12, 2020):

  • Build
  • Rebuild
  • Clean
  • Run
  • Publish
  • PublishOnly
  • ResolveReferences
  • ResolveProjectReferences
  • ResolveAssemblyReferences
  • GenerateBindingRedirects
  • PrepareResources
  • ResGen
  • Compile
  • GenerateManifests
  • PrepareForRun
  • CopyFilesToOutputDirectory
  • CoreBuild
  • BuildGenerateSources
  • BuildCompile
  • BuildLink
  • CopyRunEnvironmentFiles
  • BuildOnlySettings
  • PrepareForBuild
  • GetFrameworkPaths
  • GetReferenceAssemblyPaths
  • AssignLinkMetadata
  • PreBuildEvent
  • UnmanagedUnregistration
  • GetTargetFrameworkVersion
  • AssignProjectConfiguration
  • GetTargetPath
  • GetTargetPathWithTargetPlatformMoniker
  • GetNativeManifest
  • ResolveNativeReferences
  • GenerateBindingRedirects
  • GenerateBindingRedirectsUpdateAppConfig
  • ResolveSDKReferences
  • FindInvalidProjectReferences
  • ExpandSDKReferences
  • ExportWindowsMDFile
  • DesignTimeResolveAssemblyReferences
  • ResolveComReferences
  • PrepareResourceNames
  • AssignTargetPaths
  • GetItemTargetPaths
  • SplitResourcesByCulture
  • CreateCustomManifestResourceNames
  • ResolveKeySource
  • GenerateTargetFrameworkMonikerAttribute
  • GenerateAdditionalSources
  • GenerateSerializationAssemblies
  • CreateSatelliteAssemblies
  • GenerateSatelliteAssemblies
  • ComputeIntermediateSatelliteAssemblies
  • SetWin32ManifestProperties
  • GenerateApplicationManifest
  • GenerateDeploymentManifest
  • GetCopyToOutputDirectoryItems
  • UnmanagedRegistration
  • IncrementalClean
  • CleanReferencedProjects
  • CleanPublishFolder
  • PostBuildEvent
  • SetGenerateManifests
  • PublishBuild
  • AllProjectOutputGroups
  • BuiltProjectOutputGroup
  • DebugSymbolsProjectOutputGroup
  • DocumentationProjectOutputGroup
  • SatelliteDllsProjectOutputGroup
  • SourceFilesProjectOutputGroup
  • ContentFilesProjectOutputGroup
  • SGenFilesOutputGroup
  • GetResolvedSDKReferences
  • PriFilesOutputGroup
  • SDKRedistOutputGroup
  • GetInstalledSDKs
  • Restore
  • BeforeBuild
  • AfterBuild
  • BeforeRebuild
  • AfterRebuild
  • BeforeResolveReferences
  • AfterResolveReferences
  • BeforeResGen
  • AfterResGen
  • BeforeCompile
  • AfterCompile
  • BeforeClean
  • AfterClean
  • BeforePublish
  • AfterPublish

The targets that are prefixed with Before or After are intended to be overridden in projects.

2
  • Hi cowlinator, thanks for your sharing and please mark your reply as answer and that will help other community members who easier search this useful information, it just a reminder :)
    – LoLance
    Commented Sep 2, 2019 at 3:11
  • 2
    Msbuild also has the target restore learn.microsoft.com/en-us/nuget/consume-packages/…
    – juwens
    Commented Nov 12, 2020 at 10:53
4

You can use the command msbuild -targets to generate a list of current targets.

With dotnet it's dotnet build -targets.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.