'What are the existing build targets for MSBuild?

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?



Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1