← all demos
// ***********************************************************************************************
// Microsoft.Common.CurrentVersion.targets
//
// WARNING:  DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
// created a backup copy.  Incorrect changes to this file will make it
// impossible to load or build your projects from the command-line or the IDE.
//
// This file defines the steps in the standard build process for .NET projects.  It
// contains all the steps that are common among the different .NET languages, such as
// Visual Basic, and Visual C#.
//
// Copyright (C) Microsoft Corporation. All rights reserved.
// ***********************************************************************************************
Project(DefaultTargets="Build", TreatAsLocalProperty="OutDir")
  if '$(MicrosoftCommonPropsHasBeenImported)' != 'true' and Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props'):
    Import "$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"
  PropertyGroup
    if '$(ImportByWildcardBeforeMicrosoftCommonTargets)' == '':
      ImportByWildcardBeforeMicrosoftCommonTargets = true
    if '$(ImportByWildcardAfterMicrosoftCommonTargets)' == '':
      ImportByWildcardAfterMicrosoftCommonTargets = true
    if '$(ImportUserLocationsByWildcardBeforeMicrosoftCommonTargets)' == '':
      ImportUserLocationsByWildcardBeforeMicrosoftCommonTargets = true
    if '$(ImportUserLocationsByWildcardAfterMicrosoftCommonTargets)' == '':
      ImportUserLocationsByWildcardAfterMicrosoftCommonTargets = true
  if '$(ImportUserLocationsByWildcardBeforeMicrosoftCommonTargets)' == 'true' and exists('$(MSBuildUserExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.targets\ImportBefore'):
    Import "$(MSBuildUserExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.targets\ImportBefore\*"
  if '$(ImportByWildcardBeforeMicrosoftCommonTargets)' == 'true' and exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.targets\ImportBefore'):
    Import "$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.targets\ImportBefore\*"
  if Exists('$(MSBuildProjectFullPath).user'):
    Import "$(MSBuildProjectFullPath).user"
  // VS10 without SP1 and without VS11 will not have VisualStudioVersion set, so do that here
  PropertyGroup
    if '$(VisualStudioVersion)' == '':
      VisualStudioVersion = 10.0
  PropertyGroup
    if '$(CustomBeforeMicrosoftCommonTargets)'=='':
      CustomBeforeMicrosoftCommonTargets = $(MSBuildExtensionsPath)\v$(MSBuildToolsVersion)\Custom.Before.Microsoft.Common.targets
    if '$(CustomAfterMicrosoftCommonTargets)'=='':
      CustomAfterMicrosoftCommonTargets = $(MSBuildExtensionsPath)\v$(MSBuildToolsVersion)\Custom.After.Microsoft.Common.targets
    if '$(ReportingServicesTargets)'=='':
      ReportingServicesTargets = $(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\ReportingServices\Microsoft.ReportingServices.targets
  if '$(CustomBeforeMicrosoftCommonTargets)' != '' and Exists('$(CustomBeforeMicrosoftCommonTargets)'):
    Import "$(CustomBeforeMicrosoftCommonTargets)"
  // By default, we are creating a managed app because .NET 2.0 projects did not have this property.
  if '$(TargetRuntime)' == '':
    PropertyGroup
      TargetRuntime = Managed
  // Because .NET 2.0 apps did not set TargetFrameworkIdentifier, we need to set it for them here by default.  If
  // the runtime is set to Managed, we also need to set these.  Otherwise they should be blank (for instance Javascript or
  // Native apps) because they do not target a .NET Framework.
  if '$(TargetRuntime)' == 'Managed':
    PropertyGroup
      if '$(TargetFrameworkIdentifier)' == '':
        TargetFrameworkIdentifier = .NETFramework
      if '$(TargetFrameworkVersion)' == '':
        TargetFrameworkVersion = v4.0
  // AvailablePlatforms is the list of platform targets available.
  PropertyGroup
    if '$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '':
      AvailablePlatforms = Any CPU,x86,x64,Itanium
    if '$(VisualStudioVersion)' != '' and '$(VisualStudioVersion)' > '10.0':
      AvailablePlatforms = Any CPU,x86,x64
  // Import depends on if it is .NETCore. Imports for .NETFramework is a superset of that for .NETCore
  if '$(TargetFrameworkIdentifier)' == '.NETFramework' or '$(TargetFrameworkIdentifier)' == 'Silverlight':
    Import "Microsoft.NETFramework.props"
  if '$(TargetFrameworkIdentifier)' == '.NETStandard' or '$(TargetFrameworkIdentifier)' == '.NETCoreApp':
    Import "Microsoft.NET.props"
  PropertyGroup
    // Generates full paths for the 'File' property in errors, warnings and messages in many targets
    if '$(GenerateFullPaths)' == '':
      GenerateFullPaths = true
    // Yield optimization properties
    if '$(YieldDuringToolExecution)' == '':
      YieldDuringToolExecution = true
  if '$(TargetFrameworkIdentifier)' != '' and '$(TargetFrameworkVersion)' != '':
    PropertyGroup
      if '$(TargetFrameworkMoniker)' == '' and '$([System.String]::IsNullOrWhitespace($(TargetFrameworkProfile)))' != 'true':
        TargetFrameworkMoniker = $(TargetFrameworkIdentifier),Version=$(TargetFrameworkVersion),Profile=$(TargetFrameworkProfile)
      if '$(TargetFrameworkMoniker)' == '':
        TargetFrameworkMoniker = $(TargetFrameworkIdentifier),Version=$(TargetFrameworkVersion)
      // When working off a packaged reference assemblies, do not go to machine-global locations. This property is target-framework-specific, so it cannot be overridden in msbuild.exe.config once and for all.
      if '$(EnableFrameworkPathOverride)' != 'false' And '$(FrameworkPathOverride)' == '' And Exists('$(TargetFrameworkRootPath)$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)'):
        FrameworkPathOverride = $(TargetFrameworkRootPath)$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)
      // The FrameworkPathOverride is required for the inproc visual basic compiler to initialize when targeting target frameworks less than 4.0. If .net 2.0 is not installed then the property value above will not provide the location
      // of mscorlib. This is also true if the build author overrides this property to some other directory which does not contain mscorlib.dll. In the case we cannot find mscorlib.dll at the correct location
      // we need to find a directory which does contain mscorlib to allow the inproc compiler to initialize and give us the chance to show certain dialogs in the IDE (which only happen after initialization).
      if '$(EnableFrameworkPathOverride)' != 'false' And '$(FrameworkPathOverride)' == '':
        FrameworkPathOverride = $([Microsoft.Build.Utilities.ToolLocationHelper]::GetPathToStandardLibraries($(TargetFrameworkIdentifier), $(TargetFrameworkVersion), $(TargetFrameworkProfile), $(PlatformTarget), $(TargetFrameworkRootPath), $(TargetFrameworkFallbackSearchPaths)))
      if '$(EnableFrameworkPathOverride)' != 'false' And !Exists('$(FrameworkPathOverride)\mscorlib.dll'):
        FrameworkPathOverride = $(MSBuildFrameworkToolsPath)
  PropertyGroup
    if '$(TargetPlatformIdentifier)' == '' and '$(_EnableDefaultWindowsPlatform)' != 'false':
      TargetPlatformIdentifier = Windows
    if '$(TargetPlatformVersion)' == '' and '$(_EnableDefaultWindowsPlatform)' != 'false':
      TargetPlatformVersion = 7.0
    if '$(TargetPlatformSdkPath)' == '' and '$(TargetPlatformSdkRootOverride)' != '':
      TargetPlatformSdkPath = $(TargetPlatformSdkRootOverride)\
    if '$(TargetPlatformSdkPath)' == '' and '$(TargetPlatformIdentifier)' == 'Windows' and $([MSBuild]::IsOSPlatform('Windows')) and '$(MSBuildRuntimeType)' != 'Core':
      TargetPlatformSdkPath = $([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\Software\Microsoft\Microsoft SDKs\Windows\v$(TargetPlatformVersion)', InstallationFolder, null, RegistryView.Registry32, RegistryView.Default))
    if '$(TargetPlatformSdkPath)' == '':
      TargetPlatformSdkPath = $([Microsoft.Build.Utilities.ToolLocationHelper]::GetPlatformSDKLocation($(TargetPlatformIdentifier), $(TargetPlatformVersion)))
    if '$(TargetPlatformSdkMetadataLocation)' == '' and Exists('$(TargetPlatformSdkPath)'):
      TargetPlatformSdkMetadataLocation = $(TargetPlatformSdkPath)Windows Metadata
    if Exists('$(TargetPlatformSdkPath)') and ('$(TargetPlatformSdkMetadataLocation)' == '' or !Exists('$(TargetPlatformSdkMetadataLocation)')):
      TargetPlatformSdkMetadataLocation = $(TargetPlatformSdkPath)References\CommonConfiguration\Neutral
    if '$(TargetPlatformWinMDLocation)' == '' and Exists('$(TargetPlatformSdkMetadataLocation)'):
      TargetPlatformWinMDLocation = $(TargetPlatformSdkMetadataLocation)
    if '$(UseOSWinMdReferences)' == '' and ('$(TargetPlatformWinMDLocation)' == '' and '$(TargetPlatformIdentifier)' == 'Windows' and '$(TargetPlatformVersion)' > '7.0'):
      UseOSWinMdReferences = true
    if '$(UseOsWinMdReferences)' == 'true':
      TargetPlatformWinMDLocation = $(WinDir)\System32\WinMetadata
    if '$(TargetPlatformMoniker)' == '' and '$(TargetPlatformIdentifier)' != '' and '$(TargetPlatformVersion)' != '':
      TargetPlatformMoniker = $(TargetPlatformIdentifier),Version=$(TargetPlatformVersion)
    if '$(TargetPlatformDisplayName)' == '':
      TargetPlatformDisplayName = $([Microsoft.Build.Utilities.ToolLocationHelper]::GetPlatformSDKDisplayName($(TargetPlatformIdentifier), $(TargetPlatformVersion)))
  // Several properties must be set in the main project file, before using this .TARGETS file.
  // However, if the properties are not set, we pick some defaults.
  //
  // OutDir:
  // Indicates the final output location for the project or solution. When building a solution,
  // OutDir can be used to gather multiple project outputs in one location. In addition,
  // OutDir is included in AssemblySearchPaths used for resolving references.
  //
  // BaseOutputPath:
  // This is the top level folder where all configuration specific output folders will be created.
  // Default value is bin\
  //
  // OutputPath:
  // This is the full Output Path, and is derived from BaseOutputPath, if none specified
  // (eg. bin\Debug). If this property is overridden, then setting BaseOutputPath has no effect.
  //
  // For Legacy projects using only Common targets, this property is usually specified in the project file
  // and is used to initialize OutDir. Some SDKs including the .NET SDK derive this automatically.
  // OutDir and OutputPath are distinguished for legacy reasons, and OutDir should be used if at all possible.
  //
  // BaseIntermediateOutputPath:
  // This is the top level folder where all configuration specific intermediate output folders will be created.
  // Default value is obj\
  //
  // IntermediateOutputPath:
  // This is the full intermediate Output Path, and is derived from BaseIntermediateOutputPath, if none specified
  // (eg. obj\Debug). If this property is overridden, then setting BaseIntermediateOutputPath has no effect.
  //
  // Ensure any and all path property has a trailing slash, so it can be concatenated.
  PropertyGroup
    // Example, AnyCPU
    _OriginalPlatform = $(Platform)
    // Example, Debug
    _OriginalConfiguration = $(Configuration)
    // Check whether OutputPath was specified for valid Configuration/Platform combination
    if '$(_OriginalPlatform)' != '' and '$(_OriginalConfiguration)' != '' and '$(OutputPath)' == '':
      _OutputPathWasMissing = true
    // Check whether BaseOutputPath was specified
    if '$(BaseOutputPath)' != '':
      BaseOutputPathWasSpecified = true
  PropertyGroup
    if '$(Platform)' == '':
      Platform = AnyCPU
    if '$(PlatformName)' == '':
      PlatformName = $(Platform)
    if '$(Configuration)' == '':
      Configuration = Debug
    if '$(ConfigurationName)' == '':
      ConfigurationName = $(Configuration)
    if '$(BaseOutputPath)' == '':
      BaseOutputPath = bin\
    if !HasTrailingSlash('$(BaseOutputPath)'):
      BaseOutputPath = $(BaseOutputPath)\
    if '$(OutputPath)' == '' and '$(PlatformName)' == 'AnyCPU':
      OutputPath = $(BaseOutputPath)$(Configuration)\
    if '$(OutputPath)' == '' and '$(PlatformName)' != 'AnyCPU':
      OutputPath = $(BaseOutputPath)$(PlatformName)\$(Configuration)\
    if !HasTrailingSlash('$(OutputPath)'):
      OutputPath = $(OutputPath)\
    if '$(BaseIntermediateOutputPath)' == '':
      BaseIntermediateOutputPath = obj\
    if !HasTrailingSlash('$(BaseIntermediateOutputPath)'):
      BaseIntermediateOutputPath = $(BaseIntermediateOutputPath)\
    if '$(IntermediateOutputPath)' == '' and '$(PlatformName)' == 'AnyCPU':
      IntermediateOutputPath = $(BaseIntermediateOutputPath)$(Configuration)\
    if '$(IntermediateOutputPath)' == '' and '$(PlatformName)' != 'AnyCPU':
      IntermediateOutputPath = $(BaseIntermediateOutputPath)$(PlatformName)\$(Configuration)\
    if !HasTrailingSlash('$(IntermediateOutputPath)'):
      IntermediateOutputPath = $(IntermediateOutputPath)\
  PropertyGroup
    // Determine OutputType property from the legacy TargetType property
    if '$(TargetType)' != '':
      OutputType = $(TargetType)
    if '$(TargetType)' == 'Container' or '$(TargetType)' == 'DocumentContainer':
      OutputType = library
    if '$(OutputType)' == '':
      OutputType = exe
    if '$(ConfigurationName)' == 'Debug' and '$(DebugSymbols)' == '' and '$(DebugType)'=='':
      DebugSymbols = true
    // Whether or not a .pdb file is produced.
    _DebugSymbolsProduced = false
    if '$(DebugSymbols)'=='true':
      _DebugSymbolsProduced = true
    if '$(DebugType)'=='none':
      _DebugSymbolsProduced = false
    if '$(DebugType)'=='pdbonly':
      _DebugSymbolsProduced = true
    if '$(DebugType)'=='full':
      _DebugSymbolsProduced = true
    if '$(DebugType)'=='portable':
      _DebugSymbolsProduced = true
    if '$(DebugType)'=='embedded':
      _DebugSymbolsProduced = false
    if '$(ProduceOnlyReferenceAssembly)'=='true':
      _DebugSymbolsProduced = false
    // Whether or not a .xml file is produced.
    _DocumentationFileProduced = true
    if '$(DocumentationFile)'=='':
      _DocumentationFileProduced = false
    // Whether or not a reference assembly is produced.
    if '$(ProduceReferenceAssembly)' == '':
      ProduceReferenceAssembly = false
  // For Legacy projects that define properties per Configuration/Platform combination, the validity of an
  // invalid combination is determined by the non-empty value of the 'OutputPath' property specified under
  // the IDE generated Configuration/Platform specific 'PropertyGroup' section.
  //
  // If 'BaseOutputPath' is specified, we can skip the validation, since, we assume the 'OutputPath' property
  // will be derived (e.g.: from the 'BaseOutputPath' property).
  if '$(BaseOutputPathWasSpecified)' != 'true' and '$(_OutputPathWasMissing)' == 'true':
    PropertyGroup
      // When 'OutputPath' is missing or empty (along with non-existent 'BaseOutputPath') at this point means,
      // we're in legacy mode and we shall assume the current Configuration/Platform combination as invalid.
      // Whether this is considered an error or a warning depends on the value of $(SkipInvalidConfigurations).
      if '$(SkipInvalidConfigurations)' == 'true':
        _InvalidConfigurationMessageSeverity = Warning
      if '$(SkipInvalidConfigurations)' != 'true':
        _InvalidConfigurationMessageSeverity = Error
  // IDE Macros available from both integrated builds and from command line builds.
  // The following properties are 'macros' that are available via IDE for
  // pre and post build steps.
  PropertyGroup
    if '$(TargetExt)' == '' and '$(OutputType)'=='exe':
      TargetExt = .exe
    if '$(TargetExt)' == '' and '$(OutputType)'=='winexe':
      TargetExt = .exe
    if '$(TargetExt)' == '' and '$(OutputType)'=='appcontainerexe':
      TargetExt = .exe
    if '$(TargetExt)' == '' and '$(OutputType)'=='library':
      TargetExt = .dll
    if '$(TargetExt)' == '' and '$(OutputType)'=='module':
      TargetExt = .netmodule
    if '$(TargetExt)' == '' and '$(OutputType)'=='winmdobj':
      TargetExt = .winmdobj
  PropertyGroup
    // Required for enabling Team Build for packaging app package-generating projects
    if '$(OutDir)'!='' and '$(OutDirWasSpecified)'=='':
      OutDirWasSpecified = true
    if '$(OutDir)' == '':
      OutDir = $(OutputPath)
    // Example, bin\Debug\
    // Ensure OutDir has a trailing slash, so it can be concatenated
    if '$(OutDir)' != '' and !HasTrailingSlash('$(OutDir)'):
      OutDir = $(OutDir)\
    if '$(ProjectName)' == '':
      ProjectName = $(MSBuildProjectName)
    // Example, MyProject
    // For projects that generate app packages or ones that want a per-project output directory, update OutDir to include the project name
    if '$(OutDir)' != '' and '$(OutDirWasSpecified)' == 'true' and (('$(WindowsAppContainer)' == 'true' and '$(GenerateProjectSpecificOutputFolder)' != 'false') or '$(GenerateProjectSpecificOutputFolder)' == 'true'):
      OutDir = $(OutDir)$(ProjectName)\
    if '$(AssemblyName)'=='':
      AssemblyName = $(MSBuildProjectName)
    if '$(TargetName)' == '' and '$(OutputType)' == 'winmdobj' and '$(RootNamespace)' != '':
      TargetName = $(RootNamespace)
    if '$(TargetName)' == '':
      TargetName = $(AssemblyName)
    // Example, MyAssembly
    if '$(ProjectFileName)' == '':
      ProjectFileName = $(MSBuildProjectFile)
    // Example, MyProject.csproj
    if '$(ProjectExt)' == '':
      ProjectExt = $(MSBuildProjectExtension)
    // Example, .csproj
    if '$(WinMDExpOutputWindowsMetadataFilename)' == '' and '$(OutputType)' == 'winmdobj':
      WinMDExpOutputWindowsMetadataFilename = $(TargetName).winmd
    if '$(TargetFileName)' == '' and '$(OutputType)' == 'winmdobj':
      TargetFileName = $(WinMDExpOutputWindowsMetadataFilename)
    if '$(TargetFileName)' == '':
      TargetFileName = $(TargetName)$(TargetExt)
    // Example, MyAssembly.dll
  PropertyGroup
    // The PublishableProject property is used when invoking the publish target on a solution that
    // contains multiple projects. The property determines which projects should be published, and
    // which projects should be skipped in the publish target. By default any "Windows Application"
    // or "Console Application" project type is publishable. However, a project that would otherwise
    // be published can be skipped by defining the PublishableProject property in the project itself.
    if '$(OutputType)'=='winexe' or '$(OutputType)'=='exe' or '$(OutputType)'=='appcontainerexe':
      _DeploymentPublishableProjectDefault = true
    if '$(PublishableProject)'=='':
      PublishableProject = $(_DeploymentPublishableProjectDefault)
    if '$(OutputType)'=='library':
      _DeploymentTargetApplicationManifestFileName = Native.$(AssemblyName).manifest
    // Example, Native.MyAssembly.manifest
    if '$(OutputType)'=='winexe':
      _DeploymentTargetApplicationManifestFileName = $(TargetFileName).manifest
    // Example, MyAssembly.exe.manifest
    if '$(OutputType)'=='exe':
      _DeploymentTargetApplicationManifestFileName = $(TargetFileName).manifest
    // Example, MyAssembly.exe.manifest
    if '$(OutputType)'=='appcontainerexe':
      _DeploymentTargetApplicationManifestFileName = $(TargetFileName).manifest
    // Example, MyAssembly.exe.manifest
    if '$(TargetDeployManifestFileName)' == '' and '$(HostInBrowser)' != 'true':
      TargetDeployManifestFileName = $(AssemblyName).application
    // Example, MyAssembly.application
    if '$(TargetDeployManifestFileName)' == '' and '$(HostInBrowser)' == 'true':
      TargetDeployManifestFileName = $(AssemblyName).xbap
    // Example, MyAssembly.xbap
    if '$(OutputType)'=='winexe' or '$(OutputType)'=='exe' or '$(OutputType)'=='appcontainerexe':
      GenerateClickOnceManifests = $(GenerateManifests)
    if '$(OutputType)'=='library':
      _DeploymentApplicationManifestIdentity = Native.$(AssemblyName)
    if '$(OutputType)'=='winexe':
      _DeploymentApplicationManifestIdentity = $(AssemblyName).exe
    if '$(OutputType)'=='exe':
      _DeploymentApplicationManifestIdentity = $(AssemblyName).exe
    if '$(OutputType)'=='appcontainerexe':
      _DeploymentApplicationManifestIdentity = $(AssemblyName).exe
    if '$(HostInBrowser)' != 'true':
      _DeploymentDeployManifestIdentity = $(AssemblyName).application
    if '$(HostInBrowser)' == 'true':
      _DeploymentDeployManifestIdentity = $(AssemblyName).xbap
    if '$(MapFileExtensions)'=='true':
      _DeploymentFileMappingExtension = .deploy
    if '$(MapFileExtensions)'!='true':
      _DeploymentFileMappingExtension
    if '$(UpdatePeriodically)'=='true':
      _DeploymentBuiltUpdateInterval = $(UpdateInterval)
    if '$(UpdatePeriodically)'=='true':
      _DeploymentBuiltUpdateIntervalUnits = $(UpdateIntervalUnits)
    if '$(UpdatePeriodically)'!='true':
      _DeploymentBuiltUpdateInterval = 0
    if '$(UpdatePeriodically)'!='true':
      _DeploymentBuiltUpdateIntervalUnits = Days
    if '$(UpdateRequired)'=='true' and '$(Install)'=='true':
      _DeploymentBuiltMinimumRequiredVersion = $(MinimumRequiredVersion)
    if '$(TargetFrameworkIdentifier)' == '.NETCoreApp':
      _DeploymentLauncherBased = true
    if '$(MaxTargetPath)'=='':
      MaxTargetPath = 100
  PropertyGroup
    // By default, GenerateApplicationManifest puts all satellite assemblies to the manifest
    // record by default by setting TargetCulture to *.
    if '$(TargetCulture)'=='':
      TargetCulture = *
    if '$(UICulture)'!='' and '$(FallbackCulture)'=='':
      FallbackCulture = $(UICulture)
  ItemGroup
    // Not used any more
    _OutputPathItem += "$(OutDir)"
    _UnmanagedRegistrationCache += "$(BaseIntermediateOutputPath)$(MSBuildProjectFile).UnmanagedRegistration.cache"
    _ResolveComReferenceCache += "$(IntermediateOutputPath)$(MSBuildProjectFile).ResolveComReference.cache"
  PropertyGroup
    // Example, C:\MyProjects\MyProject\bin\Debug\
    // Condition intentionally omitted on this one, because it causes problems
    // when we pick up the value of an environment variable named TargetDir
    if '$(OutDir)' != '':
      TargetDir = $([MSBuild]::Escape($([System.IO.Path]::GetFullPath(`$([System.IO.Path]::Combine(`$(MSBuildProjectDirectory)`, `$(OutDir)`))`))))
    // Example, C:\MyProjects\MyProject\bin\Debug\MyAssembly.dll
    if '$(TargetPath)' == '':
      TargetPath = $(TargetDir)$(TargetFileName)
    if '$(TargetRefPath)' == '' and '$(ProduceReferenceAssembly)' == 'true' and '$(ProduceReferenceAssemblyInOutDir)' == 'true':
      TargetRefPath = $([MSBuild]::NormalizePath($(TargetDir), 'ref', $(TargetFileName)))
    if '$(TargetRefPath)' == '' and '$(ProduceReferenceAssembly)' == 'true':
      TargetRefPath = $([MSBuild]::NormalizePath($(MSBuildProjectDirectory), $(IntermediateOutputPath), 'ref', $(TargetFileName)))
    // Example, C:\MyProjects\MyProject\
    if '$(ProjectDir)' == '':
      ProjectDir = $([MSBuild]::EnsureTrailingSlash($(MSBuildProjectDirectory)))
    // Example, C:\MyProjects\MyProject\MyProject.csproj
    if '$(ProjectPath)' == '':
      ProjectPath = $(ProjectDir)$(ProjectFileName)
  ItemGroup
    // This is not used here but remains for backwards compatibility
    AppConfigFileDestination += "$(OutDir)$(TargetFileName).config"
  // IDE Macros available only from integrated builds.
  // The following properties are 'macros' that are available via IDE for
  // pre and post build steps. However, they are not defined when directly building
  // a project from the command line, only when building a solution.
  PropertyGroup
    if '$(DevEnvDir)'=='':
      DevEnvDir = *Undefined*
    if '$(SolutionName)'=='':
      SolutionName = *Undefined*
    // Example, MySolution
    if '$(SolutionFileName)'=='':
      SolutionFileName = *Undefined*
    // Example, MySolution.sln
    if '$(SolutionPath)'=='':
      SolutionPath = *Undefined*
    // Example, f:\MySolutions\MySolution\MySolution.sln
    if '$(SolutionDir)'=='':
      SolutionDir = *Undefined*
    // Example, f:\MySolutions\MySolution\
    if '$(SolutionExt)'=='':
      SolutionExt = *Undefined*
    // Example, .sln
  PropertyGroup
    if '$(OutputType)'=='exe' or '$(OutputType)'=='winexe':
      GenerateBindingRedirectsOutputType = true
    // It would be a breaking change to automatically turn on binding redirects for existing projects, so turn them on only when opting into a new framework.
    if '$(AutoGenerateBindingRedirects)' == '' and '$(TargetFrameworkIdentifier)' == '.NETFramework' and '$(TargetFrameworkVersion.TrimStart(vV))' >= '4.7.2':
      AutoGenerateBindingRedirects = true
  if '$(AutoUnifyAssemblyReferences)' == '':
    PropertyGroup
      AutoUnifyAssemblyReferences = true
      if '$(GenerateBindingRedirectsOutputType)' == 'true' and '$(AutoGenerateBindingRedirects)' != 'true':
        AutoUnifyAssemblyReferences = false
  PropertyGroup
    if '$(CleanFile)'=='':
      CleanFile = $(MSBuildProjectFile).FileListAbsolute.txt
    // During DesignTime Builds, skip project reference build as Design time is only queueing information.
    if '$(BuildProjectReferences)' == '' and '$(DesignTimeBuild)' == 'true':
      BuildProjectReferences = false
    // By default we will build (and if applicable, clean) all project references. But this can be used to disable that
    if '$(BuildProjectReferences)' == '':
      BuildProjectReferences = true
    if '$(BuildInParallel)' == '':
      BuildInParallel = true
    if '$(_ResolveReferenceDependencies)' == '':
      _ResolveReferenceDependencies = false
    if '$(_GetChildProjectCopyToOutputDirectoryItems)' == '':
      _GetChildProjectCopyToOutputDirectoryItems = true
    if '$(OverwriteReadOnlyFiles)' == '':
      OverwriteReadOnlyFiles = false
    if '$(ComReferenceNoClassMembers)' == '':
      ComReferenceNoClassMembers = false
  PropertyGroup
    _GenerateBindingRedirectsIntermediateAppConfig = $(IntermediateOutputPath)$(TargetFileName).config
  if '$(MSBuildCopyMarkerName)' == '':
    PropertyGroup
      MSBuildCopyMarkerName = $(MSBuildProjectFile)
      // For a long MSBuildProjectFile let's shorten this to 17 chars - using the first 8 codepoints of the filename and a filename hash.
      if '$(MSBuildCopyMarkerName.Length)' > '17':
        MSBuildCopyMarkerName = $([MSBuild]::SubstringByAsciiChars($(MSBuildProjectFile), 0, 8)).$([MSBuild]::StableStringHash($(MSBuildProjectFile)).ToString("X8"))
      MSBuildCopyMarkerName = $(MSBuildCopyMarkerName).Up2Date
  ItemGroup
    IntermediateAssembly += "$(IntermediateOutputPath)$(TargetName)$(TargetExt)"
    FinalDocFile += "@(DocFileItem->'$(OutDir)%(Filename)%(Extension)')"
    CopyUpToDateMarker += "$([MSBuild]::NormalizePath('$(MSBuildProjectDirectory)', '$(IntermediateOutputPath)', '$(MSBuildCopyMarkerName)'))"
  if '$(ProduceReferenceAssembly)' == 'true':
    ItemGroup
      if '@(IntermediateRefAssembly)' == '':
        IntermediateRefAssembly += "$(IntermediateOutputPath)refint\$(TargetName)$(TargetExt)"
      CreateDirectory += "@(IntermediateRefAssembly->'%(RootDir)%(Directory)')"
      if '$(ProduceReferenceAssemblyInOutDir)' == 'true':
        CreateDirectory += "$(OutDir)ref"
      if '$(ProduceReferenceAssemblyInOutDir)' != 'true':
        CreateDirectory += "$(IntermediateOutputPath)ref"
  if '$(_DebugSymbolsProduced)' == 'true':
    ItemGroup
      if '$(OutputType)' == 'winmdobj' and '@(_DebugSymbolsIntermediatePath)' == '':
        _DebugSymbolsIntermediatePath += "$(IntermediateOutputPath)$(TargetName).compile.pdb"
      if '$(OutputType)' != 'winmdobj' and '@(_DebugSymbolsIntermediatePath)' == '':
        _DebugSymbolsIntermediatePath += "$(IntermediateOutputPath)$(TargetName).pdb"
      _DebugSymbolsOutputPath += "@(_DebugSymbolsIntermediatePath->'$(OutDir)%(Filename)%(Extension)')"
  if '$(_DebugSymbolsProduced)' == 'true' and '$(OutputType)' == 'winmdobj':
    PropertyGroup
      if '$(WinMDExpOutputPdb)' == '':
        WinMDExpOutputPdb = $(IntermediateOutputPath)$(TargetName).pdb
      _WinMDDebugSymbolsOutputPath = $([System.IO.Path]::Combine('$(OutDir)', $([System.IO.Path]::GetFileName('$(WinMDExpOutputPdb)'))))
  if '$(OutputType)' == 'winmdobj' and '$(DocumentationFile)'!='':
    PropertyGroup
      if '$(WinMDOutputDocumentationFile)' == '':
        WinMDOutputDocumentationFile = $(IntermediateOutputPath)$(TargetName).xml
      _WinMDDocFileOutputPath = $([System.IO.Path]::Combine('$(OutDir)', $([System.IO.Path]::GetFileName('$(WinMDOutputDocumentationFile)'))))
  if '$(WinMDExpOutputWindowsMetadataFilename)' != '':
    PropertyGroup
      _IntermediateWindowsMetadataPath = $(IntermediateOutputPath)$(WinMDExpOutputWindowsMetadataFilename)
      _WindowsMetadataOutputPath = $(OutDir)$(WinMDExpOutputWindowsMetadataFilename)
  // ARM64-related properties
  PropertyGroup
    _SupportedArchitectures = amd64 arm64
  ItemGroup
    // Create an item for entry point of the ClickOnce application (Example: WindowsApplication1.exe)
    _DeploymentManifestEntryPoint += "@(IntermediateAssembly)"
      TargetPath = $(TargetFileName)
    // Create an item for the application icon if one exists in the project (Example: app.ico)
    // NOTE: The item Include and the Exists function are operating relative to the PROJECT (.csproj, .vbproj etc.) directory in this case
    if Exists('$(ApplicationIcon)'):
      _DeploymentManifestIconFile += "$(ApplicationIcon)"
        TargetPath = $(ApplicationIcon)
    // Create an item for the output application manifest (Example: WindowsApplication1.exe.manifeset)
    ApplicationManifest += "$(IntermediateOutputPath)$(_DeploymentTargetApplicationManifestFileName)"
      TargetPath = $(_DeploymentTargetApplicationManifestFileName)
    // Create an item for the final application manifest (Example: WindowsApplication1.exe.manifeset)
    // This item represents the final output application manifest used for project-to-project
    // references and for copying to the publish output location.
    _ApplicationManifestFinal += "$(OutDir)$(_DeploymentTargetApplicationManifestFileName)"
      TargetPath = $(_DeploymentTargetApplicationManifestFileName)
    // Create an item for the output deploy manifest (Example: WindowsApplication1.application)
    DeployManifest += "$(IntermediateOutputPath)$(TargetDeployManifestFileName)"
      TargetPath = $(TargetDeployManifestFileName)
    // Create an item for the intermediate trust info file
    if '$(TargetZone)'!='':
      _DeploymentIntermediateTrustInfoFile += "$(IntermediateOutputPath)$(TargetName).TrustInfo.xml"
  // Determine the <deploymentProvider> (_DeploymentUrl) for the ClickOnce deployment manifest.
  // Prefer the UpdateUrl, falling back to InstallUrl or PublishUrl if not specified.
  // If the UpdateUrl is specified then _DeploymentUrl is always set to the UpdateUrl.
  // Otherwise, only set the _DeploymentUrl if it's an installed app and updates are enabled.
  PropertyGroup
    if '$(_DeploymentUrl)'=='':
      _DeploymentUrl = $(UpdateUrl)
    if '$(_DeploymentUrl)'=='':
      _DeploymentUrl = $(InstallUrl)
    if '$(_DeploymentUrl)'=='':
      _DeploymentUrl = $(PublishUrl)
    if !('$(UpdateUrl)'=='') and '$(Install)'=='false':
      _DeploymentUrl
    if '$(_DeploymentUrl)'!='':
      _DeploymentUrl = $(_DeploymentUrl)$(TargetDeployManifestFileName)
    // Need to explicitly blank out the _DeploymentUrl when it's not used. Otherwise an
    // inappropriate value may be used. For example a local path from the PublishUrl
    // is something we never want to see in the manifest because it means you could
    // only install the app from that machine.
    if '$(UpdateUrl)'=='' and !('$(Install)'=='true' and '$(UpdateEnabled)'=='true'):
      _DeploymentUrl
    if '$(ExcludeDeploymentUrl)'=='true':
      _DeploymentUrl
  // Determine the URLs for the bootstrapper.
  PropertyGroup
    if '$(IsWebBootstrapper)'=='true':
      _DeploymentApplicationUrl = $(InstallUrl)
    if '$(IsWebBootstrapper)'=='true' and '$(InstallUrl)'=='':
      _DeploymentApplicationUrl = $(PublishUrl)
    if '$(BootstrapperComponentsLocation)'=='Absolute':
      _DeploymentComponentsUrl = $(BootstrapperComponentsUrl)
  // Output location for publish target.
  PropertyGroup
    if '$(PublishDir)' != '' and !HasTrailingSlash('$(PublishDir)'):
      PublishDir = $(PublishDir)\
    if '$(PublishDir)'=='':
      PublishDir = $([MSBuild]::EnsureTrailingSlash('$(OutputPath)'))app.publish\
  // ClickOncePublishDir property is the output location used by all ClickOnce publish targets. This should be same as PublishDir except
  // for a trailing slash. PublishDir when specified as a global property on the command line cannot be changed to add a trailing slash.
  PropertyGroup
    ClickOncePublishDir = $(PublishDir)
    if !HasTrailingSlash('$(ClickOncePublishDir)'):
      ClickOncePublishDir = $(ClickOncePublishDir)\
  // ProcessorArchitecture is the target processor architecture.
  if '$(ProcessorArchitecture)'=='':
    PropertyGroup
      // If ProcessorArchitecture is not set, set it to PlatformTarget
      // Note: if $(PlatformTarget) is also blank resolve assembly reference defaults to msil which is the
      // desired behavior in this case
      ProcessorArchitecture = $(PlatformTarget)
      // If Processor architecture is not set and PlatformTarget is a known target translate the
      // PlatformTarget into something ResolveAssemblyReference knows about
      if '$(PlatformTarget)' == 'AnyCpu':
        ProcessorArchitecture = msil
      if '$(PlatformTarget)' == 'x64':
        ProcessorArchitecture = amd64
      if '$(PlatformTarget)' == 'Itanium':
        ProcessorArchitecture = ia64
      if '$(PlatformTarget)' == 'x86':
        ProcessorArchitecture = x86
      if '$(PlatformTarget)' == 'ARM':
        ProcessorArchitecture = arm
  PropertyGroup
    if '$(ConsiderPlatformAsProcessorArchitecture)' == '':
      ConsiderPlatformAsProcessorArchitecture = true
  if '$(ProcessorArchitecture)' == '' and '$(ConsiderPlatformAsProcessorArchitecture)' == 'true':
    PropertyGroup
      // We need to do this here because if we were to just compare against platform visual would parse them out as available platforms which may not be the case
      ProcessorArchitectureAsPlatform = $(Platform)
      if '$(ProcessorArchitectureAsPlatform)' == 'AnyCpu' or '$(ProcessorArchitectureAsPlatform)' == 'Any Cpu':
        ProcessorArchitecture = msil
      if '$(ProcessorArchitectureAsPlatform)' == 'x64' or '$(ProcessorArchitectureAsPlatform)' == 'amd64':
        ProcessorArchitecture = amd64
      if '$(ProcessorArchitectureAsPlatform)' == 'Itanium':
        ProcessorArchitecture = ia64
      if '$(ProcessorArchitectureAsPlatform)' == 'x86' or '$(ProcessorArchitectureAsPlatform)' == 'win32':
        ProcessorArchitecture = x86
      if '$(ProcessorArchitectureAsPlatform)' == 'ARM':
        ProcessorArchitecture = arm
      // For compatibility with the 4.0 behavior, if not set above, default to the environment. To override this, set ProcessorArchitecture explicitly. We also need to disable the warning since we do not know if what the environment is set to is correct
      if '$(ProcessorArchitecture)'=='':
        ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch = None
      if '$(ProcessorArchitecture)'=='':
        ProcessorArchitecture = $(PROCESSOR_ARCHITECTURE)
  // Sensible defaults for the most-commonly-desired MSBuildRuntime and MSBuildArchitecture values. The Core runtime does not currently support specifying task architecture or runtime.
  // If support for out-of-proc task execution is added on other runtimes, make sure each task's logic is checked against the current state of support.
  if '$(DisableOutOfProcTaskHost)' == '' and '$(MSBuildRuntimeType)' == 'Full':
    PropertyGroup
      if '$(TargetFrameworkVersion)' == 'v2.0' or '$(TargetFrameworkVersion)' == 'v3.0' or '$(TargetFrameworkVersion)' == 'v3.5':
        TargetFrameworkAsMSBuildRuntime = CLR2
      if '$(TargetFrameworkVersion)' == 'v4.0' or '$(TargetFrameworkVersion)' == 'v4.5':
        TargetFrameworkAsMSBuildRuntime = CLR4
      if '$(TargetFrameworkAsMSBuildRuntime)' == '':
        TargetFrameworkAsMSBuildRuntime = CurrentRuntime
      if '$(PlatformTargetAsMSBuildArchitecture)' != '':
        PlatformTargetAsMSBuildArchitectureExplicitlySet = true
      if '$(PlatformTargetAsMSBuildArchitecture)' == '':
        PlatformTargetAsMSBuildArchitectureExplicitlySet = false
      if '$(PlatformTarget)' == 'x86' or ('$(PlatformTarget)' == 'x64' and '$(MSBuildExtensionsPath64)' != ''):
        PlatformTargetAsMSBuildArchitecture = $(PlatformTarget)
      if '$(PlatformTarget)' == 'arm':
        PlatformTargetAsMSBuildArchitecture = x86
      if ('$(PlatformTarget)' == 'ia64' and '$(MSBuildExtensionsPath64)' != ''):
        PlatformTargetAsMSBuildArchitecture = x64
      if '$(PlatformTargetAsMSBuildArchitecture)' == '':
        PlatformTargetAsMSBuildArchitecture = CurrentArchitecture
  // Flavor is the project flavor. For example, Client, Smart Devices, SQL Server, etc.
  PropertyGroup
    if '$(ProjectFlavor)'=='':
      ProjectFlavor = Client
  // The default for compilers is to not delay-sign. If $(DelaySign) is false, let the compiler
  // use its default rather than forcing a no-delay-sign flag to be passed in. This is so that
  // attributes in the source code can override this decision.
  PropertyGroup
    if '$(SignAssembly)' != 'true':
      DelaySign = false
    if '$(DelaySign)'!='true':
      DelaySign
  // These properties control web reference proxy generation.
  PropertyGroup
    if '$(WebReference_EnableProperties)' == '':
      WebReference_EnableProperties = true
    if '$(WebReference_EnableSQLTypes)' == '':
      WebReference_EnableSQLTypes = true
    if '$(WebReference_EnableLegacyEventingModel)' == '':
      WebReference_EnableLegacyEventingModel = false
  // These parameters control where to look in the registry for directories to search for
  // assemblies in the assembly resolution tasks.
  PropertyGroup
    if '$(AssemblyFoldersSuffix)' == '':
      AssemblyFoldersSuffix = AssemblyFoldersEx
    if '$(FrameworkRegistryBase)' == '':
      FrameworkRegistryBase = Software\Microsoft\$(TargetFrameworkIdentifier)
    if '$(TargetPlatformRegistryBase)' == '':
      TargetPlatformRegistryBase = Software\Microsoft\Microsoft SDKs\$(TargetPlatformIdentifier)
    if '$(AssemblyFoldersConfigFile)' == '':
      AssemblyFoldersConfigFile = $([MSBuild]::GetToolsDirectory32())\AssemblyFolders.config
    if Exists('$(AssemblyFoldersConfigFile)'):
      AssemblyFoldersConfigFileSearchPath = {AssemblyFoldersFromConfig:$(AssemblyFoldersConfigFile),$(TargetFrameworkVersion)};
    // These are the extensions that assembly reference resolution will consider for resolution.
    // Add new extensions here if you want to add new file types to consider (for example, .metadata_dll).
    // Put the most likely extensions first for reference resolution speed.
    if '$(AllowedReferenceAssemblyFileExtensions)' == '':
      AllowedReferenceAssemblyFileExtensions =
        | .winmd;
        |       .dll;
        |       .exe
    // These are the extensions that reference resolution will consider when looking for files related
    // to resolved references.  Add new extensions here if you want to add new file types to consider.
    if '$(AllowedReferenceRelatedFileExtensions)' == '':
      AllowedReferenceRelatedFileExtensions =
        | .pdb;
        |       .xml;
        |       .pri;
        |       .dll.config;
        |       .exe.config
    // These names are used when determining which TargetFramework subset to use. If the any of the FullReferenceAssemblyNames
    // are seen in the list of client subsets, RAR will assume that no client subset is being used. The list is semicolon seperated
    // For example :   Full;Complete;AllThere
    if '$(FullReferenceAssemblyNames)' == '':
      FullReferenceAssemblyNames = Full
  if $(AssemblySearchPaths) == '':
    PropertyGroup
      // The SearchPaths property is set to find assemblies in the following order:
      //
      // (1) Files from current project - indicated by {CandidateAssemblyFiles}
      // (2) $(ReferencePath) - the reference path property, which comes from the .USER file.
      // (3) The hintpath from the referenced item itself, indicated by {HintPathFromItem}.
      // (4) The directory of MSBuild's "target" runtime from GetFrameworkPath.
      // The "target" runtime folder is the folder of the runtime that MSBuild is a part of.
      // (5) Assembly folders from AssemblyFolders.config file (provided by Visual Studio Dev15+).
      // (6) Registered assembly folders, indicated by {Registry:*,*,*}
      // (7) Legacy registered assembly folders, indicated by {AssemblyFolders}
      // (8) Resolve to the GAC.
      // (9) Treat the reference's Include as if it were a real file name.
      // (10) Look in the application's output folder (like bin\debug)
      if '$(AssemblySearchPath_UseCandidateAssemblyFiles)' != 'false':
        AssemblySearchPaths = {CandidateAssemblyFiles}
      if '$(AssemblySearchPath_UseReferencePath)' != 'false':
        AssemblySearchPaths = $(AssemblySearchPaths);$(ReferencePath)
      if '$(AssemblySearchPath_UseHintPathFromItem)' != 'false':
        AssemblySearchPaths = $(AssemblySearchPaths);{HintPathFromItem}
      if '$(AssemblySearchPath_UseTargetFrameworkDirectory)' != 'false':
        AssemblySearchPaths = $(AssemblySearchPaths);{TargetFrameworkDirectory}
      if '$(AssemblySearchPath_UseAssemblyFoldersConfigFileSearchPath)' != 'false':
        AssemblySearchPaths = $(AssemblySearchPaths);$(AssemblyFoldersConfigFileSearchPath)
      if '$(AssemblySearchPath_UseRegistry)' != 'false':
        AssemblySearchPaths = $(AssemblySearchPaths);{Registry:$(FrameworkRegistryBase),$(TargetFrameworkVersion),$(AssemblyFoldersSuffix)$(AssemblyFoldersExConditions)}
      if '$(AssemblySearchPath_UseAssemblyFolders)' != 'false':
        AssemblySearchPaths = $(AssemblySearchPaths);{AssemblyFolders}
      if '$(AssemblySearchPath_UseGAC)' != 'false':
        AssemblySearchPaths = $(AssemblySearchPaths);{GAC}
      if '$(AssemblySearchPath_UseRawFileName)' != 'false':
        AssemblySearchPaths = $(AssemblySearchPaths);{RawFileName}
      if '$(AssemblySearchPath_UseOutDir)' != 'false':
        AssemblySearchPaths = $(AssemblySearchPaths);$(OutDir)
  // ContinueOnError takes 3 values:  WarnAndContinue (true), ErrorAndStop (false), and ErrorAndContinue.
  // Default to ErrorAndStop, since that matches the behaviour in previous versions, and what users
  // typically expect
  PropertyGroup
    if '$(ContinueOnError)' == '':
      ContinueOnError = false
  // Users familiar with how some other repos work try to use NoWarn with MSBuild in place of MSBuildWarningsAsMessages.
  PropertyGroup
    MSBuildWarningsAsMessages = $(MSBuildWarningsAsMessages);$(NoWarn)
    if '$(MSBuildWarningsAsErrors)'=='':
      MSBuildWarningsAsErrors = $(WarningsAsErrors)
    if '$(MSBuildWarningsNotAsErrors)'=='':
      MSBuildWarningsNotAsErrors = $(WarningsNotAsErrors)
  // Common Project System support
  PropertyGroup
    if '$(CommonXamlResourcesDirectory)' == '':
      CommonXamlResourcesDirectory = $(MSBuildThisFileDirectory)$(LangName)\
  // We need to fallback to en-US in case the xaml rules are not localized (possibly happen on community languages).
  if !Exists('$(CommonXamlResourcesDirectory)'):
    PropertyGroup
      CommonXamlResourcesDirectory = $(MSBuildThisFileDirectory)en-US\
  if '$(DefineCommonItemSchemas)' == 'true':
    ItemGroup
      PropertyPageSchema += "$(CommonXamlResourcesDirectory)ProjectItemsSchema.xaml"
      PropertyPageSchema += "
                        $(CommonXamlResourcesDirectory)General.xaml;
                        $(CommonXamlResourcesDirectory)Debugger_General.xaml"
        Context = Project
      PropertyPageSchema += "$(CommonXamlResourcesDirectory)General.BrowseObject.xaml"
        Context = BrowseObject
      PropertyPageSchema += "$(CommonXamlResourcesDirectory)General_File.xaml"
        Context = File
      PropertyPageSchema += "$(CommonXamlResourcesDirectory)SCC.xaml"
        Context = Invisible
      PropertyPageSchema += "
                        $(CommonXamlResourcesDirectory)Folder.xaml;
                        $(CommonXamlResourcesDirectory)None.xaml;
                        $(CommonXamlResourcesDirectory)Content.xaml;
                        $(CommonXamlResourcesDirectory)EmbeddedResource.xaml;
                        "
        Context = File;BrowseObject
      PropertyPageSchema += "$(CommonXamlResourcesDirectory)SpecialFolder.xaml;"
        Context = File;ProjectSubscriptionService
  PropertyGroup
    if '$(DefineCommonReferenceSchemas)' == '':
      DefineCommonReferenceSchemas = $(DefineCommonItemSchemas)
  if '$(DefineCommonReferenceSchemas)' == 'true':
    ItemGroup
      // Assembly references
      PropertyPageSchema += "$(CommonXamlResourcesDirectory)assemblyreference.xaml"
        Context = ;BrowseObject
      PropertyPageSchema += "$(CommonXamlResourcesDirectory)ResolvedAssemblyReference.xaml"
        Context = ProjectSubscriptionService;BrowseObject
      // COM references
      PropertyPageSchema += "$(CommonXamlResourcesDirectory)COMReference.xaml"
        Context = ;BrowseObject
      PropertyPageSchema += "$(CommonXamlResourcesDirectory)ResolvedCOMReference.xaml"
        Context = ProjectSubscriptionService;BrowseObject
      // Project references
      PropertyPageSchema += "$(CommonXamlResourcesDirectory)ProjectReference.xaml"
        Context = ;BrowseObject
      PropertyPageSchema += "$(CommonXamlResourcesDirectory)ResolvedProjectReference.xaml"
        Context = ProjectSubscriptionService;BrowseObject
  if '$(DefineCommonCapabilities)' == 'true':
    ItemGroup
      ProjectCapability += "
                          AssemblyReferences;
                          COMReferences;
                          ProjectReferences;
                          SharedProjectReferences;
                          OutputGroups;
                          AllTargetOutputGroups;
                          VisualStudioWellKnownOutputGroups;
                          SingleFileGenerators;
                          DeclaredSourceItems;
                          UserSourceItems;
                           "
      if '$(TargetPlatformIdentifier)' == 'Windows' and '$(TargetPlatformVersion)' < 8.0:
        ProjectCapability += "BuildWindowsDesktopTarget"
  if '$(DefineExplicitDefaults)' == 'true':
    ItemDefinitionGroup
      None
        CopyToOutputDirectory = Never
      Content
        CopyToOutputDirectory = Never
      Compile
        CopyToOutputDirectory = Never
      EmbeddedResource
        CopyToOutputDirectory = Never
  // Target that allows targets consuming source control confirmation to establish a dependency on targets producing this information.
  //
  // Any target that reads SourceRevisionId, PrivateRepositoryUrl, SourceRoot, and other source control properties and items
  // should depend on this target and be conditioned on '$(SourceControlInformationFeatureSupported)' == 'true'.
  //
  // SourceRevisionId property uniquely identifies the source control revision of the repository the project belongs to.
  // For Git repositories this id is a commit hash, for TFVC repositories it's the changeset number, etc.
  //
  // PrivateRepositoryUrl property stores the URL of the repository supplied by the CI server or retrieved from source control manager.
  // Targets consuming this property shall not publish its value implicitly as it might inadvertently reveal an internal URL.
  // Instead, they shall only do so if the project sets PublishRepositoryUrl property to true. For example, the NuGet Pack target
  // may include the repository URL in the nuspec file generated for NuGet package produced by the project if PublishRepositoryUrl is true.
  //
  // SourceRoot item group lists all source roots that the project source files reside under and their mapping to source control server URLs,
  // if available. This includes both source files under source control as well as source files in source packages. SourceRoot items are
  // used by compilers to determine path map in deterministic build and by SourceLink provider, which maps local paths to URLs of source files
  // stored on the source control server.
  //
  // Source control information provider that sets these properties and items shall execute before this target (by including
  // InitializeSourceControlInformation in its BeforeTargets) and set source control properties and items that haven't been initialized yet.
  Target InitializeSourceControlInformation
  PropertyGroup
    SourceControlInformationFeatureSupported = true
  // ***********************************************************************************************
  // ***********************************************************************************************
  // Build Section
  // ***********************************************************************************************
  // ***********************************************************************************************
  Target _AddOutputPathToGlobalPropertiesToRemove
    PropertyGroup
      if '$(PassOutputPathToReferencedProjects)'=='false':
        _GlobalPropertiesToRemoveFromProjectReferences = $(_GlobalPropertiesToRemoveFromProjectReferences);OutputPath
  // ============================================================
  // _CheckForInvalidConfigurationAndPlatform
  //
  // This target checks for errors in statically defined properties.  By setting BeforeTargets, we try
  // to ensure that the target runs before any build related targets.
  // If your target requires this check and is running as a BeforeTargets of one of the first targets
  // of $(BuildDependsOn), $(RebuildDependsOn), or $(CleanDependsOn) you will need to set your DependsOn
  // to this target.
  // ============================================================
  Target _CheckForInvalidConfigurationAndPlatform(
      BeforeTargets="$(BuildDependsOn);Build;$(RebuildDependsOn);Rebuild;$(CleanDependsOn);Clean")
    PropertyGroup
      if '$(BuildingInsideVisualStudio)' == 'true':
        _InvalidConfigurationMessageResourceName = CommonSdk.InvalidConfigurationTextWhenBuildingInsideVisualStudio
      if '$(BuildingInsideVisualStudio)' != 'true':
        _InvalidConfigurationMessageResourceName = CommonSdk.InvalidConfigurationTextWhenBuildingOutsideVisualStudio
    if '$(_InvalidConfigurationMessageSeverity)' != '':
      MSBuildInternalMessage(
          FormatArguments="$(MSBuildProjectFile);$(_OriginalConfiguration);$(_OriginalPlatform)",
          ResourceName="$(_InvalidConfigurationMessageResourceName)",
          Severity="$(_InvalidConfigurationMessageSeverity)")
    if '$(DesignTimeBuild)' != 'true':
      Message(Importance="Low", Text="Configuration=$(Configuration)")
    if '$(DesignTimeBuild)' != 'true':
      Message(Importance="Low", Text="Platform=$(Platform)")
    // Although we try to ensure a trailing slash, it's possible to circumvent this if the property is set on the command line
    if '$(OutDir)' != '' and !HasTrailingSlash('$(OutDir)'):
      MSBuildInternalMessage(
          FormatArguments="OutDir",
          ResourceName="CommonSdk.PropertyWithTrailingSlash",
          Severity="Error")
    if '$(IntermediateOutputPath)' != '' and !HasTrailingSlash('$(IntermediateOutputPath)'):
      MSBuildInternalMessage(
          FormatArguments="IntermediateOutputPath",
          ResourceName="CommonSdk.PropertyWithTrailingSlash",
          Severity="Error")
    if '$(BaseIntermediateOutputPath)' != '' and !HasTrailingSlash('$(BaseIntermediateOutputPath)'):
      MSBuildInternalMessage(
          FormatArguments="BaseIntermediateOutputPath",
          ResourceName="CommonSdk.PropertyWithTrailingSlash",
          Severity="Error")
    // Also update the value of PlatformTargetAsMSBuildArchitecture per the value of Prefer32Bit.  We are doing
    // this here because Prefer32Bit may be set anywhere in the targets, so we can't depend on it having the
    // correct value when we're trying to figure out PlatformTargetAsMSBuildArchitecture
    if '$(Prefer32Bit)' == 'true' and ('$(PlatformTarget)' == 'AnyCPU' or '$(PlatformTarget)' == '') and '$(PlatformTargetAsMSBuildArchitectureExplicitlySet)' != 'true':
      PropertyGroup
        PlatformTargetAsMSBuildArchitecture = x86
    if '$(Prefer32Bit)' == 'true' and '$(PreferNativeArm64)' == 'true':
      MSBuildInternalMessage(
          ResourceName="CommonSdk.Prefer32BitAndPreferNativeArm64Enabled",
          Severity="Error")
    if '$(NoWin32Manifest)' == 'true' and '$(PreferNativeArm64)' == 'true':
      MSBuildInternalMessage(
          ResourceName="CommonSdk.NoWin32ManifestAndPreferNativeArm64Enabled",
          Severity="Error")
    if '$(PreferNativeArm64)' == 'true' and '$(Platform)' != 'AnyCPU':
      MSBuildInternalMessage(
          FormatArguments="$(Platform)",
          ResourceName="CommonSdk.PlatformIsAnyCPUAndPreferNativeArm64Enabled",
          Severity="Warning")
    // Log an error MSB3540 if the user set MSBuildProjectExtensionsPath in the body of a project. In an SDK style project
    // if you set a value in the body, the value is not used by the top implicit import but is used by the bottom.
    // This can lead to confusing behavior and builds can fail for obscure reasons.
    if '$(_InitialMSBuildProjectExtensionsPath)' != '' And '$(MSBuildProjectExtensionsPath)' != '$(_InitialMSBuildProjectExtensionsPath)':
      MSBuildInternalMessage(
          ResourceName="CommonSdk.MSBuildProjectExtensionsPathModifiedAfterUse",
          Severity="Error")
    // Log a warning MSB3539 if:
    // 1. $(EnableBaseIntermediateOutputPathMismatchWarning) is 'true'
    // 2. $(BaseIntermediateOutputPath) was set in the body of a project after its default value was set in Microsoft.Common.props
    // 3. $(BaseIntermediateOutputPath) is not the same as $(MSBuildProjectExtensionsPath)
    //
    // Similar to the error above, there are cases when users set $(BaseIntermediateOutputPath) in the body of their project and things build but only by coincidence.
    // MSBuild does not know if $(BaseIntermediateOutputPath) changing would cause problems so tools like NuGet must set $(EnableBaseIntermediateOutputPathMismatchWarning)
    // to 'true'.
    if '$(EnableBaseIntermediateOutputPathMismatchWarning)' == 'true' And '$(_InitialBaseIntermediateOutputPath)' != '$(BaseIntermediateOutputPath)' And '$(BaseIntermediateOutputPath)' != '$(MSBuildProjectExtensionsPath)':
      MSBuildInternalMessage(
          ResourceName="CommonSdk.BaseIntermediateOutputPathMismatchWarning",
          Severity="Warning")
  // ============================================================
  // Build
  //
  // The main build entry point.
  // ============================================================
  PropertyGroup
    BuildDependsOn =
      | BeforeBuild;
      |       CoreBuild;
      |       AfterBuild
  if '$(_InvalidConfigurationWarning)' != 'true':
    Target Build(
        DependsOnTargets="$(BuildDependsOn)",
        Returns="@(TargetPathWithTargetPlatformMoniker)")
  // ============================================================
  // BeforeBuild
  //
  // Redefine this target in your project in order to run tasks just before Build
  // ============================================================
  Target BeforeBuild
  // ============================================================
  // AfterBuild
  //
  // Redefine this target in your project in order to run tasks just after Build
  // ============================================================
  Target AfterBuild
  // ============================================================
  // CoreBuild
  //
  // The core build step calls each of the build targets.
  // ============================================================
  PropertyGroup
    CoreBuildDependsOn =
      | BuildOnlySettings;
      |       PrepareForBuild;
      |       PreBuildEvent;
      |       ResolveReferences;
      |       PrepareResources;
      |       ResolveKeySource;
      |       Compile;
      |       ExportWindowsMDFile;
      |       UnmanagedUnregistration;
      |       GenerateSerializationAssemblies;
      |       CreateSatelliteAssemblies;
      |       GenerateManifests;
      |       GetTargetPath;
      |       PrepareForRun;
      |       UnmanagedRegistration;
      |       IncrementalClean;
      |       PostBuildEvent
  Target CoreBuild(DependsOnTargets="$(CoreBuildDependsOn)")
    if '$(RunPostBuildEvent)'=='Always' or '$(RunPostBuildEvent)'=='OnOutputUpdated':
      OnError(ExecuteTargets="_TimeStampAfterCompile;PostBuildEvent")
    OnError(ExecuteTargets="_CleanRecordFileWrites")
  // ============================================================
  // Rebuild
  //
  // Delete all intermediate and final build outputs, and then build the project from scratch.
  // ============================================================
  PropertyGroup
    if '$(MSBuildProjectDefaultTargets)' != '':
      _ProjectDefaultTargets = $(MSBuildProjectDefaultTargets)
    if '$(MSBuildProjectDefaultTargets)' == '':
      _ProjectDefaultTargets = Build
    RebuildDependsOn =
      | BeforeRebuild;
      |       Clean;
      |       $(_ProjectDefaultTargets);
      |       AfterRebuild;
    if '$(MSBuildProjectDefaultTargets)' == 'Rebuild':
      RebuildDependsOn =
        | BeforeRebuild;
        |       Clean;
        |       Build;
        |       AfterRebuild;
  if '$(_InvalidConfigurationWarning)' != 'true':
    Target Rebuild(DependsOnTargets="$(RebuildDependsOn)", Returns="$(TargetPath)")
  // ============================================================
  // BeforeRebuild
  //
  // Redefine this target in your project in order to run tasks just before Rebuild
  // ============================================================
  Target BeforeRebuild
  // ============================================================
  // AfterRebuild
  //
  // Redefine this target in your project in order to run tasks just after Rebuild
  // ============================================================
  Target AfterRebuild
  // ============================================================
  // BuildGenerateSources
  //
  // Redefine this target in your project in order to run tasks for BuildGenerateSources
  //
  // Set BuildPassReferences to enable P2P builds
  // ============================================================
  PropertyGroup
    BuildGenerateSourcesAction = Build
  Target BuildGenerateSources(
      DependsOnTargets=[
        BuildGenerateSourcesTraverse
        $(BuildGenerateSourcesAction)
      ])
  Target BuildGenerateSourcesTraverse(DependsOnTargets="PrepareProjectReferences")
    if '$(BuildPassReferences)' == 'true' and '@(ProjectReferenceWithConfiguration)' != '' and '@(_MSBuildProjectReferenceExistent)' != '' and '%(_MSBuildProjectReferenceExistent.BuildReference)' == 'true':
      MSBuild(
          BuildInParallel="$(BuildInParallel)",
          ContinueOnError="!$(BuildingProject)",
          Projects="@(_MSBuildProjectReferenceExistent)",
          Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform); %(_MSBuildProjectReferenceExistent.SetTargetFramework);",
          RemoveProperties="%(_MSBuildProjectReferenceExistent.GlobalPropertiesToRemove)$(_GlobalPropertiesToRemoveFromProjectReferences)",
          Targets="BuildGenerateSources")
  if '$(IsGraphBuild)' == 'true' and '$(BuildPassReferences)' == 'true':
    ItemGroup
      ProjectReferenceTargets += "BuildGenerateSources"(Targets="BuildGenerateSources")
  // ============================================================
  // BuildCompile
  //
  // Redefine this target in your project in order to run tasks for BuildCompile
  // ============================================================
  PropertyGroup
    BuildCompileAction = Build
  Target BuildCompile(
      DependsOnTargets=[
        BuildCompileTraverse
        $(BuildCompileAction)
      ])
  Target BuildCompileTraverse(DependsOnTargets="PrepareProjectReferences")
    if '$(BuildPassReferences)' == 'true' and '@(ProjectReferenceWithConfiguration)' != '' and '@(_MSBuildProjectReferenceExistent)' != '' and '%(_MSBuildProjectReferenceExistent.BuildReference)' == 'true':
      MSBuild(
          BuildInParallel="$(BuildInParallel)",
          ContinueOnError="!$(BuildingProject)",
          Projects="@(_MSBuildProjectReferenceExistent)",
          Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform); %(_MSBuildProjectReferenceExistent.SetTargetFramework)",
          RemoveProperties="%(_MSBuildProjectReferenceExistent.GlobalPropertiesToRemove)$(_GlobalPropertiesToRemoveFromProjectReferences)",
          Targets="BuildCompile")
  if '$(IsGraphBuild)' == 'true' and '$(BuildPassReferences)' == 'true':
    ItemGroup
      ProjectReferenceTargets += "BuildCompile"(Targets="BuildCompile")
  // ============================================================
  // BuildLink
  //
  // Redefine this target in your project in order to run tasks for BuildLink
  // ============================================================
  PropertyGroup
    BuildLinkAction = Build
  Target BuildLink(
      DependsOnTargets=[
        BuildLinkTraverse
        $(BuildLinkAction)
      ])
  Target BuildLinkTraverse(DependsOnTargets="PrepareProjectReferences")
    if '$(BuildPassReferences)' == 'true' and '@(ProjectReferenceWithConfiguration)' != '' and '@(_MSBuildProjectReferenceExistent)' != '' and '%(_MSBuildProjectReferenceExistent.BuildReference)' == 'true':
      MSBuild(
          BuildInParallel="$(BuildInParallel)",
          ContinueOnError="!$(BuildingProject)",
          Projects="@(_MSBuildProjectReferenceExistent)",
          Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform); %(_MSBuildProjectReferenceExistent.SetTargetFramework)",
          RemoveProperties="%(_MSBuildProjectReferenceExistent.GlobalPropertiesToRemove)$(_GlobalPropertiesToRemoveFromProjectReferences)",
          Targets="BuildLink")
  if '$(IsGraphBuild)' == 'true' and '$(BuildPassReferences)' == 'true':
    ItemGroup
      ProjectReferenceTargets += "BuildLink"(Targets="BuildLink")
  // ============================================================
  // CopyRunEnvironmentFiles
  //
  // Copy environment files necessary to run the user's app to the final directory.
  // This is a public target that can be invoked by an IDE.
  //
  // This may be used by an IDE to make the app.config file available for running
  // the target app.
  // ============================================================
  Target CopyRunEnvironmentFiles(
      DependsOnTargets=[
        PrepareForBuild
        SetWin32ManifestProperties
        _CopyAppConfigFile
        _CleanRecordFileWrites
      ])
  // ============================================================
  // Run
  //
  // Run the final build output if it is a .EXE
  // ============================================================
  PropertyGroup
    RunDependsOn
  Target Run(DependsOnTargets="$(RunDependsOn)")
    if '$(TargetExt)'!='.exe':
      MSBuildInternalMessage(
          FormatArguments="$(TargetPath)",
          ResourceName="CommonSdk.RunTargetDependsOnMessage",
          Severity="Error")
    if '$(StartWorkingDirectory)' == '':
      Exec(Command="$(TargetPath) $(StartArguments)", WorkingDirectory="$(OutDir)")
    if '$(StartWorkingDirectory)' != '':
      Exec(Command="$(TargetPath) $(StartArguments)", WorkingDirectory="$(StartWorkingDirectory)")
  // ***********************************************************************************************
  // ***********************************************************************************************
  // BuildOnlySettings Section
  // ***********************************************************************************************
  // ***********************************************************************************************
  // ============================================================
  // BuildOnlySettings
  //
  // This target is called only when doing a real build.  It is specifically not called during project load.
  // ============================================================
  PropertyGroup
    BuildingProject = false
  Target BuildOnlySettings
    PropertyGroup
      BuildingProject = true
  // ***********************************************************************************************
  // ***********************************************************************************************
  // PrepareForBuild Section
  // ***********************************************************************************************
  // ***********************************************************************************************
  // ============================================================
  // PrepareForBuild
  //
  // Prepare the prerequisites for building.
  // ============================================================
  PropertyGroup
    PrepareForBuildDependsOn = $(PrepareForBuildDependsOn);GetFrameworkPaths;GetReferenceAssemblyPaths;AssignLinkMetadata
  Target PrepareForBuild(DependsOnTargets="$(PrepareForBuildDependsOn)")
    ItemGroup
      if '$(AppConfig)'!='':
        AppConfigWithTargetPath += "$(AppConfig)"
          TargetPath = $(TargetFileName).config
    if '$(AppConfig)'=='':
      FindAppConfigFile(
          PrimaryList="@(None)",
          SecondaryList="@(Content)",
          TargetPath="$(TargetFileName).config")
        Output(ItemName="AppConfigWithTargetPath", TaskParameter="AppConfigFile")
        Output(PropertyName="AppConfig", TaskParameter="AppConfigFile")
    // Create the directories for intermediate and final build products, and any other arbitrary directories.
    // We are going to continue on error here so that if the tree is read only we will still get intellisense
    MakeDir(
        ContinueOnError="true",
        Directories="$(OutDir);$(IntermediateOutputPath);@(DocFileItem->'%(RelativeDir)');@(CreateDirectory)")
  // ============================================================
  // GetFrameworkPaths
  //
  // Get the paths for the .NET Framework installation directory
  //
  // These paths are not used directly by this .targets file but are available for pre and
  // post build steps.
  // ============================================================
  PropertyGroup
    Framework40Dir = @(_TargetFramework40DirectoryItem)
    Framework35Dir = @(_TargetFramework35DirectoryItem)
    Framework30Dir = @(_TargetFramework30DirectoryItem)
    Framework20Dir = @(_TargetFramework20DirectoryItem)
    // Note we need to make the 4.0 FrameworkDir point to the 2.0 location by default since we shipped msbuild 4.0 that way and to change it would be a breaking change.
    if '$(FrameworkDir)' == '' and ('$(TargetFrameworkVersion)' == 'v2.0' or '$(TargetFrameworkVersion)' == 'v3.5' or '$(TargetFrameworkVersion)' == 'v4.0'):
      FrameworkDir = @(_TargetFramework20DirectoryItem)
    if '$(FrameworkDir)' == '':
      FrameworkDir = @(_TargetFramework40DirectoryItem)
    if '$(TargetedFrameworkDir)' == '':
      TargetedFrameworkDir = @(_TargetedFrameworkDirectoryItem)
    if '$(FrameworkSDKDir)' == '':
      FrameworkSDKDir = @(_TargetFrameworkSDKDirectoryItem)
    GetFrameworkPathsDependsOn
  // This is a generally overriden target, for example it is overriden in the Microsoft.NETFramework.targets file
  Target GetFrameworkPaths
  // ============================================================
  // GetReferenceAssemblyPaths
  //
  // Get the paths for the Reference Assemblies for the known versions of the
  // .NET Framework.
  //
  // These paths are used by the build process in order to resolve the correct
  // assemblies from the various directories, and to support multi-targeting
  // ============================================================
  Target GetReferenceAssemblyPaths(
      DependsOnTargets=[
        $(GetReferenceAssemblyPathsDependsOn)
        GetFrameworkPaths
      ])
    // if TargetFrameworkDirectory doesn't have a custom value, clear it out; that way we can get reference paths and target framework directories all in the right order
    PropertyGroup
      if '@(_CombinedTargetFrameworkDirectoriesItem)' == '$(TargetFrameworkDirectory)':
        TargetFrameworkDirectory
    // By default if there is no root path set then the task will assume it is Program Files\Reference Assemblies\Microsoft\Framework
    if '$(TargetFrameworkMoniker)' != '' and ('$(_TargetFrameworkDirectories)' == '' or '$(_FullFrameworkReferenceAssemblyPaths)' == ''):
      GetReferenceAssemblyPaths(
          BypassFrameworkInstallChecks="$(BypassFrameworkInstallChecks)",
          ContinueOnError="!$(BuildingProject)",
          RootPath="$(TargetFrameworkRootPath)",
          TargetFrameworkFallbackSearchPaths="$(TargetFrameworkFallbackSearchPaths)",
          TargetFrameworkMoniker="$(TargetFrameworkMoniker)")
        Output(PropertyName="_TargetFrameworkDirectories", TaskParameter="ReferenceAssemblyPaths")
        Output(
            PropertyName="_FullFrameworkReferenceAssemblyPaths",
            TaskParameter="FullFrameworkReferenceAssemblyPaths")
        if '$(TargetFrameworkMonikerDisplayName)' == '':
          Output(
              PropertyName="TargetFrameworkMonikerDisplayName",
              TaskParameter="TargetFrameworkMonikerDisplayName")
    PropertyGroup
      TargetFrameworkDirectory = $(_TargetFrameworkDirectories);$(TargetFrameworkDirectory);$(WinFXAssemblyDirectory)
      if '$(TargetPlatformWinMDLocation)' != '' and Exists('$(TargetPlatformWinMDLocation)'):
        TargetFrameworkDirectory = $(TargetFrameworkDirectory);$(TargetPlatformWinMDLocation)
    // Remove the AssemblyFolders if no target framework directories could be found. This is to prevent us from
    // resolving from the assemblyfolders global location if we are not acutally targeting a framework
    PropertyGroup
      if '$(RemoveAssemblyFoldersIfNoTargetFramework)' == '':
        RemoveAssemblyFoldersIfNoTargetFramework = true
    if '$(_TargetFrameworkDirectories)' == '' and '$(AssemblySearchPaths)' != '' and '$(RemoveAssemblyFoldersIfNoTargetFramework)' == 'true':
      PropertyGroup
        AssemblySearchPaths = $(AssemblySearchPaths.Replace('{AssemblyFolders}', '').Split(';'))
    if '$(ImplicitlyExpandDesignTimeFacades)' == 'true':
      ItemGroup
        DesignTimeFacadeDirectoryRoots += "$(TargetFrameworkDirectory)"
        if Exists('%(DesignTimeFacadeDirectoryRoots.Identity)Facades\'):
          DesignTimeFacadeDirectories += "%(DesignTimeFacadeDirectoryRoots.Identity)Facades\"
    if '@(DesignTimeFacadeDirectories)' != '':
      PropertyGroup
        TargetFrameworkDirectory = $(TargetFrameworkDirectory);@(DesignTimeFacadeDirectories)
    if '$(_TargetFrameworkDirectories)' == '':
      PropertyGroup
        TargetFrameworkProfile
  // Returns target framework moniker. E.g. ".NETFramework,Version=v4.0.1"
  Target GetTargetFrameworkMoniker(Returns="$(TargetFrameworkMoniker)")
  // Returns target framework moniker display name. E.g. ".NET Framework 4 Platform Update 1 (KB2478063)"
  Target GetTargetFrameworkMonikerDisplayName(
      DependsOnTargets=[
        GetFrameworkPaths
        GetReferenceAssemblyPaths
      ],
      Returns="$(TargetFrameworkMonikerDisplayName)")
  // Returns semicolon separated list of target framework directories.
  // E.g "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0.1\;C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\"
  Target GetTargetFrameworkDirectories(
      DependsOnTargets=[
        GetFrameworkPaths
        GetReferenceAssemblyPaths
      ],
      Returns="$(TargetFrameworkDirectory)")
  // ============================================================
  // AssignLinkMetadata
  //
  // For items of a certain set of allowlisted types, make sure that
  // if they are defined in a file other than the project file, that
  // they have "Link" metadata set to an appropriate default.
  // ============================================================
  if '$(SynthesizeLinkMetadata)' == 'true':
    Target AssignLinkMetadata
      // NONE ITEMS
      if '@(None)' != '' and '%(None.DefiningProjectFullPath)' != '$(MSBuildProjectFullPath)':
        AssignLinkMetadata(Items="@(None)")
          Output(ItemName="_Temp", TaskParameter="OutputItems")
      ItemGroup
        None -= "@(_Temp)"
        None += "@(_Temp)"
        _Temp -= "@(_Temp)"
      // CONTENT ITEMS
      if '@(Content)' != '' and '%(Content.DefiningProjectFullPath)' != '$(MSBuildProjectFullPath)':
        AssignLinkMetadata(Items="@(Content)")
          Output(ItemName="_Temp", TaskParameter="OutputItems")
      ItemGroup
        Content -= "@(_Temp)"
        Content += "@(_Temp)"
        _Temp -= "@(_Temp)"
      // PAGE ITEMS
      if '@(Page)' != '' and '%(Page.DefiningProjectFullPath)' != '$(MSBuildProjectFullPath)':
        AssignLinkMetadata(Items="@(Page)")
          Output(ItemName="_Temp", TaskParameter="OutputItems")
      ItemGroup
        Page -= "@(_Temp)"
        Page += "@(_Temp)"
        _Temp -= "@(_Temp)"
      // APPLICATIONDEFINITION ITEMS
      if '@(ApplicationDefinition)' != '' and '%(ApplicationDefinition.DefiningProjectFullPath)' != '$(MSBuildProjectFullPath)':
        AssignLinkMetadata(Items="@(ApplicationDefinition)")
          Output(ItemName="_Temp", TaskParameter="OutputItems")
      ItemGroup
        ApplicationDefinition -= "@(_Temp)"
        ApplicationDefinition += "@(_Temp)"
        _Temp -= "@(_Temp)"
      // EMBEDDEDRESOURCE ITEMS
      if '@(EmbeddedResource)' != '' and '%(EmbeddedResource.DefiningProjectFullPath)' != '$(MSBuildProjectFullPath)':
        AssignLinkMetadata(Items="@(EmbeddedResource)")
          Output(ItemName="_Temp", TaskParameter="OutputItems")
      ItemGroup
        EmbeddedResource -= "@(_Temp)"
        EmbeddedResource += "@(_Temp)"
        _Temp -= "@(_Temp)"
      // RESOURCE ITEMS
      if '@(Resource)' != '' and '%(Resource.DefiningProjectFullPath)' != '$(MSBuildProjectFullPath)' and $([MSBuild]::AreFeaturesEnabled('17.10')):
        AssignLinkMetadata(Items="@(Resource)")
          Output(ItemName="_Temp", TaskParameter="OutputItems")
      if $([MSBuild]::AreFeaturesEnabled('17.10')):
        ItemGroup
          Resource -= "@(_Temp)"
          Resource += "@(_Temp)"
          _Temp -= "@(_Temp)"
  // ***********************************************************************************************
  // ***********************************************************************************************
  // PreBuildEvent Section
  // ***********************************************************************************************
  // ***********************************************************************************************
  // ============================================================
  // PreBuildEvent
  //
  // Run the pre-build event if there is one.
  // ============================================================
  PropertyGroup
    PreBuildEventDependsOn
  if '$(PreBuildEvent)'!='':
    Target PreBuildEvent(DependsOnTargets="$(PreBuildEventDependsOn)")
      Exec(Command="$(PreBuildEvent)", WorkingDirectory="$(OutDir)")
  // ***********************************************************************************************
  // ***********************************************************************************************
  // UnmanagedUnregistration Section
  // ***********************************************************************************************
  // ***********************************************************************************************
  // ============================================================
  // UnmanagedUnregistration
  //
  // If the main assembly had previously been registered for COM interop, unregister it now.
  // We will re-register the new version after it has been built.
  // ============================================================
  PropertyGroup
    UnmanagedUnregistrationDependsOn
  if (('$(_AssemblyTimestampBeforeCompile)' != '$(_AssemblyTimestampAfterCompile)' or '$(RegisterForComInterop)' != 'true' or '$(OutputType)' != 'library') or ('$(_AssemblyTimestampBeforeCompile)' == '')) and Exists('@(_UnmanagedRegistrationCache)'):
    Target UnmanagedUnregistration(DependsOnTargets="$(UnmanagedUnregistrationDependsOn)")
      PropertyGroup
        if '$(UnregisterAssemblyMSBuildArchitecture)' == '':
          UnregisterAssemblyMSBuildArchitecture = $(PlatformTargetAsMSBuildArchitecture)
      if '$(TargetFrameworkAsMSBuildRuntime)' != '' and '$(UnregisterAssemblyMSBuildArchitecture)' != '':
        PropertyGroup
          // Falling back to the current runtime if we are targeting CLR2 and the task host doesn't exist will lead to
          // incorrect behavior in some cases, but it's the same incorrect behavior as Visual Studio 2010, and thus better
          // than causing build breaks on upgrade to Win8 the way not doing so would.  For more details, see the
          // corresponding comment in GenerateResource.
          if '$(UnregisterAssemblyMSBuildRuntime)' == '' and $([MSBuild]::DoesTaskHostExist(`$(TargetFrameworkAsMSBuildRuntime)`, `$(UnregisterAssemblyMSBuildArchitecture)`)):
            UnregisterAssemblyMSBuildRuntime = $(TargetFrameworkAsMSBuildRuntime)
          // If the targeted runtime doesn't exist, fall back to current
          if '$(UnregisterAssemblyMSBuildRuntime)' == '':
            UnregisterAssemblyMSBuildRuntime = CurrentRuntime
      UnregisterAssembly(
          AssemblyListFile="@(_UnmanagedRegistrationCache)",
          MSBuildArchitecture="$(UnregisterAssemblyMSBuildArchitecture)",
          MSBuildRuntime="$(UnregisterAssemblyMSBuildRuntime)")
  // ***********************************************************************************************
  // ***********************************************************************************************
  // ResolveReferences Section
  // ***********************************************************************************************
  // ***********************************************************************************************
  // ============================================================
  // GetTargetFrameworkVersion
  //
  // This stand-alone target returns the target framework version (i.e. v3.5, v4.0, etc.)
  // that would be used if we built this project.
  //
  // ============================================================
  Target GetTargetFrameworkVersion(Returns="$(TargetFrameworkVersion)")
  // ============================================================
  // ResolveReferences
  // ============================================================
  PropertyGroup
    ResolveReferencesDependsOn =
      | BeforeResolveReferences;
      |       AssignProjectConfiguration;
      |       ResolveProjectReferences;
      |       FindInvalidProjectReferences;
      |       ResolveNativeReferences;
      |       ResolveAssemblyReferences;
      |       GenerateBindingRedirects;
      |       GenerateBindingRedirectsUpdateAppConfig;
      |       ResolveComReferences;
      |       AfterResolveReferences
  Target ResolveReferences(
      DependsOnTargets="$(ResolveReferencesDependsOn)",
      Returns="@(ReferencePath)")
  // ============================================================
  // BeforeResolveReferences
  //
  // Redefine this target in your project in order to run tasks just before ResolveReferences
  // ============================================================
  Target BeforeResolveReferences
  // ============================================================
  // AfterResolveReferences
  //
  // Redefine this target in your project in order to run tasks just after ResolveReferences
  // ============================================================
  Target AfterResolveReferences
  // ============================================================
  // IgnoreJavaScriptOutputAssembly
  //
  // esproj are JavaScript or TypeScript Projects that never produce an assembly.
  // Set ReferenceOutputAssembly to false in any reference to an esproj.
  // ============================================================
  Target IgnoreJavaScriptOutputAssembly(BeforeTargets="AssignProjectConfiguration")
    ItemGroup
      if '%(ProjectReference.Extension)' == '.esproj' and '%(ProjectReference.ReferenceOutputAssembly)' == '':
        ProjectReference
          ReferenceOutputAssembly = false
  // ============================================================
  // AssignProjectConfiguration
  //
  // Assigns the appropriate configuration to each project in the list of project references passed in.
  // Adds to the project references passed in any project references implied by dependencies expressed in the solution file, if any.
  //
  // [IN]
  // @(ProjectReference) - the list of all project references
  //
  // [OUT]
  // @(ProjectReferenceWithConfiguration) - the list of project references (MSBuild and potentially VSIP projects)
  // with metadata values FullConfiguration, Configuration, Platform,
  // SetConfiguration, and SetPlatform
  // ============================================================
  if '$(CurrentSolutionConfigurationContents)' != '' or '@(ProjectReference)'!='':
    Target AssignProjectConfiguration
      PropertyGroup
        if '$(OnlyReferenceAndBuildProjectsEnabledInSolutionConfiguration)' == '':
          OnlyReferenceAndBuildProjectsEnabledInSolutionConfiguration = true
        if '$(ShouldUnsetParentConfigurationAndPlatform)' == '' and ('$(BuildingInsideVisualStudio)' == 'true' or '$(BuildingSolutionFile)' == 'true'):
          ShouldUnsetParentConfigurationAndPlatform = true
        if '$(ShouldUnsetParentConfigurationAndPlatform)' == '':
          ShouldUnsetParentConfigurationAndPlatform = false
        // Web Application projects can "secretly" reference Silverlight projects, which can take project dependencies on that same Web Application.  If the project
        // dependencies are promoted to project references, this ends up creating a situation where we have a circular reference between the two projects.  We don't
        // want this to happen, so just turn off synthetic project reference generation for Silverlight projects.
        if '$(AddSyntheticProjectReferencesForSolutionDependencies)' == '' and '$(TargetFrameworkIdentifier)' == 'Silverlight':
          AddSyntheticProjectReferencesForSolutionDependencies = false
        // Inside VS, we do not need to add synthetic references, as VS already organizes the build per any solution-level dependencies; we only do this on the command line
        if '$(AddSyntheticProjectReferencesForSolutionDependencies)' == '' and '$(BuildingInsideVisualStudio)' != 'true':
          AddSyntheticProjectReferencesForSolutionDependencies = true
      // Assign a project configuration to each project reference if we're building a solution file.
      AssignProjectConfiguration(
          AddSyntheticProjectReferencesForSolutionDependencies="$(AddSyntheticProjectReferencesForSolutionDependencies)",
          CurrentProject="$(MSBuildProjectFullPath)",
          CurrentProjectConfiguration="$(Configuration)",
          CurrentProjectPlatform="$(Platform)",
          DefaultToVcxPlatformMapping="$(DefaultToVcxPlatformMapping)",
          OnlyReferenceAndBuildProjectsEnabledInSolutionConfiguration="$(OnlyReferenceAndBuildProjectsEnabledInSolutionConfiguration)",
          OutputType="$(OutputType)",
          ProjectReferences="@(ProjectReference)",
          ResolveConfigurationPlatformUsingMappings="false",
          ShouldUnsetParentConfigurationAndPlatform="$(ShouldUnsetParentConfigurationAndPlatform)",
          SolutionConfigurationContents="$(CurrentSolutionConfigurationContents)",
          VcxToDefaultPlatformMapping="$(VcxToDefaultPlatformMapping)")
        // EMITTED FOR COMPATIBILITY REASONS ONLY. CONSUME PROJECTREFERENCEWITHCONFIGURATION INSTEAD
        Output(ItemName="_ProjectReferenceWithConfiguration", TaskParameter="AssignedProjects")
        Output(ItemName="_ProjectReferenceWithConfiguration", TaskParameter="UnassignedProjects")
        Output(ItemName="ProjectReferenceWithConfiguration", TaskParameter="AssignedProjects")
        Output(ItemName="ProjectReferenceWithConfiguration", TaskParameter="UnassignedProjects")
      ItemGroup
        _ProjectReferenceWithConfiguration
          if '%(_ProjectReferenceWithConfiguration.BuildReference)' == '':
            BuildReference = true
          if '%(_ProjectReferenceWithConfiguration.ReferenceOutputAssembly)' == '':
            ReferenceOutputAssembly = true
        ProjectReferenceWithConfiguration
          if '%(ProjectReferenceWithConfiguration.BuildReference)' == '':
            BuildReference = true
          if '%(ProjectReferenceWithConfiguration.ReferenceOutputAssembly)' == '':
            ReferenceOutputAssembly = true
  // ============================================================
  // _SplitProjectReferencesByFileExistence
  //
  // Split referenced projects into two lists: those that exist on
  // disk and those that don't.
  // ============================================================
  Target _SplitProjectReferencesByFileExistence
    // Use this task for matching projects with pre-resolved project outputs set by the IDE
    // if building inside the IDE.  The IDE only includes non-MSBuild projects in the output list.  We'll
    // use MSBuild to resolve MSBuild projects.
    // This task will resolve VSIP (3rd party) project references and create a new item list with only project references
    // to projects in the MSBuild format.
    if '$(BuildingInsideVisualStudio)'=='true' and '@(ProjectReferenceWithConfiguration)'!='':
      ResolveNonMSBuildProjectOutput(
          PreresolvedProjectOutputs="$(VSIDEResolvedNonMSBuildProjectOutputs)",
          ProjectReferences="@(ProjectReferenceWithConfiguration)")
        Output(ItemName="_ResolvedProjectReferencePaths", TaskParameter="ResolvedOutputPaths")
        Output(ItemName="_MSBuildProjectReference", TaskParameter="UnresolvedProjectReferences")
    // If building from the command line, simply copy the ProjectReferenceWithConfiguration item list to _MSBuildProjectReference,
    // since we have to assume all projects are in the MSBuild format. We have no way of building
    // VSIP (3rd party) projects from the command line.
    ItemGroup
      if '$(BuildingInsideVisualStudio)'!='true' and '@(ProjectReferenceWithConfiguration)'!='':
        _MSBuildProjectReference += "@(ProjectReferenceWithConfiguration)"
    // Break the project list into two lists: those that exist on disk and those that don't.
    // When _BuildNonexistentProjectsByDefault is true, treat all references as existent
    // because they may be virtual (in-memory) projects in the ProjectRootElementCache.
    ItemGroup
      if '$(_BuildNonexistentProjectsByDefault)' == 'true' or Exists('%(Identity)'):
        _MSBuildProjectReferenceExistent += "@(_MSBuildProjectReference)"
      if '$(_BuildNonexistentProjectsByDefault)' != 'true' and !Exists('%(Identity)'):
        _MSBuildProjectReferenceNonexistent += "@(_MSBuildProjectReference)"
  // ====================================================================================
  // _GetProjectReferencePlatformProperties
  //
  // If a project is opted in via $(EnableDynamicPlatformResolution), this target calls the
  // GetCompatiblePlatform task on all ProjectReference items to determine the most compatible
  // platform for each project. It then sets SetPlatform metadata on each ProjectReference.
  // This prevents overbuilding a project when 'AnyCPU' is available.
  //
  // ======================================================================================
  PropertyGroup
    if '$(UseDefaultPlatformLookupTables)' == '':
      UseDefaultPlatformLookupTables = true
  // This target skips sln-based builds because they already supply Platform and
  // Configuration information. See AssignProjectConfiguration
  if '$(EnableDynamicPlatformResolution)' == 'true' and '@(_MSBuildProjectReferenceExistent)' != '':
    Target _GetProjectReferencePlatformProperties
      // Allow preset SetPlatform to override this operation
      ItemGroup
        if '%(_MSBuildProjectReferenceExistent.SetPlatform)' != '':
          _MSBuildProjectReferenceExistent
            SkipGetPlatformProperties = true
      ItemGroup
        if '%(_MSBuildProjectReferenceExistent.SkipGetPlatformProperties)' != 'true':
          _ProjectReferencePlatformPossibilities += "@(_MSBuildProjectReferenceExistent)"
      // Assign default PlatformLookupTables when doing Managed <-> Unmanaged hops
      ItemGroup
        // If we're looking at a c++ project from a managed project, map managed platforms to native platforms.
        if '$(MSBuildProjectExtension)' != '.vcxproj' and '$(MSBuildProjectExtension)' != '.nativeproj' and '%(_ProjectReferencePlatformPossibilities.IsVcxOrNativeProj)' == 'true':
          _ProjectReferencePlatformPossibilities
            // Taken from https://docs.microsoft.com/visualstudio/msbuild/assignprojectconfiguration-task
            if '$(UseDefaultPlatformLookupTables)' == 'true' and '$(PlatformLookupTable)' == '':
              PlatformLookupTable = x86=Win32
        // If we're looking at a managed project from a cpp project, map native to managed platforms.
        if ('$(MSBuildProjectExtension)' == '.vcxproj' or '$(MSBuildProjectExtension)' == '.nativeproj') and '%(_ProjectReferencePlatformPossibilities.IsVcxOrNativeProj)' != 'true':
          _ProjectReferencePlatformPossibilities
            if '$(UseDefaultPlatformLookupTables)' == 'true' and '$(PlatformLookupTable)' == '':
              PlatformLookupTable = Win32=x86
      if '@(_ProjectReferencePlatformPossibilities)' != '':
        GetCompatiblePlatform(
            AnnotatedProjects="@(_ProjectReferencePlatformPossibilities)",
            CurrentProjectPlatform="$(Platform)",
            PlatformLookupTable="$(PlatformLookupTable)")
          Output(
              ItemName="_ProjectsWithPlatformAssignment",
              TaskParameter="AssignedProjectsWithPlatform")
      // If GetCompatiblePlatform didn't run, @(ProjectsWithPlatformAssignment) will be empty.
      // Don't do anything in this case. Ex: A project references many projects
      // that can't multiplatform.
      if '@(_ProjectsWithPlatformAssignment)' != '':
        ItemGroup
          ProjectsWithNearestPlatform += "@(_ProjectsWithPlatformAssignment)"
          if '%(ProjectsWithNearestPlatform.Identity)' != '' and '%(ProjectsWithNearestPlatform.NearestPlatform)' != '':
            ProjectsWithNearestPlatform
              SetPlatform = Platform=%(ProjectsWithNearestPlatform.NearestPlatform)
          // When GetCompatiblePlatform fails to assign NearestPlatform (or determines it's identical to default for the referenced project), undefine Platform and let that project build "on its own"
          if '%(ProjectsWithNearestPlatform.Identity)' != '' and '%(ProjectsWithNearestPlatform.NearestPlatform)' == '':
            ProjectsWithNearestPlatform
              UndefineProperties = %(ProjectsWithNearestPlatform.UndefineProperties);Platform
          if '%(_MSBuildProjectReferenceExistent.SkipGetPlatformProperties)' != 'true':
            _MSBuildProjectReferenceExistent -= "@(_MSBuildProjectReferenceExistent)"
          _MSBuildProjectReferenceExistent += "@(ProjectsWithNearestPlatform)"
  // ====================================================================================
  // _GetProjectReferenceTargetFrameworkProperties
  //
  // Builds the GetTargetFrameworks target of all existent project references to get a list
  // of all supported TargetFrameworks of the referenced projects. Calls the
  // GetReferenceNearestTargetFrameworkTask to determine the closest match for each project.
  // This allows a cross-targeting project to select how it should be configured to build
  // against the most appropriate target for the referring target framework.
  //
  // ======================================================================================
  Target _GetProjectReferenceTargetFrameworkProperties(
      DependsOnTargets="_AddOutputPathToGlobalPropertiesToRemove")
    // Select the moniker to send to each project reference  if not already set. NugetTargetMoniker (NTM) is preferred by default over
    // TargetFrameworkMoniker (TFM) because it is required to disambiguate the UWP case where TFM is fixed at .NETCore,Version=v5.0 and
    // has floating NTM=UAP,Version=vX.Y.Z. However, in other cases (classic PCLs), NTM contains multiple values and that will cause the MSBuild
    // invocation below to fail by passing invalid properties. Therefore we do not use the NTM if it contains a semicolon.
    if '$(ReferringTargetFrameworkForProjectReferences)' == '':
      PropertyGroup
        if '$(NuGetTargetMoniker)' != '' and !$(NuGetTargetMoniker.Contains(';')):
          ReferringTargetFrameworkForProjectReferences = $(NuGetTargetMoniker)
        if '$(NuGetTargetMoniker)' == '':
          ReferringTargetFrameworkForProjectReferences = $(TargetFrameworkMoniker)
    // Honor SkipGetTargetFrameworkProperties=true metadata on project references
    // to mean that the project reference is known not to target multiple frameworks
    // and the mechanism here for selecting the best one can be skipped as an optimization.
    //
    // We give this treatment to .vcxproj by default since no .vcxproj can target more
    // than one framework currently. The user must specify exactly one TargetFramework.
    //
    // vcxproj files compile down to OS-specific binaries, either native or .NET. In the
    // _GetProjectReferenceTargetFrameworkProperties target of Microsoft.Common.CurrentVersion.targets,
    // SkipTargetFrameworkProperties is set to true for vcxproj to account for that.
    //
    // This means we do not fill the Item _ProjectReferenceTargetFrameworkPossibilities or, by extension,
    // the AnnotatedProjects Item.
    //
    // For single-targeted projects, we normally decorate the AnnotatedProjects Item with
    // UndefineProperties metadata specifying that TargetFramework should be undefined. Because it
    // isn't defined properly at that stage, however, this does not happen, and TargetFramework is
    // defined at this point in addition to having been defined globally. Currently, this is always
    // true for vcxproj.
    //
    // MSBuild permits building the same project twice as long as it has different sets of global properties.
    // Because the TargetFramework global property is not being removed as expected by the multitargeting
    // part of MSBuild, the engine recognizes that there are differences and builds it twice. This can
    // become more noticeable if the projects build in parallel, since they could try to access the same
    // resources and conflict, failing the build. Note, however, that building the same project twice in
    // this way is always wrong even if it seems minor because they do not conflict, and the second build is
    // relatively fast.
    ItemGroup
      if '%(_MSBuildProjectReferenceExistent.SkipGetTargetFrameworkProperties)' == '' and ('%(Extension)' == '.vcxproj' or '%(Extension)' == '.nativeproj'):
        _MSBuildProjectReferenceExistent
          // Platform negotiation requires the MSBuild task call to GetTargetFrameworks.
          // Don't skip when opted into the feature.
          if '$(EnableDynamicPlatformResolution)' != 'true':
            SkipGetTargetFrameworkProperties = true
          UndefineProperties = %(_MSBuildProjectReferenceExistent.UndefineProperties);TargetFramework
    // Allow project references to specify which target framework properties to set and their values
    // without consulting the referenced project. This has two use cases:
    //
    // 1. A caller may wish to pick a compatible but sub-optimal target framework. For example,
    // to unit test the .NETStandard implementation using a .NETFramework caller even though
    // there is also a .NETFramework implementation.
    //
    // 2. As an escape hatch for cases where the compatibility check performed by
    // GetTargetFrameworkProperties is faulty.
    ItemGroup
      if '%(_MSBuildProjectReferenceExistent.SetTargetFramework)' != '':
        _MSBuildProjectReferenceExistent
          // Platform negotiation requires the MSBuild task call to GetTargetFrameworks.
          // Don't skip when opted into the feature.
          if '$(EnableDynamicPlatformResolution)' != 'true':
            SkipGetTargetFrameworkProperties = true
    // Get reference target framework lists.
    // Note: A future optimization could cache the closest match and set the target framework on
    // this MSBuild task invocation. This would (optimistically) save an evaluation of the referenced
    // project when the answer is the same.
    if '%(_MSBuildProjectReferenceExistent.SkipGetTargetFrameworkProperties)' != 'true' and '$(EnableDynamicPlatformResolution)' != 'true':
      MSBuild(
          BuildInParallel="$(BuildInParallel)",
          ContinueOnError="!$(BuildingProject)",
          Projects="@(_MSBuildProjectReferenceExistent)",
          Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform)",
          RemoveProperties="%(_MSBuildProjectReferenceExistent.GlobalPropertiesToRemove);TargetFramework;RuntimeIdentifier;SelfContained;$(_GlobalPropertiesToRemoveFromProjectReferences)",
          SkipNonexistentTargets="true",
          Targets="GetTargetFrameworks")
        Output(
            ItemName="_ProjectReferenceTargetFrameworkPossibilities",
            TaskParameter="TargetOutputs")
    // SetPlatform negotiation requires the 'GetTargetFrameworks' MSBuild call to NOT pass global properties. This is to verify
    // whether or not the referenced project would build as the same platform as the current project by default. The above
    // MSBuild call is kept for legacy scenarios that may depend on passing %(SetConfiguration) and %(SetPlatform).
    if '%(_MSBuildProjectReferenceExistent.SkipGetTargetFrameworkProperties)' != 'true' and '$(EnableDynamicPlatformResolution)' == 'true':
      MSBuild(
          BuildInParallel="$(BuildInParallel)",
          ContinueOnError="!$(BuildingProject)",
          Projects="@(_MSBuildProjectReferenceExistent)",
          RemoveProperties="%(_MSBuildProjectReferenceExistent.GlobalPropertiesToRemove);TargetFramework;RuntimeIdentifier;SelfContained;Platform;Configuration;$(_GlobalPropertiesToRemoveFromProjectReferences)",
          SkipNonexistentTargets="true",
          Targets="GetTargetFrameworks")
        Output(
            ItemName="_ProjectReferenceTargetFrameworkPossibilities",
            TaskParameter="TargetOutputs")
    ItemGroup
      // Preserve the ItemSpec value on the _ProjectReferenceTargetFrameworkPossibilities. Because relative paths in another project
      // context would be incorrect, the MSBuild task invocation needs expands the project reference paths in the MSBuild task above.
      // This is generally OK, but if the list is copied the OriginalItemSpec can become the expanded value and cause issues correlating
      // a project reference back to an Item instance.
      _ProjectReferenceTargetFrameworkPossibilitiesOriginalItemSpec += "@(_ProjectReferenceTargetFrameworkPossibilities->'%(OriginalItemSpec)')"
      _ProjectReferenceTargetFrameworkPossibilities -= "@(_ProjectReferenceTargetFrameworkPossibilities)"
      _ProjectReferenceTargetFrameworkPossibilities += "@(_ProjectReferenceTargetFrameworkPossibilitiesOriginalItemSpec)"
    // For each reference, get closest match
    // Pass the CurrentProjectTargetFrameworkProperty parameter to the task only if GetReferenceNearestTargetFrameworkTaskSupportsTargetFrameworkPropertyParameter is true.  This means
    // that we are using a version of NuGet which supports that parameter on this task.
    if '@(_ProjectReferenceTargetFrameworkPossibilities)' != '' and '$(ReferringTargetFrameworkForProjectReferences)' != '' And '$(GetReferenceNearestTargetFrameworkTaskSupportsTargetFrameworkPropertyParameter)' == 'true' and '%(_ProjectReferenceTargetFrameworkPossibilities.IsVcxOrNativeProj)' != 'true':
      GetReferenceNearestTargetFrameworkTask(
          AnnotatedProjectReferences="@(_ProjectReferenceTargetFrameworkPossibilities)",
          CurrentProjectName="$(MSBuildProjectName)",
          CurrentProjectTargetFramework="$(ReferringTargetFrameworkForProjectReferences)",
          CurrentProjectTargetFrameworkProperty="$(TargetFramework)",
          CurrentProjectTargetPlatform="$(TargetPlatformMoniker)",
          FallbackTargetFrameworks="$(AssetTargetFallback)")
        Output(ItemName="AnnotatedProjects", TaskParameter="AssignedProjects")
    // Pass the CurrentProjectTargetPlatform parameter to the task only if GetReferenceNearestTargetFrameworkTaskSupportsTargetPlatformParameter is true and GetReferenceNearestTargetFrameworkTaskSupportsTargetFrameworkPropertyParameter is not true.  This means
    // that we are using a version of NuGet which supports that parameter on this task.
    if '@(_ProjectReferenceTargetFrameworkPossibilities)' != '' and '$(ReferringTargetFrameworkForProjectReferences)' != '' And '$(GetReferenceNearestTargetFrameworkTaskSupportsTargetPlatformParameter)' == 'true' and '$(GetReferenceNearestTargetFrameworkTaskSupportsTargetFrameworkPropertyParameter)' != 'true' and '%(_ProjectReferenceTargetFrameworkPossibilities.IsVcxOrNativeProj)' != 'true':
      GetReferenceNearestTargetFrameworkTask(
          AnnotatedProjectReferences="@(_ProjectReferenceTargetFrameworkPossibilities)",
          CurrentProjectName="$(MSBuildProjectName)",
          CurrentProjectTargetFramework="$(ReferringTargetFrameworkForProjectReferences)",
          CurrentProjectTargetPlatform="$(TargetPlatformMoniker)",
          FallbackTargetFrameworks="$(AssetTargetFallback)")
        Output(ItemName="AnnotatedProjects", TaskParameter="AssignedProjects")
    if '@(_ProjectReferenceTargetFrameworkPossibilities)' != '' and '$(ReferringTargetFrameworkForProjectReferences)' != '' And '$(GetReferenceNearestTargetFrameworkTaskSupportsTargetPlatformParameter)' != 'true' and '%(_ProjectReferenceTargetFrameworkPossibilities.IsVcxOrNativeProj)' != 'true':
      GetReferenceNearestTargetFrameworkTask(
          AnnotatedProjectReferences="@(_ProjectReferenceTargetFrameworkPossibilities)",
          CurrentProjectName="$(MSBuildProjectName)",
          CurrentProjectTargetFramework="$(ReferringTargetFrameworkForProjectReferences)",
          FallbackTargetFrameworks="$(AssetTargetFallback)")
        Output(ItemName="AnnotatedProjects", TaskParameter="AssignedProjects")
    ItemGroup
      // If the task was skipped or the current TargetFramework is empty, AnnotatedProjects will be empty.
      // In this case, copy _ProjectReferenceTargetFrameworkPossibilities as is. See:
      // https://github.com/dotnet/sdk/issues/416
      //
      // Furthermore, if we're referencing a .vcxproj or .nativeproj, those items won't be populated into `AnnotatedProjects`
      // by `GetReferenceNearestTargetFrameworkTask`, so let them flow when `EnableDynamicPlatformResolution` is set.
      if '$(ReferringTargetFrameworkForProjectReferences)' == '' or ('$(EnableDynamicPlatformResolution)' == 'true' and '%(_ProjectReferenceTargetFrameworkPossibilities.IsVcxOrNativeProj)' == 'true'):
        AnnotatedProjects += "@(_ProjectReferenceTargetFrameworkPossibilities)"
    // IsRidAgnostic metadata is used to determine whether global properties such as RuntimeIdentifier and SelfContained flow to a referenced project.
    // However, for multi-targeted projects there may be a different IsRidAgnostic value for each TargetFramework.  In that case, this task selects
    // the IsRidAgnostic value for the NearestTargetFramework for the project.
    SetRidAgnosticValueForProjects(Projects="@(AnnotatedProjects)")
      Output(ItemName="UpdatedAnnotatedProjects", TaskParameter="UpdatedProjects")
    ItemGroup
      AnnotatedProjects -= "@(AnnotatedProjects)"
      AnnotatedProjects += "@(UpdatedAnnotatedProjects)"
      UpdatedAnnotatedProjects -= "@(UpdatedAnnotatedProjects)"
      // If the NearestTargetFramework property was set and the project multi-targets, SetTargetFramework must be set.
      if '%(AnnotatedProjects.Identity)' != '' and '%(AnnotatedProjects.NearestTargetFramework)' != '' and '%(AnnotatedProjects.HasSingleTargetFramework)' != 'true':
        AnnotatedProjects
          SetTargetFramework = TargetFramework=%(AnnotatedProjects.NearestTargetFramework)
      // If the NearestTargetFramework property was not set or the project has a single TargetFramework, we need to Undefine
      // TargetFramework to avoid another project evaluation.
      if '%(AnnotatedProjects.Identity)' != '' and ('%(AnnotatedProjects.NearestTargetFramework)' == '' or '%(AnnotatedProjects.HasSingleTargetFramework)' == 'true'):
        AnnotatedProjects
          UndefineProperties = %(AnnotatedProjects.UndefineProperties);TargetFramework
      // Add RuntimeIdentifier and SelfContained to the list of global properties that should not flow to the referenced project,
      // unless the project is expecting those properties to flow.
      if '%(AnnotatedProjects.Identity)' != '' and '%(AnnotatedProjects.IsRidAgnostic)' != 'false':
        AnnotatedProjects
          UndefineProperties = %(AnnotatedProjects.UndefineProperties);RuntimeIdentifier;SelfContained
      // Remove the items we've touched from _MSBuildProjectReferenceExistent. This will leave all projects where
      // SkipGetTargetFrameworkProperties was set. Then add all AnnotatedProjects back.
      if '%(_MSBuildProjectReferenceExistent.SkipGetTargetFrameworkProperties)' != 'true':
        _MSBuildProjectReferenceExistent -= "@(_MSBuildProjectReferenceExistent)"
      _MSBuildProjectReferenceExistent += "@(AnnotatedProjects)"
  Target GetTargetFrameworks(
      DependsOnTargets="GetTargetFrameworksWithPlatformForSingleTargetFramework",
      Returns="@(_ThisProjectBuildMetadata)")
    if '$(IsCrossTargetingBuild)' == 'true':
      MSBuildInternalMessage(
          ResourceName="CommonSdk.CrossTargetingGetTargetFrameworks",
          Severity="Error")
    CombineXmlElements(
        RootElementName="AdditionalProjectProperties",
        XmlElements="@(_TargetFrameworkInfo->'%(AdditionalPropertiesFromProject)')")
      Output(PropertyName="_AdditionalPropertiesFromProject", TaskParameter="Result")
    ItemGroup
      _ThisProjectBuildMetadata += "$(MSBuildProjectFullPath)"
        TargetFrameworks = @(_TargetFrameworkInfo)
        TargetFrameworkMonikers = @(_TargetFrameworkInfo->'%(TargetFrameworkMonikers)')
        TargetPlatformMonikers = @(_TargetFrameworkInfo->'%(TargetPlatformMonikers)')
        AdditionalPropertiesFromProject = $(_AdditionalPropertiesFromProject)
        HasSingleTargetFramework = true
        IsRidAgnostic = @(_TargetFrameworkInfo->'%(IsRidAgnostic)')
        // Extract necessary information for SetPlatform negotiation
        if '$(MSBuildProjectExtension)' == '.vcxproj' or '$(MSBuildProjectExtension)' == '.nativeproj':
          IsVcxOrNativeProj = true
        copy properties:
          Platform
          Platforms
        // .vcxproj and .nativeproj contain a `ProjectConfiguration` item that have `Platform` metadata within.
        // Build the `Platforms` property from that.
        if '$(UsePlatformFromProjectConfiguration)' != 'false' and '@(ProjectConfiguration)' != '' and ('$(MSBuildProjectExtension)' == '.vcxproj' or '$(MSBuildProjectExtension)' == '.nativeproj'):
          Platforms = @(ProjectConfiguration->'%(Platform)'->Distinct())
  Target GetTargetFrameworksWithPlatformForSingleTargetFramework(Returns="@(_TargetFrameworkInfo)")
    ItemGroup
      _AdditionalTargetFrameworkInfoPropertyWithValue += "@(AdditionalTargetFrameworkInfoProperty)"
        Value = $(%(AdditionalTargetFrameworkInfoProperty.Identity))
    PropertyGroup
      if '$(_UseAttributeForTargetFrameworkInfoPropertyNames)' == '':
        _UseAttributeForTargetFrameworkInfoPropertyNames = false
    CombineTargetFrameworkInfoProperties(
        PropertiesAndValues="@(_AdditionalTargetFrameworkInfoPropertyWithValue)",
        RootElementName="$(TargetFramework)",
        UseAttributeForTargetFrameworkInfoPropertyNames="$(_UseAttributeForTargetFrameworkInfoPropertyNames)")
      Output(PropertyName="_AdditionalTargetFrameworkInfoProperties", TaskParameter="Result")
    ItemGroup
      _TargetFrameworkInfo += "$(TargetFramework)"
        TargetFrameworks = $(TargetFramework)
        TargetFrameworkMonikers = $(TargetFrameworkMoniker)
        TargetPlatformMonikers = $(TargetPlatformMoniker)
        if '$(TargetPlatformMoniker)' == '':
          TargetPlatformMonikers = None
        AdditionalPropertiesFromProject = $(_AdditionalTargetFrameworkInfoProperties)
        // Determine whether a project is "RID agnostic" for each TargetFramework.  "RID agnostic" means that global properties such as
        // SelfContained and RuntimeIdentifier should not flow across project references.  The IsRidAgnostic metadata value is consumed in the
        // _GetProjectReferenceTargetFrameworkProperties target, where those properties are added to a project's UndefineProperties if
        // IsRidAgnostic is set.
        //
        // Generally we set the IsRidAgnostic metadata based on the IsRidAgnostic property set by the .NET SDK.  If that's not set, then the
        // fallback logic here will be that the project is RID agnostic if it doesn't have RuntimeIdentifier or RuntimeIdentifiers properties set.
        IsRidAgnostic = $(IsRidAgnostic)
        if '%(IsRidAgnostic)' == '' and '$(RuntimeIdentifier)' == '' and '$(RuntimeIdentifiers)' == '':
          IsRidAgnostic = true
        if '%(IsRidAgnostic)' == '':
          IsRidAgnostic = false
  // ============================================================
  // GetTargetFrameworkProperties
  //
  // OBSOLETE: present only for theoretical backward compatibility.
  Target GetTargetFrameworkProperties
  // ============================================================
  // PrepareProjectReferences
  //
  // Prepares project references for consumption by other targets.
  //
  // [IN]
  // @(ProjectReference) - The list of project references.
  //
  // [OUT]
  // @(ProjectReferenceWithConfiguration)   - Project references with apporpriate metadata
  // @(_MSBuildProjectReferenceExistent)    - Subset of @(ProjectReferenceWithConfiguration) that exist
  // with added SetTargetFramework metadata for cross-targeting
  // @(_MSBuildProjectReferenceNonExistent) - Subset of  @(ProjectReferenceWithConfiguration) that do not exist
  // ============================================================
  PropertyGroup
    PrepareProjectReferencesDependsOn =
      | AssignProjectConfiguration;
      |       _SplitProjectReferencesByFileExistence;
      |       _GetProjectReferenceTargetFrameworkProperties;
      |       _GetProjectReferencePlatformProperties
  Target PrepareProjectReferences(DependsOnTargets="$(PrepareProjectReferencesDependsOn)")
  // ============================================================
  // ResolveProjectReferences
  //
  // Build referenced projects:
  //
  // [IN]
  // @(ProjectReferenceWithConfiguration) - The list of project references.
  //
  // [OUT]
  // @(_ResolvedNativeProjectReferencePaths) - Paths to referenced native projects.
  // @(_ResolvedProjectReferencePaths) - Paths to referenced managed projects.
  // ============================================================
  // By default, the outputs of project references are passed to the compiler
  ItemDefinitionGroup
    ProjectReference
      // Target to build in the project reference; by default, this property is blank, indicating the default targets
      Targets = $(ProjectReferenceBuildTargets)
      // Extra item type to emit outputs of the destination into. Defaults to blank. To emit only into this list, set the ReferenceOutputAssembly metadata to false as well.
      OutputItemType
      ReferenceSourceTarget = ProjectReference
  Target ResolveProjectReferences(
      DependsOnTargets="PrepareProjectReferences",
      Returns="@(_ResolvedNativeProjectReferencePaths);@(_ResolvedProjectReferencePaths)")
    // When building this project from the IDE, just gather the referenced build outputs.
    // The IDE will already have built the project, so there's no need to do it again here.
    //
    // The ContinueOnError setting is here so that, during project load, as
    // much information as possible will be passed to the compilers.
    if '%(_MSBuildProjectReferenceExistent.BuildReference)' == 'true' and '@(ProjectReferenceWithConfiguration)' != '' and ('$(BuildingInsideVisualStudio)' == 'true' or '$(BuildProjectReferences)' != 'true') and '$(VisualStudioVersion)' != '10.0' and '@(_MSBuildProjectReferenceExistent)' != '':
      MSBuild(
          BuildInParallel="$(BuildInParallel)",
          ContinueOnError="!$(BuildingProject)",
          Projects="@(_MSBuildProjectReferenceExistent)",
          Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform); %(_MSBuildProjectReferenceExistent.SetTargetFramework)",
          RemoveProperties="%(_MSBuildProjectReferenceExistent.GlobalPropertiesToRemove)$(_GlobalPropertiesToRemoveFromProjectReferences)",
          Targets="GetTargetPath")
        if '%(_MSBuildProjectReferenceExistent.ReferenceOutputAssembly)'=='true':
          Output(ItemName="_ResolvedProjectReferencePaths", TaskParameter="TargetOutputs")
        if '%(_MSBuildProjectReferenceExistent.OutputItemType)' != '':
          Output(
              ItemName="%(_MSBuildProjectReferenceExistent.OutputItemType)",
              TaskParameter="TargetOutputs")
    // Build referenced projects when building from the command line.
    if '%(_MSBuildProjectReferenceExistent.BuildReference)' == 'true' and '@(ProjectReferenceWithConfiguration)' != '' and '$(BuildingInsideVisualStudio)' != 'true' and '$(BuildProjectReferences)' == 'true' and '@(_MSBuildProjectReferenceExistent)' != '':
      MSBuild(
          BuildInParallel="$(BuildInParallel)",
          ContinueOnError="$(ContinueOnError)",
          Projects="@(_MSBuildProjectReferenceExistent)",
          Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform);  %(_MSBuildProjectReferenceExistent.SetTargetFramework)",
          RemoveProperties="%(_MSBuildProjectReferenceExistent.GlobalPropertiesToRemove)$(_GlobalPropertiesToRemoveFromProjectReferences)",
          Targets="%(_MSBuildProjectReferenceExistent.Targets)")
        if '%(_MSBuildProjectReferenceExistent.ReferenceOutputAssembly)'=='true' or '$(DesignTimeBuild)' == 'true':
          Output(ItemName="_ResolvedProjectReferencePaths", TaskParameter="TargetOutputs")
        if '%(_MSBuildProjectReferenceExistent.OutputItemType)' != '':
          Output(
              ItemName="%(_MSBuildProjectReferenceExistent.OutputItemType)",
              TaskParameter="TargetOutputs")
    // Get manifest items from the (non-exe) built project references (to feed them into ResolveNativeReference).
    if '%(_MSBuildProjectReferenceExistent.BuildReference)' == 'true' and '@(ProjectReferenceWithConfiguration)' != '' and '$(BuildingProject)' == 'true' and '@(_MSBuildProjectReferenceExistent)' != '':
      MSBuild(
          BuildInParallel="$(BuildInParallel)",
          ContinueOnError="$(ContinueOnError)",
          Projects="@(_MSBuildProjectReferenceExistent)",
          Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform); %(_MSBuildProjectReferenceExistent.SetTargetFramework)",
          RemoveProperties="%(_MSBuildProjectReferenceExistent.GlobalPropertiesToRemove)$(_GlobalPropertiesToRemoveFromProjectReferences)",
          SkipNonexistentTargets="true",
          Targets="GetNativeManifest")
        if '%(_MSBuildProjectReferenceExistent.ReferenceOutputAssembly)' == 'true':
          Output(ItemName="NativeReference", TaskParameter="TargetOutputs")
    ItemGroup
      if '%(_ResolvedProjectReferencePaths.ResolveableAssembly)' == 'false':
        _ResolvedProjectReferencePaths -= "@(_ResolvedProjectReferencePaths)"
      // Copy OriginalItemSpec to OriginalProjectReferenceItemSpec, so that when ResolveAssemblyReferences
      // takes these items and resolves them to ReferencePath, we can still recover the _real_ OriginalItemSpec
      // for the unresolved reference items.
      _ResolvedProjectReferencePaths
        OriginalProjectReferenceItemSpec = %(_ResolvedProjectReferencePaths.OriginalItemSpec)
    // Issue a warning or error MSB9008 for each non-existent project.
    PropertyGroup
      if '@(ProjectReferenceWithConfiguration)' != '' and '@(_MSBuildProjectReferenceNonexistent)' != '' and '$(ErrorOnMissingProjectReference)' != 'True':
        _NonExistentProjectReferenceSeverity = Warning
      if '@(ProjectReferenceWithConfiguration)' != '' and '@(_MSBuildProjectReferenceNonexistent)' != '' and '$(ErrorOnMissingProjectReference)' == 'True':
        _NonExistentProjectReferenceSeverity = Error
    if '$(_NonExistentProjectReferenceSeverity)' != '':
      MSBuildInternalMessage(
          FormatArguments="@(_MSBuildProjectReferenceNonexistent->'%(Identity)')",
          ResourceName="CommonSdk.NonExistentProjectReference",
          Severity="$(_NonExistentProjectReferenceSeverity)")
  Target ResolveProjectReferencesDesignTime(
      DependsOnTargets=[
        ResolveProjectReferences
        ResolveAssemblyReferences
      ],
      Returns="@(_ProjectReferencesFromRAR);@(_ResolvedNativeProjectReferencePaths)")
    // We need to do this here because we only want project references which have passed through rar and have not been unresolved due to violating some MT rule
    // which means we need to pull the project references out of the referencepath item because they will only exist there if they were correctly resolved.
    ItemGroup
      _ProjectReferencesFromRAR += "@(ReferencePath->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))"
        OriginalItemSpec = %(ReferencePath.ProjectReferenceOriginalItemSpec)
  Target ExpandSDKReferencesDesignTime(
      DependsOnTargets="ExpandSDKReferences",
      Returns="@(ReferencesFromSDK)")
  // ============================================================
  // GetTargetPath
  //
  // This target returns an item containing the build product (i.e. EXE, DLL)
  // that would be produced if we built this project, with some relevant
  // metadata.
  // ============================================================
  Target GetTargetPath(
      DependsOnTargets="$(GetTargetPathDependsOn)",
      Returns="@(TargetPathWithTargetPlatformMoniker)")
  // ============================================================
  // GetTargetPathWithTargetPlatformMoniker
  //
  // This stand-alone target returns the name and version of the target platform for this project.
  //
  // NOTE: The ProjectReference protocol uses only GetTargetPath. Computing the item
  // in this target allows projects to override GetTargetPath without having to reimplement
  // the details of the metadata computation.
  // ============================================================
  PropertyGroup
    GetTargetPathWithTargetPlatformMonikerDependsOn = $(GetTargetPathDependsOn)
  // NOTE: since an overridden GetTargetPath might not include a DependsOn
  // for this target, it's safer to establish the dependency here with a
  // BeforeTargets.
  Target GetTargetPathWithTargetPlatformMoniker(
      BeforeTargets="GetTargetPath",
      DependsOnTargets="$(GetTargetPathWithTargetPlatformMonikerDependsOn)",
      Returns="@(TargetPathWithTargetPlatformMoniker)")
    ItemGroup
      TargetPathWithTargetPlatformMoniker += "$(TargetPath)"
        copy properties:
          TargetPlatformMoniker
          TargetPlatformIdentifier
          TargetFrameworkIdentifier
        TargetFrameworkVersion = $(TargetFrameworkVersion.TrimStart('vV'))
        if '$(ProduceReferenceAssembly)' == 'true':
          ReferenceAssembly = $(TargetRefPath)
        CopyUpToDateMarker = @(CopyUpToDateMarker)
  // ============================================================
  // GetNativeManifest
  //
  // Compute the manifest item for this project.
  //
  // [IN]
  // $(_DeploymentApplicationManifestIdentity) - the manifest identity
  // @(ApplicationManifest)         - the original application manifest item
  //
  // [OUT]
  // @(ComputedApplicationManifest) - application manifest item with full hint path, if generated
  // ============================================================
  Target GetNativeManifest(Returns="@(ComputedApplicationManifest)")
    ItemGroup
      if '$(OutputType)'!='winexe' and '$(OutputType)'!='exe' and '$(OutputType)'!='appcontainerexe' and Exists('%(_ApplicationManifestFinal.FullPath)'):
        ComputedApplicationManifest += "$(_DeploymentApplicationManifestIdentity)"
          HintPath = %(_ApplicationManifestFinal.FullPath)
  // ============================================================
  // ResolveNativeReferences
  //
  // Resolve native references
  //
  // [IN]
  // @(NativeReference) - The manifest reference (or list of manifest references)
  //
  // [OUT]
  // @(NativeReferenceFile)  - List of manifest files referenced.
  // @(_DeploymentNativePrerequisite)   - List of native assembly prerequisites contained in the manifest.
  // @(ComClassReference)    - List of COM components contained in the manifest.
  // @(COMReferenceFromNative) List of type libraries contained in the manifest.
  // @(COMFileReference)     - List of loose files contained in the manifest.
  // @(_DeploymentLooseManifestFile)    - List of extra files that should be published.
  // ============================================================
  if '@(NativeReference)'!='':
    Target ResolveNativeReferences(DependsOnTargets="ResolveProjectReferences")
      ResolveNativeReference(
          AdditionalSearchPaths="$(ReferencePath);$(OutDir)",
          NativeReferences="@(NativeReference)")
        Output(ItemName="NativeReferenceFile", TaskParameter="ContainingReferenceFiles")
        Output(
            ItemName="_DeploymentNativePrerequisite",
            TaskParameter="ContainedPrerequisiteAssemblies")
        Output(ItemName="ComClassReference", TaskParameter="ContainedComComponents")
        Output(ItemName="COMReferenceFromNative", TaskParameter="ContainedTypeLibraries")
        Output(ItemName="COMFileReference", TaskParameter="ContainedLooseTlbFiles")
        Output(ItemName="_DeploymentLooseManifestFile", TaskParameter="ContainedLooseEtcFiles")
  // ============================================================
  //
  // ResolveAssemblyReferences
  //
  // Given the list of assemblies, find the closure of all assemblies that they depend on. These are
  // what we need to copy to the output directory.
  //
  // [IN]
  // @(Reference) - List of assembly references as fusion names.
  // @(_ResolvedProjectReferencePaths) - List of project references produced by projects that this project depends on.
  //
  // The 'Private' attribute on the reference corresponds to the Copy Local flag in IDE.
  // The 'Private' flag can have three possible values:
  // - 'True' means the reference should be Copied Local
  // - 'False' means the reference should not be Copied Local
  // - [Missing] means this task will decide whether to treat this reference as CopyLocal or not.
  //
  // [OUT]
  // @(ReferencePath) - Paths to resolved primary files.
  // @(ReferenceDependencyPaths) - Paths to resolved dependency files.
  // @(_ReferenceRelatedPaths) - Paths to .xmls and .pdbs.
  // @(ReferenceSatellitePaths) - Paths to satellites.
  // @(_ReferenceSerializationAssemblyPaths) - Paths to XML serialization assemblies created by sgen.
  // @(_ReferenceScatterPaths) - Paths to scatter files.
  // @(ReferenceCopyLocalPaths) - Paths to files that should be copied to the local directory.
  // ============================================================
  PropertyGroup
    ResolveAssemblyReferencesDependsOn =
      | ResolveProjectReferences;
      |       FindInvalidProjectReferences;
      |       GetFrameworkPaths;
      |       GetReferenceAssemblyPaths;
      |       PrepareForBuild;
      |       ResolveSDKReferences;
      |       ExpandSDKReferences;
  Target ResolveAssemblyReferences(
      DependsOnTargets="$(ResolveAssemblyReferencesDependsOn)",
      Returns="@(ReferencePath)")
    ItemGroup
      _ReferenceInstalledAssemblyDirectory += "$(TargetFrameworkDirectory)"
      _ReferenceInstalledAssemblySubsets += "$(TargetFrameworkSubset)"
    // Only read and write cache file at build time, skip it for load time because its more
    // expensive to write the newly created cache file.
    PropertyGroup
      if '$(DisableRarCache)'!='true' and '$(ResolveAssemblyReferencesStateFile)' == '':
        ResolveAssemblyReferencesStateFile = $(IntermediateOutputPath)$(MSBuildProjectFile).AssemblyReference.cache
    PropertyGroup
      if '$(AllowResolveAssemblyReferencesOutOfProcNode)' == '':
        AllowResolveAssemblyReferencesOutOfProcNode = false
    // Make an App.Config item that exists when AutoUnify is false.
    ItemGroup
      if '$(AutoGenerateBindingRedirects)'=='true' or '$(AutoUnifyAssemblyReferences)'=='false':
        _ResolveAssemblyReferencesApplicationConfigFileForExes += "@(AppConfigWithTargetPath)"
    PropertyGroup
      // Default in task is true
      if '$(BuildingProject)' != 'true' and '$(_ResolveReferenceDependencies)' != 'true':
        _FindDependencies = false
      if '$(ResolveAssemblyReferencesSilent)' == '' and '$(TraceDesignTime)' != 'true' and '$(BuildingProject)' == 'false':
        ResolveAssemblyReferencesSilent = true
      if '$(ResolveAssemblyReferencesSilent)' == '':
        ResolveAssemblyReferencesSilent = false
      if '$(ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch)' == '':
        ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch = Warning
      if '$(ResolveAssemblyReferencesFindRelatedSatellites)' == '':
        ResolveAssemblyReferencesFindRelatedSatellites = $(BuildingProject)
      if '$(ResolveAssemblyReferencesFindSerializationAssemblies)' == '':
        ResolveAssemblyReferencesFindSerializationAssemblies = $(BuildingProject)
      if '$(ResolveAssemblyReferencesFindRelatedFiles)' == '':
        ResolveAssemblyReferencesFindRelatedFiles = $(BuildingProject)
      if '$(ResolveAssemblyReferenceOutputUnresolvedAssemblyConflicts)' == '':
        ResolveAssemblyReferenceOutputUnresolvedAssemblyConflicts = false
    ItemGroup
      // Remove any references which we have added as explicit reference so that we do not get duplicates. We need to make sure we do not have duplicates
      // because this confuses the IDE  when it tries to compare the list of references passed in to the list of resolved references. If it does not match then the
      // ide will show one of the references as not resolved, this will not break the build but is a display issue
      Reference -= "$(AdditionalExplicitAssemblyReferences)"
      Reference += "$(AdditionalExplicitAssemblyReferences)"
        Implicit = true
    // Converts string property NonCultureResourceDirectories to array if present. NonCultureResourceDirectories defines exclusions for the custom cultures.
    if '$(NonCultureResourceDirectories)' != '':
      ItemGroup
        NonCultureResourceDirectory += "$(NonCultureResourceDirectories)"
    if '$(EnableCustomCulture)' == '':
      PropertyGroup
        EnableCustomCulture = false
    // Normally, as an optimization, finding dependencies of references marked with ExternallyResolved=true metadata is skipped.
    // However, skipping that step breaks binding redirect generation when there are conflicting versions within the externally
    // resolved graph.
    if '$(FindDependenciesOfExternallyResolvedReferences)' == '':
      PropertyGroup
        FindDependenciesOfExternallyResolvedReferences = false
        if '$(AutoGenerateBindingRedirects)' == 'true':
          FindDependenciesOfExternallyResolvedReferences = true
    if '@(Reference)'!='' or '@(_ResolvedProjectReferencePaths)'!='' or '@(_ExplicitReference)' != '':
      ResolveAssemblyReference(
          AllowOutOfProcNode="$(AllowResolveAssemblyReferencesOutOfProcNode)",
          AllowedAssemblyExtensions="$(AllowedReferenceAssemblyFileExtensions)",
          AllowedRelatedFileExtensions="$(AllowedReferenceRelatedFileExtensions)",
          AppConfigFile="@(_ResolveAssemblyReferencesApplicationConfigFileForExes)",
          Assemblies="@(Reference)",
          AssemblyFiles="@(_ResolvedProjectReferencePaths);@(_ExplicitReference)",
          AssemblyInformationCacheOutputPath="$(AssemblyInformationCacheOutputPath)",
          AssemblyInformationCachePaths="$(AssemblyInformationCachePaths)",
          AutoUnify="$(AutoUnifyAssemblyReferences)",
          CandidateAssemblyFiles="@(Content);@(None)",
          ContinueOnError="$(ContinueOnError)",
          CopyLocalDependenciesWhenParentReferenceInGac="$(CopyLocalDependenciesWhenParentReferenceInGac)",
          DoNotCopyLocalIfInGac="$(DoNotCopyLocalIfInGac)",
          EnableCustomCulture="$(EnableCustomCulture)",
          FindDependencies="$(_FindDependencies)",
          FindDependenciesOfExternallyResolvedReferences="$(FindDependenciesOfExternallyResolvedReferences)",
          FindRelatedFiles="$(ResolveAssemblyReferencesFindRelatedFiles)",
          FindSatellites="$(ResolveAssemblyReferencesFindRelatedSatellites)",
          FindSerializationAssemblies="$(ResolveAssemblyReferencesFindSerializationAssemblies)",
          FullFrameworkAssemblyTables="@(FullFrameworkAssemblyTables)",
          FullFrameworkFolders="$(_FullFrameworkReferenceAssemblyPaths)",
          FullTargetFrameworkSubsetNames="$(FullReferenceAssemblyNames)",
          IgnoreDefaultInstalledAssemblySubsetTables="$(IgnoreInstalledAssemblySubsetTables)",
          IgnoreDefaultInstalledAssemblyTables="$(IgnoreDefaultInstalledAssemblyTables)",
          IgnoreTargetFrameworkAttributeVersionMismatch="$(ResolveAssemblyReferenceIgnoreTargetFrameworkAttributeVersionMismatch)",
          IgnoreVersionForFrameworkReferences="$(IgnoreVersionForFrameworkReferences)",
          InstalledAssemblySubsetTables="@(InstalledAssemblySubsetTables)",
          InstalledAssemblyTables="@(InstalledAssemblyTables);@(RedistList)",
          LatestTargetFrameworkDirectories="@(LatestTargetFrameworkDirectories)",
          NonCultureResourceDirectories="@(NonCultureResourceDirectory)",
          OutputUnresolvedAssemblyConflicts="$(ResolveAssemblyReferenceOutputUnresolvedAssemblyConflicts)",
          ProfileName="$(TargetFrameworkProfile)",
          ResolvedSDKReferences="@(ResolvedSDKReference)",
          SearchPaths="$(AssemblySearchPaths)",
          Silent="$(ResolveAssemblyReferencesSilent)",
          StateFile="$(ResolveAssemblyReferencesStateFile)",
          SupportsBindingRedirectGeneration="$(GenerateBindingRedirectsOutputType)",
          TargetFrameworkDirectories="@(_ReferenceInstalledAssemblyDirectory)",
          TargetFrameworkMoniker="$(TargetFrameworkMoniker)",
          TargetFrameworkMonikerDisplayName="$(TargetFrameworkMonikerDisplayName)",
          TargetFrameworkSubsets="@(_ReferenceInstalledAssemblySubsets)",
          TargetFrameworkVersion="$(TargetFrameworkVersion)",
          TargetProcessorArchitecture="$(ProcessorArchitecture)",
          TargetedRuntimeVersion="$(TargetedRuntimeVersion)",
          WarnOrErrorOnTargetArchitectureMismatch="$(ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch)")
        Output(ItemName="ReferencePath", TaskParameter="ResolvedFiles")
        Output(ItemName="_ResolveAssemblyReferenceResolvedFiles", TaskParameter="ResolvedFiles")
        Output(ItemName="ReferenceDependencyPaths", TaskParameter="ResolvedDependencyFiles")
        Output(ItemName="_ReferenceRelatedPaths", TaskParameter="RelatedFiles")
        Output(ItemName="ReferenceSatellitePaths", TaskParameter="SatelliteFiles")
        Output(
            ItemName="_ReferenceSerializationAssemblyPaths",
            TaskParameter="SerializationAssemblyFiles")
        Output(ItemName="_ReferenceScatterPaths", TaskParameter="ScatterFiles")
        Output(ItemName="ReferenceCopyLocalPaths", TaskParameter="CopyLocalFiles")
        Output(ItemName="SuggestedBindingRedirects", TaskParameter="SuggestedRedirects")
        Output(ItemName="FileWrites", TaskParameter="FilesWritten")
        Output(PropertyName="DependsOnSystemRuntime", TaskParameter="DependsOnSystemRuntime")
        Output(PropertyName="_DependsOnNETStandard", TaskParameter="DependsOnNETStandard")
        Output(
            ItemName="ResolveAssemblyReferenceUnresolvedAssemblyConflicts",
            TaskParameter="UnresolvedAssemblyConflicts")
  // ============================================================
  //
  // FindReferenceAssembliesForReferences
  //
  // Given the list of references, create a list of assemblies to pass to the compiler that
  // includes reference assemblies rather than implementation assemblies where possible.
  //
  // [IN]
  // @(ReferencePath) - List of assembly references as resolved paths with ReferenceAssembly metadata
  //
  // [OUT]
  // @(ReferencePathWithRefAssemblies) - Paths to resolved reference (or implementation) assemblies.
  // ============================================================
  Target FindReferenceAssembliesForReferences(DependsOnTargets="ResolveReferences")
    ItemGroup
      // Reference assemblies are not produced in all cases, but it's easier to consume them
      // if this metadatum is always populated. Ensure that it points to the implementation
      // assembly unless already specified.
      if '%(ReferencePath.ReferenceAssembly)' == '':
        ReferencePath
          ReferenceAssembly = %(FullPath)
      if '$(CompileUsingReferenceAssemblies)' != 'false':
        ReferencePathWithRefAssemblies += "@(ReferencePath->'%(ReferenceAssembly)')"
          if '%(ReferencePath.Identity)' != '@(ReferencePath->'%(ReferenceAssembly)')':
            OriginalPath = %(ReferencePath.Identity)
      if '$(CompileUsingReferenceAssemblies)' == 'false':
        ReferencePathWithRefAssemblies += "@(ReferencePath)"
  // ====================================================================================================
  //
  // GenerateBindingRedirects
  // Inject the binding redirects into the app config file based on suggested redirects as output from
  // ResolveAssemblyReferences.
  //
  // [IN]
  // @(AppConfigWithTargetPath) - Path to the source app config file. This can be null if the project
  // doesn't contain an app config file.
  // $(TargetFileName) -          The file name of the build target.
  //
  // [OUT]
  // @(OutputAppConfigFile) -     Path to the output app config file in the intermediate directory.
  //
  // ====================================================================================================
  if '$(AutoGenerateBindingRedirects)' == 'true' and '$(GenerateBindingRedirectsOutputType)' == 'true' and '@(SuggestedBindingRedirects)' != '' and '$(DesignTimeBuild)' != 'true' and '$(BuildingProject)' == 'true':
    Target GenerateBindingRedirects(
        DependsOnTargets="_GenerateSuggestedBindingRedirectsCache",
        Inputs="$(MSBuildAllProjects);@(AppConfigWithTargetPath);$(SuggestedBindingRedirectsCacheFile)",
        Outputs="$(_GenerateBindingRedirectsIntermediateAppConfig)")
      GenerateBindingRedirects(
          AppConfigFile="@(AppConfigWithTargetPath)",
          OutputAppConfigFile="$(_GenerateBindingRedirectsIntermediateAppConfig)",
          SuggestedRedirects="@(SuggestedBindingRedirects)",
          TargetName="$(TargetFileName).config")
      ItemGroup
        FileWrites += "$(_GenerateBindingRedirectsIntermediateAppConfig)"
  // ====================================================================================================
  //
  // GenerateBindingRedirectsUpdateAppConfig
  // Updates the project to use the generated app.config content.  This needs to run regardless of
  // inputs/outputs so it is seperate from GenerateBindingRedirects.
  // ====================================================================================================
  if '$(AutoGenerateBindingRedirects)' == 'true' and '$(GenerateBindingRedirectsOutputType)' == 'true':
    Target GenerateBindingRedirectsUpdateAppConfig
      PropertyGroup
        if Exists('$(_GenerateBindingRedirectsIntermediateAppConfig)'):
          _NewGenerateBindingRedirectsIntermediateAppConfig = true
        if $(_NewGenerateBindingRedirectsIntermediateAppConfig) == 'true':
          AppConfig = $(_GenerateBindingRedirectsIntermediateAppConfig)
      if $(_NewGenerateBindingRedirectsIntermediateAppConfig) == 'true':
        ItemGroup
          AppConfigWithTargetPath -= "@(AppConfigWithTargetPath)"
          AppConfigWithTargetPath += "$(AppConfig)"
            TargetPath = $(TargetFileName).config
  // ===========================================================================================
  // GetInstalledSDKs
  //
  // Gets the list of SDKs installed in the SDKDirectoryRoot and SDKRegistryRoot locations
  //
  // These paths are used by the ResolveSDKReference task and the ResolveAssemblyReference task.
  // ===========================================================================================
  PropertyGroup
    if '$(SDKReferenceRegistryRoot)' == '':
      SDKReferenceRegistryRoot = Software\Microsoft\Microsoft SDKs
    if '$(SDKReferenceDirectoryRoot)' == '':
      SDKReferenceDirectoryRoot = $(LocalAppData)\Microsoft SDKs;$(MSBuildProgramFiles32)\Microsoft SDKs
    // Manifest driven extension SDK locations
    if '$(SDKExtensionDirectoryRoot)' == '' and '$(SDKIdentifier)' != '':
      SDKExtensionDirectoryRoot = $(MSBuildProgramFiles32)\Microsoft SDKs\Windows Kits\10;$(WindowsKitsRoot)
    // UAP projects by default should support Windows 8.1 SDKs
    if '$(SupportWindows81SDKs)' == '' and '$(Support81SDKs)' != 'false' and '$(TargetPlatformIdentifier)' == 'UAP':
      SupportWindows81SDKs = true
    if '$(TargetPlatformIdentifierWindows81)' == '' and '$(SupportWindows81SDKs)' == 'true':
      TargetPlatformIdentifierWindows81 = Windows
    if '$(TargetPlatformVersionWindows81)' == '' and '$(SupportWindows81SDKs)' == 'true':
      TargetPlatformVersionWindows81 = 8.1
    // Desktop and phone SDKs often have the exact same identifiers, don't enable phone by default
    if '$(SupportWindowsPhone81SDKs)' == '' and '$(Support81SDKs)' != 'false' and '$(TargetPlatformIdentifier)' == 'UAP':
      SupportWindowsPhone81SDKs = false
    if '$(TargetPlatformIdentifierWindowsPhone81)' == '' and '$(SupportWindowsPhone81SDKs)' == 'true':
      TargetPlatformIdentifierWindowsPhone81 = WindowsPhoneApp
    if '$(TargetPlatformVersionWindowsPhone81)' == '' and '$(SupportWindowsPhone81SDKs)' == 'true':
      TargetPlatformVersionWindowsPhone81 = 8.1
  if '@(SDKReference)' != '':
    Target GetInstalledSDKLocations(
        DependsOnTargets="$(GetInstalledSDKLocationsDependsOn)",
        Returns="@(InstalledSDKLocations)")
      GetInstalledSDKLocations(
          SDKDirectoryRoots="$(SDKReferenceDirectoryRoot)",
          SDKExtensionDirectoryRoots="$(SDKExtensionDirectoryRoot)",
          SDKRegistryRoot="$(SDKReferenceRegistryRoot)",
          TargetPlatformIdentifier="$(TargetPlatformIdentifier)",
          TargetPlatformVersion="$(TargetPlatformVersion)")
        Output(ItemName="InstalledSDKLocations", TaskParameter="InstalledSDKs")
      // Also lookup 8.1 SDKs if requested
      if '$(SupportWindows81SDKs)' == 'true' and '$(TargetPlatformIdentifierWindows81)' != '' and '$(TargetPlatformVersionWindows81)' != '':
        GetInstalledSDKLocations(
            SDKDirectoryRoots="$(SDKReferenceDirectoryRoot)",
            SDKRegistryRoot="$(SDKReferenceRegistryRoot)",
            TargetPlatformIdentifier="$(TargetPlatformIdentifierWindows81)",
            TargetPlatformVersion="$(TargetPlatformVersionWindows81)",
            WarnWhenNoSDKsFound="false",
            SDKExtensionDirectoryRoots)
          Output(ItemName="InstalledSDKLocations", TaskParameter="InstalledSDKs")
      if '$(SupportWindowsPhone81SDKs)' == 'true' and '$(TargetPlatformIdentifierWindowsPhone81)' != '' and '$(TargetPlatformVersionWindowsPhone81)' != '':
        GetInstalledSDKLocations(
            SDKDirectoryRoots="$(SDKReferenceDirectoryRoot)",
            SDKRegistryRoot="$(SDKReferenceRegistryRoot)",
            TargetPlatformIdentifier="$(TargetPlatformIdentifierWindowsPhone81)",
            TargetPlatformVersion="$(TargetPlatformVersionWindowsPhone81)",
            WarnWhenNoSDKsFound="false",
            SDKExtensionDirectoryRoots)
          Output(ItemName="InstalledSDKLocations", TaskParameter="InstalledSDKs")
  // ============================================================
  //
  // ResolveSDKReferences
  //
  // Given a list of SDKReference items and a list of resolved winmd files which may contain metadata as to which sdk they came from
  // we need to find the sdk root folders on disk and populate a ResolvedSDKReference item which has the full path to the SDK ROOT
  // and the sdk identity as a piece of metadata.
  //
  // [IN]
  // @(SDKReference) - List of sdk references (the identity in the sdk manifest file).
  // @(ReferencePath) -List of resolved assemblies, we are interested in the ones which have IsWinMDFile set to true.
  //
  // [OUT]
  // @(ResolvedSDKReference) - Full path to the root of the SDK
  // ============================================================
  PropertyGroup
    ResolveSDKReferencesDependsOn = GetInstalledSDKLocations
  PropertyGroup
    if '$(TargetedSDKConfiguration)' == '' and '_$(Configuration)' == '_Debug':
      TargetedSDKConfiguration = Debug
    if '$(TargetedSDKConfiguration)' == '' and '_$(Configuration)' == '_Release':
      TargetedSDKConfiguration = Retail
    if '$(TargetedSDKConfiguration)' == '':
      TargetedSDKConfiguration = Retail
    if '$(TargetedSDKArchitecture)' == '':
      TargetedSDKArchitecture = $(ProcessorArchitecture)
    if '$(TargetedSDKArchitecture)' == '':
      TargetedSDKArchitecture = Neutral
  PropertyGroup
    if '$(ShouldMarkCertainSDKReferencesAsRuntimeOnly)' == '':
      ShouldMarkCertainSDKReferencesAsRuntimeOnly = true
  if '$(ShouldMarkCertainSDKReferencesAsRuntimeOnly)' == 'true':
    ItemGroup
      // Dependencies that are specified as runtime-only dependencies. Therefore the associated files are not used to build Appx package.
      // TODO: Do we need to do anything like this for the new SDK?
      if '$(TargetPlatformVersion)' == '8.1':
        RuntimeReferenceOnlySDKDependencies += "Microsoft.VCLibs, Version=11.0"
  Target ResolveSDKReferences(
      DependsOnTargets="$(ResolveSDKReferencesDependsOn)",
      Returns="@(ResolvedSDKReference)")
    if '@(SDKReference)'!='':
      ResolveSDKReference(
          ContinueOnError="$(ContinueOnError)",
          InstalledSDKs="@(InstalledSDKLocations)",
          LogResolutionErrorsAsWarnings="$(LogSDKReferenceResolutionErrorsAsWarnings)",
          Prefer32Bit="$(Prefer32Bit)",
          ProjectName="$(MSBuildProjectName)",
          References="@(Reference)",
          RuntimeReferenceOnlySDKDependencies="@(RuntimeReferenceOnlySDKDependencies)",
          SDKReferences="@(SDKReference)",
          TargetPlatformIdentifier="$(TargetPlatformIdentifier)",
          TargetPlatformVersion="$(TargetPlatformVersion)",
          TargetedSDKArchitecture="$(TargetedSDKArchitecture)",
          TargetedSDKConfiguration="$(TargetedSDKConfiguration)",
          WarnOnMissingPlatformVersion="$(SDKReferenceWarnOnMissingMaxPlatformVersion)")
        Output(ItemName="ResolvedSDKReference", TaskParameter="ResolvedSDKReferences")
  Target ResolveSDKReferencesDesignTime(
      DependsOnTargets="ResolveSDKReferences",
      Returns="@(ResolvedSDKReference)")
  // ============================================================
  //
  // FindInvalidProjectReferences
  //
  // Find project to project references with target platform version higher than the one used by the current project and
  // creates a list of invalid references to be unresolved. It issues a warning for each invalid reference.
  //
  // [IN]
  // $(TargetPlatformVersion) - Project's target platform version
  // @(_ProjectReferenceTargetPlatformMonikers) - List of monikers of all referenced projects gathered by the helper
  // target GetTargetPlatformMonikers.
  //
  // [OUT]
  // @(InvalidProjectReferences) - List of invalid project references
  //
  // ============================================================
  PropertyGroup
    FindInvalidProjectReferencesDependsOn = GetReferenceTargetPlatformMonikers
  if '$(FindInvalidProjectReferences)' == 'true':
    Target FindInvalidProjectReferences(DependsOnTargets="$(FindInvalidProjectReferencesDependsOn)")
      FindInvalidProjectReferences(
          ProjectReferences="@(_ProjectReferenceTargetPlatformMonikers)",
          TargetPlatformIdentifier="$(TargetPlatformIdentifier)",
          TargetPlatformVersion="$(TargetPlatformVersion)")
        Output(ItemName="InvalidProjectReferences", TaskParameter="InvalidReferences")
      ItemGroup
        _ResolvedProjectReferencePaths -= "@(InvalidProjectReferences)"
  Target GetReferenceTargetPlatformMonikers(DependsOnTargets="PrepareProjectReferences")
    MSBuild(
        BuildInParallel="$(BuildInParallel)",
        ContinueOnError="!$(BuildingProject)",
        Projects="@(_MSBuildProjectReferenceExistent)",
        Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform); %(_MSBuildProjectReferenceExistent.SetTargetFramework)",
        RemoveProperties="%(_MSBuildProjectReferenceExistent.GlobalPropertiesToRemove)$(_GlobalPropertiesToRemoveFromProjectReferences)",
        Targets="GetTargetPathWithTargetPlatformMoniker")
      Output(ItemName="_ProjectReferenceTargetPlatformMonikers", TaskParameter="TargetOutputs")
  if '$(IsGraphBuild)' == 'true' and '$(FindInvalidProjectReferences)' == 'true':
    ItemGroup
      ProjectReferenceTargets += "Build"(Targets="GetTargetPathWithTargetPlatformMoniker")
  // ============================================================
  //
  // ExpandSDKReferences
  //
  // After we have resolved the sdk refrence we need to make sure that we automatically include the references which are part of the SDK (both winmd and dll)
  // as part of the assemblies passed to the compiler.
  //
  // Project systems or project which do not want to reference all dlls or winmd files should override this target to do nothing.
  // ============================================================
  PropertyGroup
    ExpandSDKReferencesDependsOn = ResolveSDKReferences
    if '$(ExpandSDKAllowedReferenceExtensions)' == '':
      ExpandSDKAllowedReferenceExtensions =
        | .winmd;
        |       .dll
  Target ExpandSDKReferences(
      DependsOnTargets="$(ExpandSDKReferencesDependsOn)",
      Returns="@(ReferencesFromSDK)")
    if '@(ResolvedSDKReference)'!='':
      GetSDKReferenceFiles(
          CacheFileFolderPath="$(GetSDKReferenceFilesCacheFolder)",
          LogCacheFileExceptions="$(GetSDKReferenceFilesLogCacheFileExceptions)",
          LogRedistConflictBetweenSDKsAsWarning="$(GetSDKReferenceFilesLogRedistConflictsBetweenSDKsAsWarning)",
          LogRedistConflictWithinSDKAsWarning="$(GetSDKReferenceFilesLogRedistConflictsWithinSDKAsWarning)",
          LogRedistFilesList="$(GetSDKReferenceFilesLogRedistFilesList)",
          LogReferenceConflictBetweenSDKsAsWarning="$(GetSDKReferenceFilesLogReferenceConflictsBetweenSDKsAsWarning)",
          LogReferenceConflictWithinSDKAsWarning="$(GetSDKReferenceFilesLogReferenceConflictsWithinSDKAsWarning)",
          LogReferencesList="$(GetSDKReferenceFilesLogReferencesList)",
          ReferenceExtensions="$(ExpandSDKAllowedReferenceExtensions)",
          ResolvedSDKReferences="@(ResolvedSDKReference)",
          TargetPlatformIdentifier="$(TargetPlatformIdentifier)",
          TargetPlatformVersion="$(TargetPlatformVersion)",
          TargetSDKIdentifier="$(SDKIdentifier)",
          TargetSDKVersion="$(SDKVersion)")
        Output(ItemName="ReferencePath", TaskParameter="References")
        Output(ItemName="ReferencesFromSDK", TaskParameter="References")
        Output(ItemName="_ResolveAssemblyReferenceResolvedFiles", TaskParameter="References")
        Output(ItemName="ReferenceCopyLocalPaths", TaskParameter="CopyLocalFiles")
        Output(ItemName="ResolvedRedistFiles", TaskParameter="RedistFiles")
  // ============================================================
  //
  // ExportWindowsMDFile
  //
  // When a project is generating a a winmd file through c# or vb, ect the compiler will create a WinMDModule file. This file needs to be run
  // through the winmdexp tool in order to generate the resulting WinMD file.
  //
  // ===========================================================
  if '$(ExportWinMDFile)' == 'true':
    Target ExportWindowsMDFile(
        DependsOnTargets="Compile",
        Inputs="@(IntermediateAssembly);@(DocFileItem);@(_DebugSymbolsIntermediatePath);@(ReferencePathWithRefAssemblies);$(MSBuildAllProjects)",
        Outputs="$(_IntermediateWindowsMetadataPath);$(WinMDExpOutputPdb);$(WinMDOutputDocumentationFile)")
      PropertyGroup
        // Will be copied by the "copy WinMD artifacts" step instead
        CopyBuildOutputToOutputDirectory = false
        CopyOutputSymbolsToOutputDirectory = false
        CopyDocumentationFileToOutputDirectory = false
        if '$(WinMdExpToolPath)' == '':
          WinMdExpToolPath = $(TargetFrameworkSDKToolsDirectory)
        if '$(WinMdExpUTF8Ouput)' == '':
          WinMdExpUTF8Ouput = true
      WinMDExp(
          AssemblyUnificationPolicy="$(WinMDExpAssemblyUnificationPolicy)",
          DisabledWarnings="$(WinMdExpNoWarn)",
          EnvironmentVariables="$(WinMDExpEnvironment)",
          InputDocumentationFile="@(DocFileItem)",
          InputPDBFile="@(_DebugSymbolsIntermediatePath)",
          OutputDocumentationFile="$(WinMDOutputDocumentationFile)",
          OutputPDBFile="$(WinMDExpOutputPdb)",
          OutputWindowsMetadataFile="$(_IntermediateWindowsMetadataPath)",
          References="@(ReferencePathWithRefAssemblies)",
          SdkToolsPath="$(WinMdExpToolPath)",
          TreatWarningsAsErrors="$(TreatWarningsAsErrors)",
          UTF8Output="$(WinMdExpUTF8Ouput)",
          WinMDModule="@(IntermediateAssembly)")
        Output(ItemName="FileWrites", TaskParameter="OutputWindowsMetadataFile")
      ItemGroup
        WinMDExpArtifacts += "$(_IntermediateWindowsMetadataPath)"
        WinMDExpArtifacts += "$(WinMDOutputDocumentationFile)"
        WinMDExpArtifacts += "$(WinMDExpOutputPdb)"
        FileWrites += "$(WinMDOutputDocumentationFile);$(WinMDExpOutputPdb)"
  Target ResolveAssemblyReferencesDesignTime(
      DependsOnTargets=[
        ResolveProjectReferences
        ResolveAssemblyReferences
      ],
      Returns="@(_ReferencesFromRAR)")
    // We need to do this here because we only want references which have been passed into rar but are not project to project references.
    ItemGroup
      _ReferencesFromRAR += "@(ReferencePath->WithMetadataValue('ReferenceSourceTarget', 'ResolveAssemblyReference'))"
  PropertyGroup
    if '$(ProjectDesignTimeAssemblyResolutionSearchPaths)' == '':
      ProjectDesignTimeAssemblyResolutionSearchPaths =
        | {CandidateAssemblyFiles};
        |       $(ReferencePath);
        |       {HintPathFromItem};
        |       {TargetFrameworkDirectory};
        |       {Registry:$(FrameworkRegistryBase),$(TargetFrameworkVersion),$(AssemblyFoldersSuffix)$(AssemblyFoldersExConditions)};
        |       {RawFileName};
        |       $(TargetDir)
  // ==============================================================
  //
  // DesignTimeResolveAssemblyReferences
  //
  // Given the list of assemblies, resolve their reference paths.
  // This target is called by Visual Studio at run time in order to filter references
  // according to the targeted framework.
  //
  // [IN]
  // @(DesignTimeReference) - List of assembly references as simple/fusion names.
  //
  // [OUT]
  // @(ReferencePath) - Paths to resolved primary files.
  //
  // ==============================================================
  PropertyGroup
    DesignTimeResolveAssemblyReferencesDependsOn =
      | GetFrameworkPaths;
      |       GetReferenceAssemblyPaths;
      |       ResolveReferences
  if '$(DesignTimeReference)'!='':
    Target DesignTimeResolveAssemblyReferences(
        DependsOnTargets="$(DesignTimeResolveAssemblyReferencesDependsOn)")
      ItemGroup
        _DesignTimeReferenceInstalledAssemblyDirectory += "$(TargetFrameworkDirectory)"
      PropertyGroup
        if '$(DisableRarCache)'!='true':
          DesignTimeResolveAssemblyReferencesStateFile = $(IntermediateOutputPath)$(MSBuildProjectFile)DesignTimeResolveAssemblyReferences.cache
      PropertyGroup
        if '$(DesignTimeAssemblySearchPaths)' == '':
          DesignTimeAssemblySearchPaths =
            | {CandidateAssemblyFiles};
            |         $(ReferencePath);
            |         {HintPathFromItem};
            |         {TargetFrameworkDirectory};
            |         {Registry:$(FrameworkRegistryBase),$(TargetFrameworkVersion),$(AssemblyFoldersSuffix)$(AssemblyFoldersExConditions)};
            |         {RawFileName};
            |         $(OutDir)
      PropertyGroup
        if '$(DesignTimeFindDependencies)' == '':
          DesignTimeFindDependencies = false
        if '$(DesignTimeIgnoreVersionForFrameworkReferences)' == '':
          DesignTimeIgnoreVersionForFrameworkReferences = false
        if '$(DesignTimeFindSatellites)' == '':
          DesignTimeFindSatellites = false
        if '$(DesignTimeFindSerializationAssemblies)' == '':
          DesignTimeFindSerializationAssemblies = false
        if '$(DesignTimeFindRelatedFiles)' == '':
          DesignTimeFindRelatedFiles = false
        if '$(DesignTimeSilentResolution)' == '' and '$(TraceDesignTime)' != 'true':
          DesignTimeSilentResolution = true
        if '$(DesignTimeAutoUnify)' == '':
          DesignTimeAutoUnify = false
      ItemGroup
        _DesignTimeReferenceAssemblies += "$(DesignTimeReference)"
      ItemGroup
        _RARResolvedReferencePath += "@(ReferencePath)"
        ReferencePath -= "@(ReferencePath)"
      ResolveAssemblyReference(
          AllowedAssemblyExtensions="$(AllowedReferenceAssemblyFileExtensions)",
          Assemblies="@(_DesignTimeReferenceAssemblies)",
          AutoUnify="$(DesignTimeAutoUnify)",
          CandidateAssemblyFiles="@(Content);@(None);@(_RARResolvedReferencePath)",
          FindDependencies="$(DesignTimeFindDependencies)",
          FindRelatedFiles="$(DesignTimeFindRelatedFiles)",
          FindSatellites="$(DesignTimeFindSatellites)",
          FindSerializationAssemblies="$(DesignTimeFindSerializationAssemblies)",
          FullFrameworkAssemblyTables="@(FullFrameworkAssemblyTables)",
          FullFrameworkFolders="$(_FullFrameworkReferenceAssemblyPaths)",
          FullTargetFrameworkSubsetNames="$(FullReferenceAssemblyNames)",
          IgnoreDefaultInstalledAssemblySubsetTables="$(IgnoreInstalledAssemblySubsetTables)",
          IgnoreTargetFrameworkAttributeVersionMismatch="$(DesignTimeIgnoreTargetFrameworkAttributeVersionMismatch)",
          IgnoreVersionForFrameworkReferences="$(DesignTimeIgnoreVersionForFrameworkReferences)",
          InstalledAssemblySubsetTables="@(InstalledAssemblySubsetTables)",
          ProfileName="$(TargetFrameworkProfile)",
          ResolvedSDKReferences="@(ResolvedSDKReference)",
          SearchPaths="$(DesignTimeAssemblySearchPaths)",
          Silent="$(DesignTimeSilentResolution)",
          StateFile="$(DesignTimeResolveAssemblyReferencesStateFile)",
          TargetFrameworkDirectories="@(_DesignTimeReferenceInstalledAssemblyDirectory)",
          TargetFrameworkMoniker="$(TargetFrameworkMoniker)",
          TargetFrameworkMonikerDisplayName="$(TargetFrameworkMonikerDisplayName)",
          TargetFrameworkSubsets="@(_ReferenceInstalledAssemblySubsets)",
          TargetFrameworkVersion="$(TargetFrameworkVersion)",
          TargetProcessorArchitecture="$(ProcessorArchitecture)",
          TargetedRuntimeVersion="$(TargetedRuntimeVersion)")
        Output(ItemName="DesignTimeReferencePath", TaskParameter="ResolvedFiles")
        Output(ItemName="FileWrites", TaskParameter="FilesWritten")
  // ============================================================
  // ResolveComReferences
  //
  // Resolve COM references
  //
  // [IN]
  // @(COMReference) - The list of COM references
  // $(InteropOutputPath) - The output directory in which to generate wrapper assemblies
  // When $(InteropOutputPath) is not set, then it defaults to $(IntermediateOutputPath).
  //
  // [OUT]
  // @(ReferencePath) - Paths to referenced wrappers.
  //
  // If ResolveComReferences is invoked from the IDE, PrepareForBuild may need to run to create directories.
  // ============================================================
  PropertyGroup
    if '$(ComReferenceExecuteAsTool)'=='':
      ComReferenceExecuteAsTool = false
  if '@(COMReference)'!='' or '@(COMFileReference)'!='':
    Target ResolveComReferences(
        DependsOnTargets=[
          PrepareForBuild
          ResolveKeySource
          ResolveAssemblyReferences
        ],
        Returns="@(ReferencePath)")
      if '$(InteropOutputPath)' == '':
        PropertyGroup
          InteropOutputPath = $(IntermediateOutputPath)
      MakeDir(Directories="$(InteropOutputPath)")
      // Note: This task should not be batched, since it relies on having all the COM references fed into it at once.
      PropertyGroup
        if '$(ResolveComReferenceMSBuildArchitecture)' == '':
          ResolveComReferenceMSBuildArchitecture = $(PlatformTargetAsMSBuildArchitecture)
        if '$(ResolveComReferenceToolPath)' == '':
          ResolveComReferenceToolPath = $(TargetFrameworkSDKToolsDirectory)
        if '$(ResolveComReferenceSilent)' == '':
          ResolveComReferenceSilent = false
      ResolveComReference(
          ContinueOnError="$(ContinueOnError)",
          DelaySign="$(DelaySign)",
          EnvironmentVariables="$(ResolveComReferenceEnvironment)",
          ExecuteAsTool="$(ComReferenceExecuteAsTool)",
          IncludeVersionInInteropName="$(IncludeVersionInInteropName)",
          KeyContainer="$(KeyContainerName)",
          KeyFile="$(KeyOriginatorFile)",
          MSBuildArchitecture="$(ResolveComReferenceMSBuildArchitecture)",
          NoClassMembers="$(ComReferenceNoClassMembers)",
          ResolvedAssemblyReferences="@(ReferencePath)",
          SdkToolsPath="$(ResolveComReferenceToolPath)",
          Silent="$(ResolveComReferenceSilent)",
          StateFile="@(_ResolveComReferenceCache)",
          TargetFrameworkVersion="$(TargetFrameworkVersion)",
          TargetProcessorArchitecture="$(ProcessorArchitecture)",
          TypeLibFiles="@(COMFileReference)",
          TypeLibNames="@(COMReference)",
          WrapperOutputDirectory="$(InteropOutputPath)")
        Output(ItemName="ReferencePath", TaskParameter="ResolvedFiles")
        Output(ItemName="ComReferenceWrappers", TaskParameter="ResolvedFiles")
        Output(ItemName="FileWrites", TaskParameter="ResolvedFiles")
        // This output list only includes items with Isolated attribute set to True.  It's done by the task itself.
        Output(ItemName="ResolvedIsolatedComModules", TaskParameter="ResolvedModules")
      ItemGroup
        FileWrites += "@(_ResolveComReferenceCache)"
        if '%(ComReferenceWrappers.CopyLocal)'!='false':
          ReferenceComWrappersToCopyLocal += "@(ComReferenceWrappers)"
  // ============================================================
  // _GetAssembliesMetadata
  //
  // Resolve Assembly attributes for assemblies
  // The ResolveComReferences dependency is needed for defining COM-referenced wrappers only,
  // but this target handles all the assembly references from ResolveAssemblyReferences
  // This target is needed by the Visual Studio legacy project system during design time build only
  //
  // [IN]
  // @(ReferencePath) - Paths to COM-referenced wrappers and other types of assembly references.
  //
  // [OUT]
  // @(AssembliesMetadata) - Resolved assemblies attributes.
  // ============================================================
  if '@(ReferencePath)'!=''and '$(DesignTimeBuild)' == 'true':
    Target _GetAssembliesMetadata(
        DependsOnTargets="ResolveComReferences",
        Returns="@(_AssembliesMetadata)")
      GetAssembliesMetadata(AssemblyPaths="@(ReferencePath)", ContinueOnError="$(ContinueOnError)")
        Output(ItemName="_AssembliesMetadata", TaskParameter="AssembliesMetadata")
  Target ResolveComReferencesDesignTime(
      DependsOnTargets="ResolveComReferences",
      Returns="@(ComReferenceWrappers)")
  // ============================================================
  // ResolveFrameworkReferences
  //
  // Overrridden by Microsoft.NET.Sdk to return
  // ResolvedFrameworkReference items in order to populate the
  // Frameworks node of the Solution Explorer in the IDE.
  Target ResolveFrameworkReferences
  // ***********************************************************************************************
  // ***********************************************************************************************
  // PrepareResources Section
  // ***********************************************************************************************
  // ***********************************************************************************************
  // ============================================================
  // PrepareResources
  //
  // Prepare resources for the Compile step.
  // ============================================================
  PropertyGroup
    PrepareResourcesDependsOn =
      | $(PrepareResourcesDependsOn);
      |       PrepareResourceNames;
      |       ResGen;
      |       CompileLicxFiles
  Target PrepareResources(DependsOnTargets="$(PrepareResourcesDependsOn)")
  // ============================================================
  // PrepareResourceNames
  //
  // Prepare the names of resource files.
  // ============================================================
  PropertyGroup
    PrepareResourceNamesDependsOn =
      | AssignTargetPaths;
      |       SplitResourcesByCulture;
      |       CreateManifestResourceNames;
      |       CreateCustomManifestResourceNames
  Target PrepareResourceNames(DependsOnTargets="$(PrepareResourceNamesDependsOn)")
  // ============================================================
  // AssignTargetPaths
  //
  // This target creates <TargetPath> tags for items. <TargetPath> is a relative folder plus filename
  // for the destination of this item.
  // ============================================================
  PropertyGroup
    AssignTargetPathsDependsOn
  Target AssignTargetPaths(DependsOnTargets="$(AssignTargetPathsDependsOn)")
    ItemGroup
      _Temporary -= "@(_Temporary)"
    // AssignTargetPath generates TargetPath metadata that is consumed by CreateManifestResourceNames target for manifest name generation
    AssignTargetPath(Files="@(EmbeddedResource)", RootFolder="$(MSBuildProjectDirectory)")
      Output(ItemName="_Temporary", TaskParameter="AssignedFiles")
    ItemGroup
      // Replace items in EmbeddedResource with the items emitted by the AssignTargetPath task that have the TargetPath metadata
      EmbeddedResource -= "@(_Temporary)"
      EmbeddedResource += "@(_Temporary)"
      _Temporary -= "@(_Temporary)"
    AssignTargetPath(Files="@(Content)", RootFolder="$(MSBuildProjectDirectory)")
      Output(ItemName="ContentWithTargetPath", TaskParameter="AssignedFiles")
    AssignTargetPath(Files="@(None)", RootFolder="$(MSBuildProjectDirectory)")
      Output(ItemName="_NoneWithTargetPath", TaskParameter="AssignedFiles")
    AssignTargetPath(Files="@(BaseApplicationManifest)", RootFolder="$(MSBuildProjectDirectory)")
      Output(ItemName="_DeploymentBaseManifestWithTargetPath", TaskParameter="AssignedFiles")
    if '@(_DeploymentBaseManifestWithTargetPath)'=='' and '%(None.Extension)'=='.manifest':
      AssignTargetPath(Files="@(None)", RootFolder="$(MSBuildProjectDirectory)")
        Output(ItemName="_DeploymentBaseManifestWithTargetPath", TaskParameter="AssignedFiles")
  // ============================================================
  // GetItemTargetPaths
  //
  // This target returns all items that have TargetPath metadata assigned by the AssignTargetPaths target.
  // ============================================================
  Target GetItemTargetPaths(
      DependsOnTargets="AssignTargetPaths",
      Returns="
      @(EmbeddedResource);
      @(ContentWithTargetPath);
      @(_NoneWithTargetPath);
      @(_DeploymentBaseManifestWithTargetPath);
      ")
  // ============================================================
  // SplitResourcesByCulture
  //
  // Split EmbeddedResource items into five lists based on whether
  // they are resx files, licx files or other resources and whether they should be localized. Also adds Type and Culture
  // metadata. Type indicates whether the resource is "Resx" or "Non-Resx".
  //
  // [IN]/[OUT]
  // @(EmbeddedResource) - The raw list of resources.
  //
  // [OUT]
  // @(_LicxFile) - The EmbeddedResource items with extension equal to '.licx'.
  // ============================================================
  Target SplitResourcesByCulture(DependsOnTargets="AssignTargetPaths")
    PropertyGroup
      if '$(RespectAlreadyAssignedItemCulture)' == '':
        RespectAlreadyAssignedItemCulture = false
      if '$(WarnOnCultureOverwritten)' == '':
        WarnOnCultureOverwritten = false
    if '@(ResxWithNoCulture)'!='':
      MSBuildInternalMessage(
          FormatArguments="MSB9000;ResxWithNoCulture",
          ResourceName="CommonSdk.SplitResourcesByCultureEmbeddedResourceMessage",
          Severity="Warning")
    if '@(ResxWithCulture)'!='':
      MSBuildInternalMessage(
          FormatArguments="MSB9001;ResxWithCulture",
          ResourceName="CommonSdk.SplitResourcesByCultureEmbeddedResourceMessage",
          Severity="Warning")
    if '@(NonResxWithCulture)'!='':
      MSBuildInternalMessage(
          FormatArguments="MSB9002;NonResxWithCulture",
          ResourceName="CommonSdk.SplitResourcesByCultureEmbeddedResourceMessage",
          Severity="Warning")
    if '@(NonResxWithNoCulture)'!='':
      MSBuildInternalMessage(
          FormatArguments="MSB9003;NonResxWithNoCulture",
          ResourceName="CommonSdk.SplitResourcesByCultureEmbeddedResourceMessage",
          Severity="Warning")
    ItemGroup
      if '%(Extension)'=='.licx':
        _LicxFile += "@(EmbeddedResource)"
      // CONSUMED FOR COMPATIBILITY REASONS ONLY. EMIT EMBEDDEDRESOURCE INSTEAD
      EmbeddedResource += "@(ResxWithNoCulture);@(ResxWithCulture)"
        Type = Resx
      EmbeddedResource += "@(NonResxWithCulture);@(NonResxWithNoCulture)"
        Type = Non-Resx
    if '%(Extension)'!='.licx':
      AssignCulture(
          Files="@(EmbeddedResource)",
          RespectAlreadyAssignedItemCulture="$(RespectAlreadyAssignedItemCulture)",
          WarnOnCultureOverwritten="$(WarnOnCultureOverwritten)")
        // Create the list of culture resx and embedded resource files
        Output(ItemName="_MixedResourceWithCulture", TaskParameter="AssignedFilesWithCulture")
        // Create the list of non-culture resx and embedded resource files
        Output(ItemName="_MixedResourceWithNoCulture", TaskParameter="AssignedFilesWithNoCulture")
    ItemGroup
      // Remove EmbeddedResource items that we have processed already
      // i.e. either Licx, or resources that don't have culture info
      EmbeddedResource -= "@(_MixedResourceWithCulture)"
      EmbeddedResource -= "@(_MixedResourceWithNoCulture)"
      EmbeddedResource -= "@(_LicxFile)"
      // Add back everything except Licx, so that we have culture info
      if '%(Extension)'=='.resx' or '%(Extension)'=='.restext':
        EmbeddedResource += "@(_MixedResourceWithNoCulture);@(_MixedResourceWithCulture)"
          if '%(_MixedResourceWithNoCulture.Type)'=='' and '%(_MixedResourceWithCulture.Type)'=='':
            Type = Resx
      if '%(Extension)'!='.resx' and '%(Extension)'!='.restext':
        EmbeddedResource += "@(_MixedResourceWithNoCulture);@(_MixedResourceWithCulture)"
          if '%(_MixedResourceWithNoCulture.Type)'=='' and '%(_MixedResourceWithCulture.Type)'=='':
            Type = Non-Resx
      // EMITTED FOR COMPATIBILITY REASONS ONLY. CONSUME EMBEDDEDRESOURCE INSTEAD
      ResxWithNoCulture -= "@(ResxWithNoCulture)"
      NonResxWithNoCulture -= "@(NonResxWithNoCulture)"
      ResxWithCulture -= "@(ResxWithCulture)"
      NonResxWithCulture -= "@(NonResxWithCulture)"
      if '%(WithCulture)'=='false' and ('%(Extension)'=='.resx' or '%(Extension)'=='.restext'):
        ResxWithNoCulture += "@(_MixedResourceWithNoCulture)"
      if '%(WithCulture)'=='false' and ('%(Extension)'!='.resx' and '%(Extension)'!='.restext'):
        NonResxWithNoCulture += "@(_MixedResourceWithNoCulture)"
      if '%(WithCulture)'=='true' and ('%(Extension)'=='.resx' or '%(Extension)'=='.restext'):
        ResxWithCulture += "@(_MixedResourceWithCulture)"
      if '%(WithCulture)'=='true' and ('%(Extension)'!='.resx' and '%(Extension)'!='.restext'):
        NonResxWithCulture += "@(_MixedResourceWithCulture)"
      // Clean up temporary lists
      _MixedResourceWithNoCulture -= "@(_MixedResourceWithNoCulture)"
      _MixedResourceWithCulture -= "@(_MixedResourceWithCulture)"
  // =======================================================================
  // CreateCustomManifestResourceNames
  //
  // Allows custom manifest resource name generation tasks to plug
  // into the build process
  // =======================================================================
  PropertyGroup
    CreateCustomManifestResourceNamesDependsOn
  Target CreateCustomManifestResourceNames(
      DependsOnTargets="$(CreateCustomManifestResourceNamesDependsOn)")
  // ============================================================
  // ResGen
  //
  // Run GenerateResource on the given resx files.
  //
  // ============================================================
  PropertyGroup
    ResGenDependsOn = ResolveAssemblyReferences;SplitResourcesByCulture;BeforeResGen;CoreResGen;AfterResGen
    CoreResGenDependsOn = FindReferenceAssembliesForReferences
    if '$(UseSourcePath)'=='':
      UseSourcePath = true
    if '$(ResGenExecuteAsTool)'=='':
      ResGenExecuteAsTool = false
  Target ResGen(DependsOnTargets="$(ResGenDependsOn)")
  // ============================================================
  // BeforeResGen
  //
  // Redefine this target in your project in order to run tasks just before Resgen.
  // ============================================================
  Target BeforeResGen
  // ============================================================
  // AfterResGen
  //
  // Redefine this target in your project in order to run tasks just after Resgen.
  // ============================================================
  Target AfterResGen
  // ============================================================
  // CoreResGen
  // ============================================================
  Target CoreResGen(DependsOnTargets="$(CoreResGenDependsOn)")
    ItemGroup
      _Temporary -= "@(_Temporary)"
    PropertyGroup
      if '$(GenerateResourceMSBuildArchitecture)' == '':
        GenerateResourceMSBuildArchitecture = $(PlatformTargetAsMSBuildArchitecture)
      if '$(ResgenToolPath)' == '':
        ResgenToolPath = $(TargetFrameworkSDKToolsDirectory)
    if '$(TargetFrameworkAsMSBuildRuntime)' != '' and '$(GenerateResourceMSBuildArchitecture)' != '':
      PropertyGroup
        // In the general case, we want to fail to run the task if the task host it's requesting doesn't exist, because we'd rather let the
        // user know there's something wrong than just silently generate something that's probably not quite right. However, in a few
        // circumstances, there are tasks that are already aware of runtime / bitness concerns, in which case even if we go ahead and run
        // the more recent version of the task, it should be able to generate something correct.  GenerateResource is one such task, so
        // we check for the existence of the targeted task host so that we can use it preferentially, but if it can't be found, we'll fall
        // back to the current task since it's still mostly correct.
        //
        // In particular, we need to do this because otherwise people with Dev10 on a machine that they upgrade to Win8 will be broken:
        // they'll have ResGen from the 7.0A SDK installed, so launching ResGen will still work, but the CLR2 task host is only installed by
        // the 8.0A SDK, which they won't have installed, and thus without this fallback mechanism, their projects targeting v3.5 will
        // suddenly start failing to build.
        if '$(GenerateResourceMSBuildRuntime)' == '' and $([MSBuild]::DoesTaskHostExist(`$(TargetFrameworkAsMSBuildRuntime)`, `$(GenerateResourceMSBuildArchitecture)`)):
          GenerateResourceMSBuildRuntime = $(TargetFrameworkAsMSBuildRuntime)
        // If the targeted runtime doesn't exist, fall back to current
        if '$(GenerateResourceMSBuildRuntime)' == '':
          GenerateResourceMSBuildRuntime = CurrentRuntime
    // 4.0 task has some new parameters that we want to make use of if we're targeting 4.0
    if '%(EmbeddedResource.Type)' == 'Resx' and '%(EmbeddedResource.GenerateResource)' != 'false' and '$(GenerateResourceMSBuildRuntime)' != 'CLR2':
      GenerateResource(
          AdditionalInputs="$(MSBuildAllProjects)",
          EnvironmentVariables="$(ResGenEnvironment)",
          ExecuteAsTool="$(ResGenExecuteAsTool)",
          MSBuildArchitecture="$(GenerateResourceMSBuildArchitecture)",
          MSBuildRuntime="$(GenerateResourceMSBuildRuntime)",
          NeverLockTypeAssemblies="$(GenerateResourceNeverLockTypeAssemblies)",
          OutputResources="@(EmbeddedResource->'$(IntermediateOutputPath)%(ManifestResourceName).resources')",
          PublicClass="%(EmbeddedResource.PublicClass)",
          References="@(ReferencePathWithRefAssemblies)",
          SdkToolsPath="$(ResgenToolPath)",
          Sources="@(EmbeddedResource)",
          StateFile="$(IntermediateOutputPath)$(MSBuildProjectFile).GenerateResource.cache",
          StronglyTypedClassName="%(EmbeddedResource.StronglyTypedClassName)",
          StronglyTypedFileName="%(EmbeddedResource.StronglyTypedFileName)",
          StronglyTypedLanguage="%(EmbeddedResource.StronglyTypedLanguage)",
          StronglyTypedManifestPrefix="%(EmbeddedResource.StronglyTypedManifestPrefix)",
          StronglyTypedNamespace="%(EmbeddedResource.StronglyTypedNamespace)",
          UsePreserializedResources="$(GenerateResourceUsePreserializedResources)",
          UseSourcePath="$(UseSourcePath)",
          WarnOnBinaryFormatterUse="$(GenerateResourceWarnOnBinaryFormatterUse)")
        Output(ItemName="FileWrites", TaskParameter="FilesWritten")
        Output(ItemName="Compile", TaskParameter="StronglyTypedFileName")
        // Gather Sources as an output since it will contain OutputResource metadata indicating the final output resource that it was compiled into
        Output(ItemName="_Temporary", TaskParameter="Sources")
    // But we can't use those parameters if we're targeting 3.5, since we're using the 3.5 task
    if '%(EmbeddedResource.Type)' == 'Resx' and '%(EmbeddedResource.GenerateResource)' != 'false' and '$(GenerateResourceMSBuildRuntime)' == 'CLR2':
      GenerateResource(
          AdditionalInputs="$(MSBuildAllProjects)",
          MSBuildArchitecture="$(GenerateResourceMSBuildArchitecture)",
          MSBuildRuntime="$(GenerateResourceMSBuildRuntime)",
          NeverLockTypeAssemblies="$(GenerateResourceNeverLockTypeAssemblies)",
          OutputResources="@(EmbeddedResource->'$(IntermediateOutputPath)%(ManifestResourceName).resources')",
          PublicClass="%(EmbeddedResource.PublicClass)",
          References="@(ReferencePath)",
          Sources="@(EmbeddedResource)",
          StateFile="$(IntermediateOutputPath)$(MSBuildProjectFile).GenerateResource.cache",
          StronglyTypedClassName="%(EmbeddedResource.StronglyTypedClassName)",
          StronglyTypedFileName="%(EmbeddedResource.StronglyTypedFileName)",
          StronglyTypedLanguage="%(EmbeddedResource.StronglyTypedLanguage)",
          StronglyTypedManifestPrefix="%(EmbeddedResource.StronglyTypedManifestPrefix)",
          StronglyTypedNamespace="%(EmbeddedResource.StronglyTypedNamespace)",
          UseSourcePath="$(UseSourcePath)")
        Output(ItemName="FileWrites", TaskParameter="FilesWritten")
        Output(ItemName="Compile", TaskParameter="StronglyTypedFileName")
        // Gather Sources as an output since it will contain OutputResource metadata indicating the final output resource that it was compiled into
        Output(ItemName="_Temporary", TaskParameter="Sources")
    ItemGroup
      EmbeddedResource -= "@(_Temporary)"
      // Add back the Sources list (with OutputResource metadata) that we output from GenerateResource into EmbeddedResource
      EmbeddedResource += "@(_Temporary)"
      _Temporary -= "@(_Temporary)"
      // EMITTED FOR COMPATIBILITY REASONS ONLY. CONSUME EMBEDDEDRESOURCE INSTEAD
      if '%(EmbeddedResource.WithCulture)'=='false' and '%(EmbeddedResource.Type)' == 'Resx':
        ManifestResourceWithNoCulture += "@(EmbeddedResource->'%(OutputResource)')"
          EmittedForCompatibilityOnly = true
      if '%(EmbeddedResource.WithCulture)'=='false' and '%(EmbeddedResource.Type)' == 'Non-Resx':
        ManifestNonResxWithNoCultureOnDisk += "@(EmbeddedResource)"
          EmittedForCompatibilityOnly = true
      // EMITTED FOR COMPATIBILITY REASONS ONLY. CONSUME EMBEDDEDRESOURCE INSTEAD
      if '%(EmbeddedResource.WithCulture)'=='true' and '%(EmbeddedResource.Type)' == 'Resx':
        ManifestResourceWithCulture += "@(EmbeddedResource->'%(OutputResource)')"
          EmittedForCompatibilityOnly = true
      if '%(EmbeddedResource.WithCulture)'=='true' and '%(EmbeddedResource.Type)' == 'Non-Resx':
        ManifestNonResxWithCultureOnDisk += "@(EmbeddedResource)"
          EmittedForCompatibilityOnly = true
  // ============================================================
  // CompileLicxFiles
  //
  // Compile .licx files (containing information about licensed controls used by the application) into .licenses files.
  //
  // [IN]
  // @(_LicxFile) - The list of .licx files in the project (usually there will be just one)
  //
  // [OUT]
  // @(CompiledLicenseFile) - The list of compiled .licenses files (there will be just one)
  // ============================================================
  PropertyGroup
    CompileLicxFilesDependsOn
  if '@(_LicxFile)'!='':
    Target CompileLicxFiles(
        DependsOnTargets="$(CompileLicxFilesDependsOn)",
        Inputs="$(MSBuildAllProjects);@(_LicxFile);@(ReferencePathWithRefAssemblies);@(ReferenceDependencyPaths)",
        Outputs="$(IntermediateOutputPath)$(TargetFileName).licenses")
      PropertyGroup
        if '$(LCMSBuildArchitecture)' == '':
          LCMSBuildArchitecture = $(PlatformTargetAsMSBuildArchitecture)
      LC(
          EnvironmentVariables="$(LCEnvironment)",
          LicenseTarget="$(TargetFileName)",
          MSBuildArchitecture="$(LCMSBuildArchitecture)",
          NoLogo="$(NoLogo)",
          OutputDirectory="$(IntermediateOutputPath)",
          OutputLicense="$(IntermediateOutputPath)$(TargetFileName).licenses",
          ReferencedAssemblies="@(ReferencePathWithRefAssemblies);@(ReferenceDependencyPaths)",
          SdkToolsPath="$(TargetFrameworkSDKToolsDirectory)",
          Sources="@(_LicxFile)",
          TargetFrameworkVersion="$(TargetFrameworkVersion)",
          ToolPath="$(LCToolPath)")
        Output(ItemName="CompiledLicenseFile", TaskParameter="OutputLicense")
        Output(ItemName="FileWrites", TaskParameter="OutputLicense")
  // ***********************************************************************************************
  // ***********************************************************************************************
  // ResolveKeySource Section
  // ***********************************************************************************************
  // ***********************************************************************************************
  // ============================================================
  // ResolveKeySource
  //
  // Resolve the strong name key used to sign the assembly as well as the certificate used to
  // sign the ClickOnce manifests.
  //
  // [IN]
  // $(AssemblyOriginatorKeyFile)     - The file used to sign the assembly (.snk or .pfx)
  // $(ManifestCertificateThumbprint) - The thumbprint used to locate the certificate in the
  // user's certificate store.
  // $(ManifestKeyFile)               - The key file that contains the certificate in case the
  // certificate is not in the user's store.
  //
  // [OUT]
  // $(ResolvedAssemblyKeyFile)        - Key used to sign the assembly
  // $(_DeploymentResolvedManifestCertificateThumbprint) - Certificate used to sign the manifests
  // ============================================================
  if $(SignManifests) == 'true' or $(SignAssembly) == 'true':
    Target ResolveKeySource
      ResolveKeySource(
          CertificateFile="$(ManifestKeyFile)",
          CertificateThumbprint="$(ManifestCertificateThumbprint)",
          ContinueOnError="!$(BuildingProject)",
          KeyFile="$(AssemblyOriginatorKeyFile)",
          ShowImportDialogDespitePreviousFailures="$(BuildingProject)",
          SuppressAutoClosePasswordPrompt="$(BuildingInsideVisualStudio)")
        if '$(SignAssembly)' == 'true':
          Output(PropertyName="KeyOriginatorFile", TaskParameter="ResolvedKeyFile")
        if '$(SignAssembly)' == 'true':
          Output(PropertyName="KeyContainerName", TaskParameter="ResolvedKeyContainer")
        if '$(SignManifests)' == 'true':
          Output(
              PropertyName="_DeploymentResolvedManifestCertificateThumbprint",
              TaskParameter="ResolvedThumbprint")
  // ***********************************************************************************************
  // ***********************************************************************************************
  // Compile Section
  // ***********************************************************************************************
  // ***********************************************************************************************
  // ============================================================
  // Compile
  // ============================================================
  PropertyGroup
    CompileDependsOn =
      | ResolveReferences;
      |       ResolveKeySource;
      |       SetWin32ManifestProperties;
      |       _SetPreferNativeArm64Win32ManifestProperties;
      |       FindReferenceAssembliesForReferences;
      |       _GenerateCompileInputs;
      |       BeforeCompile;
      |       _TimeStampBeforeCompile;
      |       _GenerateCompileDependencyCache;
      |       CoreCompile;
      |       _TimeStampAfterCompile;
      |       AfterCompile;
  Target Compile(DependsOnTargets="$(CompileDependsOn)")
  // ============================================================
  // _GenerateCompileInputs
  //
  // Create the _CoreCompileResourceInputs list of inputs to the CoreCompile target.
  // ============================================================
  Target _GenerateCompileInputs
    if '@(ManifestResourceWithNoCulture)'!='' and '%(ManifestResourceWithNoCulture.EmittedForCompatibilityOnly)'=='':
      MSBuildInternalMessage(
          FormatArguments="MSB9004;ManifestResourceWithNoCulture;false;Resx",
          ResourceName="CommonSdk.ManifestResourceWithNoCultureWarning",
          Severity="Warning")
    if '@(ManifestNonResxWithNoCultureOnDisk)'!='' and '%(ManifestNonResxWithNoCultureOnDisk.EmittedForCompatibilityOnly)'=='':
      MSBuildInternalMessage(
          FormatArguments="MSB9005;ManifestNonResxWithNoCultureOnDisk;false;Non-Resx",
          ResourceName="CommonSdk.ManifestResourceWithNoCultureWarning",
          Severity="Warning")
    ItemGroup
      // _CoreCompileResourceInputs is the list of TLDA inputs that should trigger CoreCompile, and are listed as inputs to that target
      if '%(EmbeddedResource.WithCulture)' == 'false' and '%(EmbeddedResource.Type)' == 'Resx':
        _CoreCompileResourceInputs += "@(EmbeddedResource->'%(OutputResource)')"
      if '%(EmbeddedResource.WithCulture)' == 'false' and '%(EmbeddedResource.Type)' == 'Non-Resx':
        _CoreCompileResourceInputs += "@(EmbeddedResource)"
      // CONSUMED FOR COMPATIBILITY REASONS ONLY. EMIT EMBEDDEDRESOURCE INSTEAD
      if '%(ManifestResourceWithNoCulture.EmittedForCompatibilityOnly)'=='':
        _CoreCompileResourceInputs += "@(ManifestResourceWithNoCulture)"
          Type = Resx
          WithCulture = false
      if '%(ManifestNonResxWithNoCultureOnDisk.EmittedForCompatibilityOnly)'=='':
        _CoreCompileResourceInputs += "@(ManifestNonResxWithNoCultureOnDisk)"
          Type = Non-Resx
          WithCulture = false
  // ============================================================
  // GenerateTargetFrameworkMonikerAttribute
  //
  // Emit the target framework moniker attribute as  a code fragment into a temporary source file for the compiler.
  // ============================================================
  if '$(TargetFrameworkMoniker)' != '':
    PropertyGroup
      // Do not clean if we are going to default the path to the temp directory
      if '$(TargetFrameworkMonikerAssemblyAttributesFileClean)' == '' and '$(TargetFrameworkMonikerAssemblyAttributesPath)' != '':
        TargetFrameworkMonikerAssemblyAttributesFileClean = true
      if '$(TargetFrameworkMonikerAssemblyAttributesPath)' == '':
        TargetFrameworkMonikerAssemblyAttributesPath = $([System.IO.Path]::Combine('$(IntermediateOutputPath)','$(TargetFrameworkMoniker).AssemblyAttributes$(DefaultLanguageSourceExtension)'))
  PropertyGroup
    if '$(GenerateTargetFrameworkAttribute)' == '' and '$(TargetFrameworkMoniker)' != '' and '$(TargetingClr2Framework)' != 'true':
      GenerateTargetFrameworkAttribute = true
  if '$(TargetFrameworkMonikerAssemblyAttributesFileClean)' == 'true':
    ItemGroup
      Clean += "$(TargetFrameworkMonikerAssemblyAttributesPath)"
  if '@(Compile)' != '' and '$(GenerateTargetFrameworkAttribute)' == 'true':
    Target GenerateTargetFrameworkMonikerAttribute(
        DependsOnTargets=[
          PrepareForBuild
          GetReferenceAssemblyPaths
        ],
        BeforeTargets="BeforeCompile",
        Inputs="$(MSBuildToolsPath)\Microsoft.Common.targets",
        Outputs="$(TargetFrameworkMonikerAssemblyAttributesPath)")
      // This is a file shared between projects so we have to take care to handle simultaneous writes (by ContinueOnError)
      // and a race between clean from one project and build from another (by not adding to FilesWritten so it doesn't clean)
      if '@(Compile)' != '' and '$(TargetFrameworkMonikerAssemblyAttributeText)' != '':
        WriteLinesToFile(
            ContinueOnError="true",
            File="$(TargetFrameworkMonikerAssemblyAttributesPath)",
            Lines="$(TargetFrameworkMonikerAssemblyAttributeText)",
            Overwrite="true")
      if '@(Compile)' != '' and '$(TargetFrameworkMonikerAssemblyAttributeText)' != '':
        ItemGroup
          Compile += "$(TargetFrameworkMonikerAssemblyAttributesPath)"
          // Do not put in FileWrites: this is a file shared between projects in %temp%, and cleaning it would create a race between projects during rebuild
  // ============================================================
  // GenerateAdditionalSources
  //
  // Emit any specified code fragments into a temporary source file for the compiler.
  // ============================================================
  if '$(AssemblyAttributesPath)' != '':
    PropertyGroup
      if '$(GenerateAdditionalSources)' == '':
        GenerateAdditionalSources = true
  if '$(AssemblyAttributesPath)' != '':
    ItemGroup
      if '$(AssemblyAttributesFileClean)' != 'false':
        Clean += "$(AssemblyAttributesPath)"
  if '@(AssemblyAttributes)' != '' and '$(GenerateAdditionalSources)' == 'true':
    Target GenerateAdditionalSources(
        DependsOnTargets=[
          PrepareForBuild
          GetReferenceAssemblyPaths
        ],
        BeforeTargets="BeforeCompile",
        Inputs="$(MSBuildAllProjects)",
        Outputs="$(AssemblyAttributesPath)")
      WriteCodeFragment(
          AssemblyAttributes="@(AssemblyAttributes)",
          Language="$(Language)",
          OutputFile="$(AssemblyAttributesPath)")
        Output(ItemName="Compile", TaskParameter="OutputFile")
        Output(ItemName="FileWrites", TaskParameter="OutputFile")
  // ============================================================
  // BeforeCompile
  //
  // Redefine this target in your project in order to run tasks just before Compile.
  // ============================================================
  Target BeforeCompile
  // ============================================================
  // AfterCompile
  //
  // Redefine this target in your project in order to run tasks just after Compile.
  // ============================================================
  Target AfterCompile
  // ============================================================
  // _TimeStampBeforeCompile
  //
  // If post-build events are set to fire "OnOutputUpdated", then take before
  // and after timestamps so that we can compare them.
  // ============================================================
  if '$(RunPostBuildEvent)'=='OnOutputUpdated' or ('$(RegisterForComInterop)'=='true' and '$(OutputType)'=='library'):
    Target _TimeStampBeforeCompile
      PropertyGroup
        _AssemblyTimestampBeforeCompile = %(IntermediateAssembly.ModifiedTime)
  // ============================================================
  // _GenerateSuggestedBindingRedirectsCache
  // Generate a file used to track whether suggested binding redirects changed between builds.
  // @(SuggestedBindingRedirects) never contains a file on disk, so create a file
  // that contains a hash of the items to prevent `GenerateBindingRedirects`
  // from running every build.
  //
  // See https://github.com/dotnet/msbuild/issues/5943 for details.
  // ============================================================
  if '$(DesignTimeBuild)' != 'true' and '$(BuildingProject)' == 'true':
    Target _GenerateSuggestedBindingRedirectsCache(DependsOnTargets="ResolveAssemblyReferences")
      PropertyGroup
        SuggestedBindingRedirectsCacheFile = $(IntermediateOutputPath)$(MSBuildProjectFile).SuggestedBindingRedirects.cache
      Hash(ItemsToHash="@(SuggestedBindingRedirects)")
        Output(PropertyName="SuggestedBindingRedirectsHash", TaskParameter="HashResult")
      WriteLinesToFile(
          File="$(SuggestedBindingRedirectsCacheFile)",
          Lines="$(SuggestedBindingRedirectsHash)",
          Overwrite="true",
          WriteOnlyWhenDifferent="true")
      ItemGroup
        FileWrites += "$(SuggestedBindingRedirectsCacheFile)"
  // ============================================================
  // _GenerateCompileDependencyCache
  //
  // Generate a file used to track compiler dependencies between incremental build
  // executions. This handles cases where items are added or removed from a glob (e.g.
  // <Compile Include="**\*.cs" />) and can't otherwise be detected with timestamp
  // comparisons. The file contains a hash of compiler inputs that are known to
  // contribute to incremental build inconsistencies.
  // ============================================================
  if '$(DesignTimeBuild)' != 'true' and '$(BuildingProject)' == 'true':
    Target _GenerateCompileDependencyCache(
        DependsOnTargets=[
          ResolveAssemblyReferences
          _GenerateCompileInputs
        ])
      ItemGroup
        CustomAdditionalCompileInputs += "$(IntermediateOutputPath)$(MSBuildProjectFile).CoreCompileInputs.cache"
        CoreCompileCache += "@(Compile)"
        CoreCompileCache += "@(ReferencePath)"
        CoreCompileCache += "$(DefineConstants)"
        CoreCompileCache += "$(LangVersion)"
        CoreCompileCache += "$(Deterministic)"
        CoreCompileCache += "$(PathMap)"
        CoreCompileCache += "@(_CoreCompileResourceInputs)"
      Hash(
          IgnoreCase="$([MSBuild]::ValueOrDefault(`$(CoreCompileCacheIgnoreCase)`, `true`))",
          ItemsToHash="@(CoreCompileCache)")
        Output(PropertyName="CoreCompileDependencyHash", TaskParameter="HashResult")
      WriteLinesToFile(
          File="$(IntermediateOutputPath)$(MSBuildProjectFile).CoreCompileInputs.cache",
          Lines="$(CoreCompileDependencyHash)",
          Overwrite="true",
          WriteOnlyWhenDifferent="true")
      ItemGroup
        FileWrites += "$(IntermediateOutputPath)$(MSBuildProjectFile).CoreCompileInputs.cache"
  // ============================================================
  // _TimeStampAfterCompile
  //
  // If post-build events are set to fire "OnOutputUpdated", then take before
  // and after timestamps so that we can compare them.
  // ============================================================
  if '$(RunPostBuildEvent)'=='OnOutputUpdated' or ('$(RegisterForComInterop)'=='true' and '$(OutputType)'=='library'):
    Target _TimeStampAfterCompile
      PropertyGroup
        _AssemblyTimestampAfterCompile = %(IntermediateAssembly.ModifiedTime)
  // ================================================================
  // _ComputeNonExistentFileProperty
  //
  // There are certain situations in which we want to always run the CoreCompile target (and
  // thus the Csc task), even if the timestamps of the outputs appear to be up-to-date on disk.
  // If we're inside the IDE during design-time, then the Csc/Vbc/Vjc task is simply being used to
  // initialize the host compiler, so we always want to run it.  Also, if we're inside the IDE, and
  // the host compiler is responsible for doing the compilation during an actual build, we want to let
  // the host compiler determine whether the output is up-to-date, because there may be source files
  // in the IDE's in-memory buffers that we don't know about.
  //
  // So, we always run the CoreCompile target if we're in the IDE, and either we're in design-time or
  // we're delegating to the host compiler for the actual build.
  //
  // We compare against BuildOutOfProcess != true because we cannot assume that the build process will
  // have set BuildOutOfProcess to true or false. Therefore the default behavior should be to do the
  // legacy behavior seen before BuildingOutOfProcess was introduced if the property is not set.
  // ================================================================
  if ('$(BuildingInsideVisualStudio)' == 'true') and ('$(BuildingOutOfProcess)' != 'true') and (('$(BuildingProject)' == 'false') or ('$(UseHostCompilerIfAvailable)' == 'true')):
    Target _ComputeNonExistentFileProperty
      PropertyGroup
        NonExistentFile = __NonExistentSubDir__\__NonExistentFile__
  // ***********************************************************************************************
  // ***********************************************************************************************
  // GenerateSerializationAssemblies Section
  // ***********************************************************************************************
  // ***********************************************************************************************
  PropertyGroup
    _SGenDllName = $(TargetName).XmlSerializers.dll
    _SGenDllCreated = false
    _SGenGenerateSerializationAssembliesConfig = $(GenerateSerializationAssemblies)
    if '$(GenerateSerializationAssemblies)' == '':
      _SGenGenerateSerializationAssembliesConfig = Auto
    if '$(ConfigurationName)'=='Debug' and '$(_SGenGenerateSerializationAssembliesConfig)' == 'Auto':
      _SGenGenerateSerializationAssembliesConfig = Off
    if '$(SGenUseProxyTypes)' == '':
      SGenUseProxyTypes = true
    if '$(SGenUseKeep)'=='':
      SGenUseKeep = false
    if '$(SGenShouldGenerateSerializer)' == '':
      SGenShouldGenerateSerializer = true
  // ============================================================
  // GenerateSerializationAssemblies
  //
  // Run GenerateSerializationAssemblies on the assembly produced by this build.
  //
  // [IN]
  // @(BuildAssemblyName) - The assembly generated by this build.
  // @(BuildAssemblyPath) - The path where the assembly resides.
  // @(ReferencePath) - The list of references used by this assembly.
  //
  // [OUT]
  // @(SerializationAssembly) - The path to the serialization assembly.  Maybe we'll just append to an existing list.
  // ============================================================
  if '$(_SGenGenerateSerializationAssembliesConfig)' == 'On' or ('@(WebReferenceUrl)'!='' and '$(_SGenGenerateSerializationAssembliesConfig)' == 'Auto'):
    Target GenerateSerializationAssemblies(
        DependsOnTargets=[
          AssignTargetPaths
          Compile
          ResolveKeySource
        ],
        Inputs="$(MSBuildAllProjects);@(IntermediateAssembly)",
        Outputs="$(IntermediateOutputPath)$(_SGenDllName)")
      PropertyGroup
        if '$(SGenMSBuildArchitecture)' == '':
          SGenMSBuildArchitecture = $(PlatformTargetAsMSBuildArchitecture)
      SGen(
          BuildAssemblyName="$(TargetFileName)",
          BuildAssemblyPath="$(IntermediateOutputPath)",
          DelaySign="$(DelaySign)",
          EnvironmentVariables="$(SGenEnvironment)",
          KeyContainer="$(KeyContainerName)",
          KeyFile="$(KeyOriginatorFile)",
          MSBuildArchitecture="$(SGenMSBuildArchitecture)",
          Platform="$(SGenPlatformTarget)",
          References="@(ReferencePath)",
          SdkToolsPath="$(TargetFrameworkSDKToolsDirectory)",
          SerializationAssembly="$(IntermediateOutputPath)$(_SGenDllName)",
          ShouldGenerateSerializer="$(SGenShouldGenerateSerializer)",
          ToolPath="$(SGenToolPath)",
          Types="$(SGenSerializationTypes)",
          UseKeep="$(SGenUseKeep)",
          UseProxyTypes="$(SGenUseProxyTypes)")
        Output(ItemName="SerializationAssembly", TaskParameter="SerializationAssembly")
  // ***********************************************************************************************
  // ***********************************************************************************************
  // CreateSatelliteAssemblies Section
  // ***********************************************************************************************
  // ***********************************************************************************************
  // ============================================================
  // CreateSatelliteAssemblies
  //
  // Create one satellite assembly for every unique culture in the resources.
  // ============================================================
  PropertyGroup
    CreateSatelliteAssembliesDependsOn =
      | $(CreateSatelliteAssembliesDependsOn);
      |       _GenerateSatelliteAssemblyInputs;
      |       ComputeIntermediateSatelliteAssemblies;
      |       GenerateSatelliteAssemblies
  Target CreateSatelliteAssemblies(DependsOnTargets="$(CreateSatelliteAssembliesDependsOn)")
  // ============================================================
  // _GenerateSatelliteAssemblyInputs
  //
  // Create the _SatelliteAssemblyResourceInputs list of inputs to the CreateSatelliteAssemblies target.
  // ============================================================
  Target _GenerateSatelliteAssemblyInputs
    if '@(ManifestResourceWithCulture)'!='' and '%(ManifestResourceWithCulture.EmittedForCompatibilityOnly)'=='':
      MSBuildInternalMessage(
          FormatArguments="MSB9006;ManifestResourceWithCulture;true;Resx",
          ResourceName="CommonSdk.ManifestResourceWithNoCultureWarning",
          Severity="Warning")
    if '@(ManifestNonResxWithCultureOnDisk)'!='' and '%(ManifestNonResxWithCultureOnDisk.EmittedForCompatibilityOnly)'=='':
      MSBuildInternalMessage(
          FormatArguments="MSB9007;ManifestNonResxWithCultureOnDisk;true;Non-Resx",
          ResourceName="CommonSdk.ManifestResourceWithNoCultureWarning",
          Severity="Warning")
    ItemGroup
      // _SatelliteAssemblyResourceInputs is the list of TLDA inputs that should trigger CreateSatelliteAssemblies, so listed as inputs to that target
      if '%(EmbeddedResource.WithCulture)' == 'true' and '%(EmbeddedResource.Type)' == 'Resx':
        _SatelliteAssemblyResourceInputs += "@(EmbeddedResource->'%(OutputResource)')"
      if '%(EmbeddedResource.WithCulture)' == 'true' and '%(EmbeddedResource.Type)' == 'Non-Resx':
        _SatelliteAssemblyResourceInputs += "@(EmbeddedResource)"
      // CONSUMED FOR COMPATIBILITY REASONS ONLY. EMIT EMBEDDEDRESOURCE INSTEAD
      if '%(ManifestResourceWithCulture.EmittedForCompatibilityOnly)'=='':
        _SatelliteAssemblyResourceInputs += "@(ManifestResourceWithCulture)"
          Type = Resx
          WithCulture = true
      if '%(ManifestNonResxWithCultureOnDisk.EmittedForCompatibilityOnly)'=='':
        _SatelliteAssemblyResourceInputs += "@(ManifestNonResxWithCultureOnDisk)"
          Type = Non-Resx
          WithCulture = true
  // ============================================================
  // GenerateSatelliteAssemblies
  //
  // Actually run al.exe to create the satellite assemblies.
  // ============================================================
  if '@(_SatelliteAssemblyResourceInputs)' != '' and '$(GenerateSatelliteAssembliesForCore)' != 'true':
    Target GenerateSatelliteAssemblies(
        Inputs="$(MSBuildAllProjects);@(_SatelliteAssemblyResourceInputs);$(IntermediateOutputPath)$(TargetName)$(TargetExt)",
        Outputs="$(IntermediateOutputPath)%(Culture)\$(TargetName).resources.dll")
      PropertyGroup
        if '$(_ALExeToolPath)' == '':
          _ALExeToolPath = $(TargetFrameworkSDKToolsDirectory)
      MakeDir(Directories="@(EmbeddedResource->'$(IntermediateOutputPath)%(Culture)')")
      AL(
          AlgorithmId="$(Satellite_AlgorithmId)",
          BaseAddress="$(Satellite_BaseAddress)",
          CompanyName="$(Satellite_CompanyName)",
          Configuration="$(Satellite_Configuration)",
          Copyright="$(Satellite_Copyright)",
          Culture="%(Culture)",
          DelaySign="$(DelaySign)",
          Description="$(Satellite_Description)",
          EmbedResources="@(_SatelliteAssemblyResourceInputs)",
          EnvironmentVariables="$(AlEnvironment)",
          EvidenceFile="$(Satellite_EvidenceFile)",
          FileVersion="$(Satellite_FileVersion)",
          Flags="$(Satellite_Flags)",
          GenerateFullPaths="$(Satellite_GenerateFullPaths)",
          KeyContainer="$(KeyContainerName)",
          KeyFile="$(KeyOriginatorFile)",
          LinkResources="@(Satellite_LinkResource)",
          MainEntryPoint="$(Satellite_MainEntryPoint)",
          OutputAssembly="$(IntermediateOutputPath)%(Culture)\$(TargetName).resources.dll",
          Platform="$(PlatformTarget)",
          ProductName="$(Satellite_ProductName)",
          ProductVersion="$(Satellite_ProductVersion)",
          ResponseFiles="@(AlResponseFile)",
          SdkToolsPath="$(_ALExeToolPath)",
          SourceModules="@(Satellite_SourceModule)",
          TargetType="$(Satellite_TargetType)",
          TemplateFile="$(IntermediateOutputPath)$(TargetName)$(TargetExt)",
          Title="$(Satellite_Title)",
          ToolExe="$(AlToolExe)",
          ToolPath="$(AlToolPath)",
          Trademark="$(Satellite_Trademark)",
          Version="$(Satellite_Version)",
          Win32Icon="$(Satellite_Win32Icon)",
          Win32Resource="$(Satellite_Win32Resource)")
        Output(ItemName="FileWrites", TaskParameter="OutputAssembly")
  // ============================================================
  // ComputeIntermediateSatelliteAssemblies
  //
  // Compute the paths to the intermediate satellite assemblies,
  // with culture attributes so we can copy them to the right place.
  // ============================================================
  PropertyGroup
    ComputeIntermediateSatelliteAssembliesDependsOn = CreateManifestResourceNames
  if @(EmbeddedResource->'%(WithCulture)') != '':
    Target ComputeIntermediateSatelliteAssemblies(
        DependsOnTargets="$(ComputeIntermediateSatelliteAssembliesDependsOn)")
      ItemGroup
        if '%(EmbeddedResource.Culture)' != '':
          IntermediateSatelliteAssembliesWithTargetPath += "$(IntermediateOutputPath)%(EmbeddedResource.Culture)\$(TargetName).resources.dll"
            Culture = %(EmbeddedResource.Culture)
            TargetPath = %(EmbeddedResource.Culture)\$(TargetName).resources.dll
  // ***********************************************************************************************
  // ***********************************************************************************************
  // SetWin32ManifestProperties Section
  // ***********************************************************************************************
  // ***********************************************************************************************
  PropertyGroup
    EmbeddedWin32Manifest = $(Win32Manifest)
  // ============================================================
  // SetWin32ManifestProperties
  //
  // Set Win32Manifest and EmbeddedManifest properties to be used later in the build.
  // ============================================================
  if '$(Win32Manifest)'=='':
    Target SetWin32ManifestProperties(
        DependsOnTargets=[
          ResolveComReferences
          ResolveNativeReferences
          _SetExternalWin32ManifestProperties
          _SetEmbeddedWin32ManifestProperties
        ])
  if '$(GenerateClickOnceManifests)'=='true' or '@(NativeReference)'!='' or '@(ResolvedIsolatedComModules)'!='':
    Target _SetExternalWin32ManifestProperties
      PropertyGroup
        // set _DeploymentBaseManifest property to the value of $(ApplicationManifest) if the property is set,
        // but use _DeploymentBaseManifestWithTargetPath item-group if the property is not set to support backwards
        // compat with earlier MSBuild versions when manifest files were determined by the item-group. If the newer
        // property is set though, prefer that one be used to specify the manifest.
        _DeploymentBaseManifest = $(ApplicationManifest)
        if '$(_DeploymentBaseManifest)'=='':
          _DeploymentBaseManifest = @(_DeploymentBaseManifestWithTargetPath)
        // when using external manifests, always set the NoWin32Manifest property to
        // true if there is no value set in the incoming project file so the
        // compilers that support manifest embedding know not to add
        // a manifest to their built assemblies
        if '$(NoWin32Manifest)'=='':
          NoWin32Manifest = true
  if '$(GenerateClickOnceManifests)'!='true' and '@(NativeReference)'=='' and '@(ResolvedIsolatedComModules)'=='':
    Target _SetEmbeddedWin32ManifestProperties
      PropertyGroup
        EmbeddedWin32Manifest = $(ApplicationManifest)
        Win32Manifest = $(ApplicationManifest)
      // If PreferNativeArm64 is enabled, it searches for the same default.win32manifest
      if '$(ApplicationManifest)'=='' and '$(NoWin32Manifest)'!='true' and '$(PreferNativeArm64)' != 'true':
        GetFrameworkPath
          Output(PropertyName="_FrameworkVersion40Path", TaskParameter="FrameworkVersion40Path")
      PropertyGroup
        if '$(ApplicationManifest)'=='' and '$(NoWin32Manifest)'!='true' and '$(PreferNativeArm64)' != 'true' and Exists('$(_FrameworkVersion40Path)\default.win32manifest'):
          EmbeddedWin32Manifest = $(_FrameworkVersion40Path)\default.win32manifest
  // ============================================================
  // _SetPreferNativeArm64Win32ManifestProperties
  //
  // Populates Manifest with SupportedArchitectures and updates Win32Manifest property to be used later in the build.
  // ============================================================
  if '$(PreferNativeArm64)'=='true' and '$(NoWin32Manifest)'!='true':
    Target _SetPreferNativeArm64Win32ManifestProperties(
        DependsOnTargets="SetWin32ManifestProperties")
      AddToWin32Manifest(
          ApplicationManifest="$(Win32Manifest)",
          OutputDirectory="$(IntermediateOutputPath)",
          SupportedArchitectures="$(_SupportedArchitectures)")
        Output(PropertyName="_Win32Manifest", TaskParameter="ManifestPath")
      PropertyGroup
        if '$(_Win32Manifest)' != '':
          Win32Manifest = $(_Win32Manifest)
  // ***********************************************************************************************
  // ***********************************************************************************************
  // GenerateManifests Section
  // ***********************************************************************************************
  // ***********************************************************************************************
  // ============================================================
  // GenerateManifests
  //
  // Generates ClickOnce application and deployment manifests or a native manifest.
  // ============================================================
  PropertyGroup
    GenerateManifestsDependsOn =
      | SetWin32ManifestProperties;
      |       GenerateApplicationManifest;
      |       GenerateDeploymentManifest
  // ============================================================
  // _GenerateResolvedDeploymentManifestEntryPoint
  //
  // Use the ResolveManifestFiles to generate the GenerateResolvedDeploymentManifestEntryPoint
  //
  // ============================================================
  Target _GenerateResolvedDeploymentManifestEntryPoint
    ItemGroup
      if '%(FileType)'=='ManifestEntryPoint':
        _DeploymentPublishFileOfTypeManifestEntryPoint += "@(PublishFile)"
    ResolveManifestFiles(
        DeploymentManifestEntryPoint="@(ApplicationManifest)",
        PublishFiles="@(_DeploymentPublishFileOfTypeManifestEntryPoint)",
        SigningManifests="$(SignManifests)",
        TargetFrameworkIdentifier="$(TargetFrameworkIdentifier)",
        TargetFrameworkVersion="$(TargetFrameworkVersion)")
      Output(
          ItemName="_DeploymentResolvedDeploymentManifestEntryPoint",
          TaskParameter="OutputDeploymentManifestEntryPoint")
  if '$(GenerateClickOnceManifests)'=='true' or '@(NativeReference)'!='' or '@(ResolvedIsolatedComModules)'!='' or '$(GenerateAppxManifest)' == 'true':
    Target GenerateManifests(DependsOnTargets="$(GenerateManifestsDependsOn)")
  // ============================================================
  // GenerateApplicationManifest
  //
  // Generates a ClickOnce or native application manifest.
  // An application manifest specifies declarative application identity, dependency and security information.
  //
  // [IN]
  // $(_DeploymentBaseManifest) - The base app.manifest from project.
  // @(ResolvedIsolatedComModules) - The list of COM references to be isolated as reg-free COM dependencies for native assembly loader.
  // @(_DeploymentManifestFiles) - The list of loose files (content, pdb, xml, etc.) for ClickOnce.
  // @(_DeploymentManifestDependencies) - The list of application dependencies (typically this is the set of assembly dependencies in bin\) for ClickOnce.
  // @(AppConfigWithTargetPath) - App config file, if present.
  // $(_DeploymentManifestType) - Type of manifest to be generated, either "Native" or "ClickOnce".
  //
  // [OUT]
  // @(ApplicationManifest) - Generated native or ClickOnce application manifest, i.e. WindowsApplication1.exe.manifest
  // ============================================================
  Target GenerateApplicationManifest(
      DependsOnTargets=[
        _DeploymentSetClickOnceVersions
        _DeploymentGenerateLauncher
        _DeploymentComputeNativeManifestInfo
        _DeploymentComputeClickOnceManifestInfo
        ResolveComReferences
        ResolveNativeReferences
        _GenerateResolvedDeploymentManifestEntryPoint
      ],
      Inputs="
            $(MSBuildAllProjects);
            @(AppConfigWithTargetPath);
            $(_DeploymentBaseManifest);
            @(ResolvedIsolatedComModules);
            @(_DeploymentManifestDependencies);
            @(_DeploymentResolvedManifestEntryPoint);
            @(_DeploymentManifestFiles)",
      Outputs="@(ApplicationManifest)")
    RequiresFramework35SP1Assembly(
        Assemblies="@(_DeploymentManifestDependencies)",
        CreateDesktopShortcut="$(CreateDesktopShortcut)",
        DeploymentManifestEntryPoint="@(_DeploymentResolvedDeploymentManifestEntryPoint)",
        EntryPoint="@(_DeploymentResolvedManifestEntryPoint)",
        ErrorReportUrl="$(_DeploymentFormattedErrorReportUrl)",
        Files="@(_DeploymentManifestFiles)",
        ReferencedAssemblies="@(Reference)",
        SigningManifests="$(SignManifests)",
        SuiteName="$(SuiteName)",
        TargetFrameworkVersion="$(TargetFrameworkVersion)")
      Output(
          PropertyName="_DeploymentRequiresMinimumFramework35SP1",
          TaskParameter="RequiresMinimumFramework35SP1")
    GenerateApplicationManifest(
        AssemblyName="$(_DeploymentApplicationManifestIdentity)",
        AssemblyVersion="$(_DeploymentManifestVersion)",
        ClrVersion="$(ClrVersion)",
        ConfigFile="@(AppConfigWithTargetPath)",
        Dependencies="@(_DeploymentManifestDependencies)",
        Description="$(Description)",
        EntryPoint="@(_DeploymentResolvedManifestEntryPoint)",
        ErrorReportUrl="$(_DeploymentFormattedErrorReportUrl)",
        FileAssociations="@(FileAssociation)",
        Files="@(_DeploymentManifestFiles)",
        HostInBrowser="$(HostInBrowser)",
        IconFile="@(_DeploymentManifestIconFile)",
        InputManifest="$(_DeploymentBaseManifest)",
        IsolatedComReferences="@(ResolvedIsolatedComModules)",
        LauncherBasedDeployment="$(_DeploymentLauncherBased)",
        ManifestType="$(_DeploymentManifestType)",
        MaxTargetPath="$(MaxTargetPath)",
        OSVersion="$(OSVersion)",
        OutputManifest="@(ApplicationManifest)",
        Platform="$(_DeploymentPlatformTarget)",
        Product="$(ProductName)",
        Publisher="$(PublisherName)",
        RequiresMinimumFramework35SP1="$(_DeploymentRequiresMinimumFramework35SP1)",
        SuiteName="$(SuiteName)",
        SupportUrl="$(_DeploymentFormattedSupportUrl)",
        TargetCulture="$(TargetCulture)",
        TargetFrameworkProfile="$(TargetFrameworkProfile)",
        TargetFrameworkSubset="$(TargetFrameworkSubset)",
        TargetFrameworkVersion="$(_DeploymentManifestTargetFrameworkVersion)",
        TrustInfoFile="@(_DeploymentIntermediateTrustInfoFile)",
        UseApplicationTrust="$(UseApplicationTrust)")
      Output(ItemName="FileWrites", TaskParameter="OutputManifest")
    if '$(PreferNativeArm64)'=='true':
      AddToWin32Manifest(
          ApplicationManifest="@(ApplicationManifest)",
          OutputDirectory="$(IntermediateOutputPath)",
          SupportedArchitectures="$(_SupportedArchitectures)")
    PropertyGroup
      _DeploymentCopyApplicationManifest = true
  // ============================================================
  // _DeploymentSetClickOnceVersions
  //
  // Sets ClickOnce versions
  // ============================================================
  if '$(GenerateClickOnceManifests)'=='true':
    Target _DeploymentSetClickOnceVersions
      PropertyGroup
        _DeploymentManifestTargetFrameworkMoniker = $(TargetFrameworkMoniker)
        _DeploymentManifestTargetFrameworkVersion = $(TargetFrameworkVersion)
  // ============================================================
  // _DeploymentGenerateLauncher
  //
  // Generates Launcher if needed
  // ============================================================
  if '$(GenerateClickOnceManifests)'=='true' and '$(_DeploymentLauncherBased)' == 'true':
    Target _DeploymentGenerateLauncher
      // If apphost based built EXE is found, use that as the Launcher.exe's entry point otherwise
      // use the built DLL as the entry point
      if '$(UseAppHost)' == 'true' and '$(_IsExecutable)' == 'true' and exists('$(AppHostIntermediatePath)'):
        ItemGroup
          EntryPointForLauncher += "$(AppHostIntermediatePath)"(TargetPath="$(AssemblyName).exe")
          ContentWithTargetPath += "@(EntryPointForLauncher)"
      if '$(EntryPointForLauncher)'=='':
        ItemGroup
          EntryPointForLauncher += "$(_DeploymentManifestEntryPoint)"
      // Generates Launcher and obtains its Framework version and moniker
      GenerateLauncher(
          AssemblyName="$(_DeploymentApplicationManifestIdentity)",
          EntryPoint="@(EntryPointForLauncher)",
          OutputPath="$(IntermediateOutputPath)",
          VisualStudioVersion="$(VisualStudioVersion)")
        Output(ItemName="_DeploymentManifestLauncherEntryPoint", TaskParameter="OutputEntryPoint")
      // .NET Core ClickOnce deployments use Launcher, which targets .NET FX 4.5 as the minimum
      // supported ClickOnce runtime version on target user's machine.
      //
      // TargetFramework Verion and Moniker properties are used in Deployment manifest generation
      // task to set compatibleFrameworks element, which needs to match Launcher's target version.
      //
      // Version can be overriden with DeploymentManifestTargetFrameworkVersionOverride property.
      PropertyGroup
        if '$(DeploymentManifestTargetFrameworkVersionOverride)' == '':
          _DeploymentManifestTargetFrameworkVersion = v4.5
        if '$(DeploymentManifestTargetFrameworkVersionOverride)' != '':
          _DeploymentManifestTargetFrameworkVersion = $(DeploymentManifestTargetFrameworkVersionOverride)
        _DeploymentManifestTargetFrameworkMoniker = .NETFramework,Version=$(_DeploymentManifestTargetFrameworkVersion)
      // Sign Launcher EXE
      if '$(_DeploymentSignClickOnceManifests)'=='true':
        SignFile(
            CertificateThumbprint="$(_DeploymentResolvedManifestCertificateThumbprint)",
            SigningTarget="@(_DeploymentManifestLauncherEntryPoint)",
            TargetFrameworkIdentifier="$(TargetFrameworkIdentifier)",
            TargetFrameworkVersion="$(TargetFrameworkVersion)",
            TimestampUrl="$(ManifestTimestampUrl)")
      // Sign the original ClickOnce entrypoint
      if '$(_DeploymentSignClickOnceManifests)'=='true':
        SignFile(
            CertificateThumbprint="$(_DeploymentResolvedManifestCertificateThumbprint)",
            SigningTarget="@(_DeploymentManifestEntryPoint)",
            TargetFrameworkIdentifier="$(TargetFrameworkIdentifier)",
            TargetFrameworkVersion="$(TargetFrameworkVersion)",
            TimestampUrl="$(ManifestTimestampUrl)")
      // Sign apphost.exe if it's the entrypoint for the Launcher.exe. This is the case in loose file publish
      if '$(_DeploymentSignClickOnceManifests)'=='true' and '$(UseAppHost)' == 'true' and '$(PublishSingleFile)' != 'true' and '$(_IsExecutable)' == 'true' and exists('$(AppHostIntermediatePath)'):
        SignFile(
            CertificateThumbprint="$(_DeploymentResolvedManifestCertificateThumbprint)",
            SigningTarget="$(AppHostIntermediatePath)",
            TargetFrameworkIdentifier="$(TargetFrameworkIdentifier)",
            TargetFrameworkVersion="$(TargetFrameworkVersion)",
            TimestampUrl="$(ManifestTimestampUrl)")
      // Replace entry-point with Launcher and move original project's entry-point to content group.
      ItemGroup
        ContentWithTargetPath += "@(_DeploymentManifestEntryPoint)"
        _DeploymentManifestEntryPoint -= "@(_DeploymentManifestEntryPoint)"
        _DeploymentManifestEntryPoint += "@(_DeploymentManifestLauncherEntryPoint)"
  // ============================================================
  // _DeploymentComputeNativeManifestInfo
  //
  // Compute info for native manifest generation
  // ============================================================
  if '$(GenerateClickOnceManifests)'!='true':
    Target _DeploymentComputeNativeManifestInfo
      // Create list of items for manifest generation
      ResolveManifestFiles(
          NativeAssemblies="@(NativeReferenceFile);@(_DeploymentNativePrerequisite)")
        Output(ItemName="_DeploymentManifestDependencies", TaskParameter="OutputAssemblies")
      PropertyGroup
        _DeploymentManifestType = Native
      // Obtain manifest version from the built assembly
      GetAssemblyIdentity(AssemblyFiles="@(IntermediateAssembly)")
        Output(ItemName="_IntermediateAssemblyIdentity", TaskParameter="Assemblies")
      PropertyGroup
        _DeploymentManifestVersion = @(_IntermediateAssemblyIdentity->'%(Version)')
  // ============================================================
  // _DeploymentComputeClickOnceManifestInfo
  //
  // Compute info for  ClickOnce manifest generation
  // ============================================================
  if '$(GenerateClickOnceManifests)'=='true':
    Target _DeploymentComputeClickOnceManifestInfo(
        DependsOnTargets="$(DeploymentComputeClickOnceManifestInfoDependsOn)")
      // Grab just the serialization assemblies for a referenced assembly.  There may also be a symbols file in ReferenceRelatedPaths
      ItemGroup
        if '%(Extension)' == '.dll':
          _SGenDllsRelatedToCurrentDll += "@(_ReferenceSerializationAssemblyPaths->'%(FullPath)')"
        if '%(Extension)' == '.dll':
          _SGenDllsRelatedToCurrentDll += "@(SerializationAssembly->'%(FullPath)')"
      if !exists('$(ProjectLockFile)'):
        ItemGroup
          if '%(CopyLocal)' == 'false':
            _CopyLocalFalseRefPaths += "@(ReferencePath)"
          _CopyLocalFalseRefPathsWithExclusion += "@(_CopyLocalFalseRefPaths)"(
              Exclude="@(ReferenceCopyLocalPaths);@(_NETStandardLibraryNETFrameworkLib)")
      if '$(PublishSingleFile)' != 'true':
        ItemGroup
          _ClickOnceSatelliteAssemblies += "@(IntermediateSatelliteAssembliesWithTargetPath);@(ReferenceSatellitePaths)"
      // Flag primary dependencies-certain warnings emitted during application manifest generation apply only to them.
      ItemGroup
        if ('%(Extension)' == '.dll' Or '%(Extension)' == '.exe' Or '%(Extension)' == '.md') and ('%(ReferenceCopyLocalPaths.CopyToPublishDirectory)' != 'false'):
          _DeploymentReferencePaths += "@(ReferenceCopyLocalPaths)"
            IsPrimary = true
        _DeploymentReferencePaths += "@(_CopyLocalFalseRefPathsWithExclusion)"
      // Include managed references in clickonce manifest only if single file publish is false
      if '$(PublishSingleFile)' != 'true':
        ItemGroup
          _ManifestManagedReferences += "@(_DeploymentReferencePaths);@(ReferenceDependencyPaths);@(_SGenDllsRelatedToCurrentDll);@(SerializationAssembly);@(ReferenceCOMWrappersToCopyLocal)"(
              Exclude="@(_ClickOnceSatelliteAssemblies);@(_ReferenceScatterPaths);@(_ExcludedAssembliesFromManifestGeneration)")
      // Include the following files in clickonce manifest only if single file publish is false
      if '$(PublishSingleFile)' != 'true':
        ItemGroup
          // _ClickOnceRuntimeCopyLocalItems group contains any runtimes folder assets of Nuget packages that are not included in
          // _DeploymentReferencePaths (e.g. pdbs). They are populated from the RuntimeTargetsCopyLocalItems and NativeCopyLocalItems
          // group that contain the RID-specific assets that go in runtimes folder on publish. They are output groups of the
          // ResolvePackageAssets target in dotnet/sdk
          if '%(RuntimeTargetsCopyLocalItems.CopyLocal)' == 'true':
            _ClickOnceRuntimeCopyLocalItems += "@(RuntimeTargetsCopyLocalItems)"
          if '%(NativeCopyLocalItems.CopyLocal)' == 'true':
            _ClickOnceRuntimeCopyLocalItems += "@(NativeCopyLocalItems)"
          _ClickOnceRuntimeCopyLocalItems -= "@(_DeploymentReferencePaths)"
          // For .NET>=5, we need to check if we need to publish any content items from transitive project references. For such items to be published, they
          // either have the .exe/.dll extension or their publish status has been overriden in VS so they will show up in the PublishFiles collection.
          // The PublishProtocol property is available only in .NET>=5 so we will used that to exclude .NET FX 4.X case.
          if '$(PublishProtocol)' == 'ClickOnce':
            _ClickOnceTransitiveContentItemsTemp += "@(_TransitiveItemsToCopyToOutputDirectory->WithoutMetadataValue('CopyToPublishDirectory', 'Never')->'%(TargetPath)')"
              SavedIdentity = %(Identity)
          if '%(Identity)'=='@(PublishFile)' Or '%(Extension)'=='.exe' Or '%(Extension)'=='.dll':
            _ClickOnceTransitiveContentItems += "@(_ClickOnceTransitiveContentItemsTemp->'%(SavedIdentity)')"
          // ClickOnce content items is union of transitive content items and content items from this project.
          // We also exclude content items from this project that have set CopyToPublishDirectory to Never.
          _ClickOnceContentItems += "@(ContentWithTargetPath->WithoutMetadataValue('CopyToPublishDirectory', 'Never'))"
          _ClickOnceContentItems += "@(_ClickOnceTransitiveContentItems)"
          // For .NET>=5, we need to check if we need to publish any copylocal items from None group. For such items to be published, they either
          // have .exe/.dll extension or their publish status has been overriden in VS so they will show up in the PublishFiles collection.
          // The PublishProtocol property is available only in .NET>=5 so we will used that to exclude .NET FX 4.X case.
          // Include items from None group for publishing
          if '$(PublishProtocol)'=='Clickonce' And ('%(_NoneWithTargetPath.CopyToOutputDirectory)'=='Always' or '%(_NoneWithTargetPath.CopyToOutputDirectory)'=='PreserveNewest' or '%(_NoneWithTargetPath.CopyToOutputDirectory)'=='IfDifferent'):
            _ClickOnceNoneItemsTemp += "@(_NoneWithTargetPath->WithoutMetadataValue('CopyToPublishDirectory', 'Never')->'%(TargetPath)')"
              SavedIdentity = %(Identity)
          if '%(Identity)'=='@(PublishFile)' Or '%(Extension)'=='.exe' Or '%(Extension)'=='.dll':
            _ClickOnceNoneItems += "@(_ClickOnceNoneItemsTemp->'%(SavedIdentity)')"
          _ClickOnceFiles += "@(_ClickOnceContentItems);@(_DeploymentManifestIconFile);@(AppConfigWithTargetPath);@(NetCoreRuntimeJsonFilesForClickOnce);@(_ClickOnceRuntimeCopyLocalItems);@(_ClickOnceNoneItems)"
          // clear temporary item groups to free memory
          _ClickOnceNoneItemsTemp -= "@(_ClickOnceNoneItemsTemp)"
          _ClickOnceNoneItems -= "@(_ClickOnceNoneItems)"
          _ClickOnceTransitiveContentItemsTemp -= "@(_ClickOnceTransitiveContentItemsTemp)"
          _ClickOnceTransitiveContentItems -= "@(_ClickOnceTransitiveContentItems)"
          _ClickOnceContentItems -= "@(_ClickOnceContentItems)"
          _ClickOnceRuntimeCopyLocalItems -= "@(_ClickOnceRuntimeCopyLocalItems)"
      // For single file publish, we need to include the SF bundle EXE, application icon file and files excluded from the bundle EXE in the clickonce manifest
      if '$(PublishSingleFile)' == 'true':
        ItemGroup
          _ClickOnceFiles += "$(PublishedSingleFilePath);@(_DeploymentManifestIconFile)"
          _ClickOnceFiles += "@(_FilesExcludedFromBundle)"
          // Include file association icons from Content as loose files
          _FileAssociationIcons += "%(FileAssociation.DefaultIcon)"
          if '%(Identity)'=='@(_FileAssociationIcons)':
            _ClickOnceFiles += "@(ContentWithTargetPath)"
      // For single file publish in .net core app, sign the SF EXE if signing is enabled
      if '$(_DeploymentSignClickOnceManifests)'=='true' and '$(_DeploymentLauncherBased)' == 'true' and '$(PublishSingleFile)' == 'true':
        SignFile(
            CertificateThumbprint="$(_DeploymentResolvedManifestCertificateThumbprint)",
            SigningTarget="$(PublishedSingleFilePath)",
            TargetFrameworkIdentifier="$(TargetFrameworkIdentifier)",
            TargetFrameworkVersion="$(TargetFrameworkVersion)",
            TimestampUrl="$(ManifestTimestampUrl)")
      // If ReadyToRun is enabled in loose files scenario, we need to remove entries of the IL images that have gone through R2R
      // compiler and replace them with the entries for their R2R images. The R2R application image also needs to be signed if necessary.
      if '$(PublishReadyToRun)' == 'true' and '$(PublishSingleFile)' != 'true':
        ItemGroup
          _ManifestManagedReferences -= "@(_ReadyToRunCompileList)"
          _ClickOnceFiles -= "@(_ReadyToRunCompileList)"
          _ClickOnceFiles += "@(_ReadyToRunFilesToPublish)"
          if '%(Filename)%(Extension)' == '$(TargetFileName)':
            _ClickOnceTargetFile += "@(_ReadyToRunFilesToPublish)"
      // Sign application image created by R2R
      if '$(_DeploymentSignClickOnceManifests)' == 'true' and '$(PublishReadyToRun)' == 'true' and '$(PublishSingleFile)' != 'true':
        SignFile(
            CertificateThumbprint="$(_DeploymentResolvedManifestCertificateThumbprint)",
            SigningTarget="@(_ClickOnceTargetFile)",
            TargetFrameworkIdentifier="$(TargetFrameworkIdentifier)",
            TargetFrameworkVersion="$(TargetFrameworkVersion)",
            TimestampUrl="$(ManifestTimestampUrl)")
      // Copy the application executable from Obj folder to app.publish folder.
      // This is being done to avoid Windows Forms designer memory issues that can arise while operating directly on files located in Obj directory.
      Copy(
          DestinationFolder="$(ClickOncePublishDir)",
          SourceFiles="@(_DeploymentManifestEntryPoint)")
        Output(
            ItemName="_DeploymentClickOnceApplicationExecutable",
            TaskParameter="DestinationFiles")
      // Sign the application executable located in app.publish folder.  Signing this file is done to comply with SmartScreen.
      if '$(_DeploymentResolvedManifestCertificateThumbprint)'!='' and '$(_DeploymentSignClickOnceManifests)'=='true' and '$(TargetExt)' == '.exe':
        SignFile(
            CertificateThumbprint="$(_DeploymentResolvedManifestCertificateThumbprint)",
            SigningTarget="@(_DeploymentClickOnceApplicationExecutable)",
            TimestampUrl="$(ManifestTimestampUrl)")
      // Create list of items for manifest generation
      ResolveManifestFiles(
          AssemblyName="$(_DeploymentApplicationManifestIdentity)",
          EntryPoint="@(_DeploymentClickOnceApplicationExecutable)",
          ExtraFiles="@(_DebugSymbolsIntermediatePath);$(IntermediateOutputPath)$(TargetName).xml;@(_ReferenceRelatedPaths)",
          Files="@(_ClickOnceFiles)",
          IsSelfContainedPublish="$(SelfContained)",
          IsSingleFilePublish="$(PublishSingleFile)",
          LauncherBasedDeployment="$(_DeploymentLauncherBased)",
          ManagedAssemblies="@(_ManifestManagedReferences)",
          NativeAssemblies="@(NativeReferenceFile);@(_DeploymentNativePrerequisite)",
          PublishFiles="@(PublishFile)",
          RuntimePackAssets="@(RuntimePackAsset)",
          SatelliteAssemblies="@(_ClickOnceSatelliteAssemblies)",
          SigningManifests="$(SignManifests)",
          TargetCulture="$(TargetCulture)",
          TargetFrameworkIdentifier="$(TargetFrameworkIdentifier)",
          TargetFrameworkVersion="$(TargetFrameworkVersion)")
        Output(
            ItemName="_DeploymentManifestDependenciesUnfiltered",
            TaskParameter="OutputAssemblies")
        Output(ItemName="_DeploymentManifestFiles", TaskParameter="OutputFiles")
        Output(ItemName="_DeploymentResolvedManifestEntryPoint", TaskParameter="OutputEntryPoint")
      // We have to filter items out of the dependencies that have neither CopyLocal set to true,
      // nor the dependency type manually set to 'Install'.
      ItemGroup
        if !('%(_DeploymentManifestDependenciesUnfiltered.CopyLocal)' == 'false' And '%(_DeploymentManifestDependenciesUnfiltered.DependencyType)' != 'Install'):
          _DeploymentManifestDependencies += "@(_DeploymentManifestDependenciesUnfiltered)"
      PropertyGroup
        _DeploymentManifestType = ClickOnce
      // Manifest platform should always be MSIL for Launcher-based deployments, as the Launcher is MSIL.
      // Do not set _DeploymentPlatformTarget property in Launcher case - this is interpreted as MSIL,
      // by GenerateApplicationManifest and GenerateDeploymentManifest tasks.
      // Otherwise, set it to PlatformTarget.
      PropertyGroup
        if '$(_DeploymentLauncherBased)' != 'true':
          _DeploymentPlatformTarget = $(PlatformTarget)
      // Obtain manifest version from ApplicationVersion and ApplicationRevision properties
      FormatVersion(Revision="$(ApplicationRevision)", Version="$(ApplicationVersion)")
        Output(PropertyName="_DeploymentManifestVersion", TaskParameter="OutputVersion")
      FormatUrl(InputUrl="$(_DeploymentUrl)")
        Output(PropertyName="_DeploymentFormattedDeploymentUrl", TaskParameter="OutputUrl")
      FormatUrl(InputUrl="$(SupportUrl)")
        Output(PropertyName="_DeploymentFormattedSupportUrl", TaskParameter="OutputUrl")
      FormatUrl(InputUrl="$(ErrorReportUrl)")
        Output(PropertyName="_DeploymentFormattedErrorReportUrl", TaskParameter="OutputUrl")
  // ============================================================
  // _DeploymentGenerateTrustInfo
  //
  // Generates the application permission set for inclusion in the generated ClickOnce application manifest.
  // ============================================================
  if '$(TargetZone)'!='':
    Target _DeploymentGenerateTrustInfo(
        Inputs="
            $(MSBuildAllProjects);
            $(_DeploymentBaseManifest);
            ",
        Outputs="@(_DeploymentIntermediateTrustInfoFile)")
      GenerateTrustInfo(
          ApplicationDependencies="@(ReferencePath);@(ReferenceDependencyPaths)",
          BaseManifest="$(_DeploymentBaseManifest)",
          ExcludedPermissions="$(ExcludedPermissions)",
          TargetFrameworkMoniker="$(TargetFrameworkMoniker)",
          TargetZone="$(TargetZone)",
          TrustInfoFile="@(_DeploymentIntermediateTrustInfoFile)")
        Output(ItemName="FileWrites", TaskParameter="TrustInfoFile")
  // ============================================================
  // GenerateDeploymentManifest
  //
  // Generates a ClickOnce deployment manifest.
  // An deployment manifest specifies declarative application identity and application update information.
  // ============================================================
  Target GenerateDeploymentManifest(
      DependsOnTargets="GenerateApplicationManifest",
      Inputs="
            $(MSBuildAllProjects);
            @(ApplicationManifest)
            ",
      Outputs="@(DeployManifest)")
    if '$(GenerateClickOnceManifests)'=='true':
      GenerateDeploymentManifest(
          AssemblyName="$(_DeploymentDeployManifestIdentity)",
          AssemblyVersion="$(_DeploymentManifestVersion)",
          CreateDesktopShortcut="$(CreateDesktopShortcut)",
          DeploymentUrl="$(_DeploymentFormattedDeploymentUrl)",
          Description="$(Description)",
          DisallowUrlActivation="$(DisallowUrlActivation)",
          EntryPoint="@(_DeploymentResolvedDeploymentManifestEntryPoint)",
          ErrorReportUrl="$(_DeploymentFormattedErrorReportUrl)",
          Install="$(Install)",
          LauncherBasedDeployment="$(_DeploymentLauncherBased)",
          MapFileExtensions="$(MapFileExtensions)",
          MaxTargetPath="$(MaxTargetPath)",
          MinimumRequiredVersion="$(_DeploymentBuiltMinimumRequiredVersion)",
          OutputManifest="@(DeployManifest)",
          Platform="$(_DeploymentPlatformTarget)",
          Product="$(ProductName)",
          Publisher="$(PublisherName)",
          SuiteName="$(SuiteName)",
          SupportUrl="$(_DeploymentFormattedSupportUrl)",
          TargetCulture="$(TargetCulture)",
          TargetFrameworkMoniker="$(_DeploymentManifestTargetFrameworkMoniker)",
          TargetFrameworkVersion="$(_DeploymentManifestTargetFrameworkVersion)",
          TrustUrlParameters="$(TrustUrlParameters)",
          UpdateEnabled="$(UpdateEnabled)",
          UpdateInterval="$(_DeploymentBuiltUpdateInterval)",
          UpdateMode="$(UpdateMode)",
          UpdateUnit="$(_DeploymentBuiltUpdateIntervalUnits)")
        Output(ItemName="FileWrites", TaskParameter="OutputManifest")
  // ***********************************************************************************************
  // ***********************************************************************************************
  // PrepareForRun Section
  // ***********************************************************************************************
  // ***********************************************************************************************
  PropertyGroup
    if '$(SkipCopyUnchangedFiles)' == '':
      SkipCopyUnchangedFiles = true
    if '$(UseCommonOutputDirectory)' == '':
      UseCommonOutputDirectory = false
  // ============================================================
  // PrepareForRun
  //
  // Copy the build outputs to the final directory if they have changed.
  // ============================================================
  PropertyGroup
    PrepareForRunDependsOn = CopyFilesToOutputDirectory
  Target PrepareForRun(DependsOnTargets="$(PrepareForRunDependsOn)")
  // ============================================================
  // CopyFilesToOutputDirectory
  //
  // Copy all build outputs, satellites and other necessary files to the final directory.
  // ============================================================
  PropertyGroup
    // By default we're not using Hard or Symbolic Links to copy to the output directory, and never when building in VS
    if '$(BuildingInsideVisualStudio)' == 'true' or '$(CreateHardLinksForCopyAdditionalFilesIfPossible)' == '':
      CreateHardLinksForCopyAdditionalFilesIfPossible = false
    if '$(BuildingInsideVisualStudio)' == 'true' or '$(CreateSymbolicLinksForCopyAdditionalFilesIfPossible)' == '':
      CreateSymbolicLinksForCopyAdditionalFilesIfPossible = false
  Target CopyFilesToOutputDirectory(
      DependsOnTargets=[
        ComputeIntermediateSatelliteAssemblies
        _CopyFilesMarkedCopyLocal
        _CopySourceItemsToOutputDirectory
        _CopyAppConfigFile
        _CopyManifestFiles
        _CheckForCompileOutputs
        _SGenCheckForOutputs
      ])
    PropertyGroup
      // By default we're not using Hard Links to copy to the output directory, and never when building in VS
      if '$(BuildingInsideVisualStudio)' == 'true' or '$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)' == '':
        CreateHardLinksForCopyFilesToOutputDirectoryIfPossible = false
      if '$(BuildingInsideVisualStudio)' == 'true' or '$(CreateSymbolicLinksForCopyFilesToOutputDirectoryIfPossible)' == '':
        CreateSymbolicLinksForCopyFilesToOutputDirectoryIfPossible = false
      if '$(BuildingInsideVisualStudio)' == 'true' or '$(ErrorIfLinkFailsForCopyFilesToOutputDirectory)' == '':
        ErrorIfLinkFailsForCopyFilesToOutputDirectory = false
    PropertyGroup
      if '$(CopyBuildOutputToOutputDirectory)'=='':
        CopyBuildOutputToOutputDirectory = true
      if '$(CopyOutputSymbolsToOutputDirectory)'=='':
        CopyOutputSymbolsToOutputDirectory = true
      if '$(CopyDocumentationFileToOutputDirectory)'=='':
        CopyDocumentationFileToOutputDirectory = true
    // Copy the build product (.dll or .exe).
    if '$(CopyBuildOutputToOutputDirectory)' == 'true' and '$(SkipCopyBuildProduct)' != 'true':
      Copy(
          DestinationFolder="$(OutDir)",
          ErrorIfLinkFails="$(ErrorIfLinkFailsForCopyFilesToOutputDirectory)",
          OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)",
          Retries="$(CopyRetryCount)",
          RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)",
          SkipUnchangedFiles="$(SkipCopyUnchangedFiles)",
          SourceFiles="@(IntermediateAssembly)",
          UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)",
          UseSymboliclinksIfPossible="$(CreateSymbolicLinksForCopyFilesToOutputDirectoryIfPossible)")
        Output(ItemName="MainAssembly", TaskParameter="DestinationFiles")
        Output(ItemName="FileWrites", TaskParameter="DestinationFiles")
        Output(
            PropertyName="_WroteMainAssemblyToOutputDirectory",
            TaskParameter="WroteAtLeastOneFile")
    // Copy the reference assembly build product (.dll or .exe).
    if '$(ProduceReferenceAssembly)' == 'true' and '$(CopyBuildOutputToOutputDirectory)' == 'true' and '$(SkipCopyBuildProduct)' != 'true':
      CopyRefAssembly(DestinationPath="$(TargetRefPath)", SourcePath="@(IntermediateRefAssembly)")
        Output(ItemName="ReferenceAssembly", TaskParameter="DestinationPath")
        Output(ItemName="FileWrites", TaskParameter="DestinationPath")
    if '$(CopyBuildOutputToOutputDirectory)' == 'true' and '$(SkipCopyBuildProduct)'!='true':
      Message(Importance="High", Text="$(MSBuildProjectName) -> @(MainAssembly->'%(FullPath)')")
    // Advance the marker considered by projects that reference this one during their up-to-date
    // checks. It must move forward when either:
    // * this project produces reference assemblies and its implementation assembly changed on
    // this build (referencing projects may need to copy the updated implementation), or
    // * copy-local (possibly transitive) references were actually copied on this build, as
    // captured by _CopyFilesMarkedCopyLocal in $(_CopyLocalReferencesCopiedInThisBuild).
    // Both signals are OR'd into this single Touch so the marker is written at most once per
    // build. _CopyFilesMarkedCopyLocal is a DependsOnTargets dependency of this target, so its
    // capture always runs before this Touch.
    if ('$(ProduceReferenceAssembly)' == 'true' and '$(_WroteMainAssemblyToOutputDirectory)' == 'true') or '$(_CopyLocalReferencesCopiedInThisBuild)' == 'true':
      Touch(AlwaysCreate="true", Files="@(CopyUpToDateMarker)")
    if '$(ProduceReferenceAssembly)' == 'true':
      ItemGroup
        FileWrites += "@(CopyUpToDateMarker)"
    // Copy the additional modules.
    if '@(AddModules)' != '':
      Copy(
          DestinationFolder="$(OutDir)",
          OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)",
          Retries="$(CopyRetryCount)",
          RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)",
          SkipUnchangedFiles="$(SkipCopyUnchangedFiles)",
          SourceFiles="@(AddModules)",
          UseHardlinksIfPossible="$(CreateHardLinksForCopyAdditionalFilesIfPossible)",
          UseSymboliclinksIfPossible="$(CreateSymbolicLinksForCopyAdditionalFilesIfPossible)")
        Output(ItemName="FileWrites", TaskParameter="DestinationFiles")
    // Copy the serialization assembly if it exists.
    if '$(_SGenDllCreated)'=='true':
      Copy(
          DestinationFiles="$(OutDir)$(_SGenDllName)",
          ErrorIfLinkFails="$(ErrorIfLinkFailsForCopyFilesToOutputDirectory)",
          OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)",
          Retries="$(CopyRetryCount)",
          RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)",
          SkipUnchangedFiles="$(SkipCopyUnchangedFiles)",
          SourceFiles="$(IntermediateOutputPath)$(_SGenDllName)",
          UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)",
          UseSymboliclinksIfPossible="$(CreateSymbolicLinksForCopyFilesToOutputDirectoryIfPossible)")
        Output(ItemName="FileWrites", TaskParameter="DestinationFiles")
    // Copy the debug information file (.pdb), if any
    if '$(_DebugSymbolsProduced)'=='true' and '$(SkipCopyingSymbolsToOutputDirectory)' != 'true' and '$(CopyOutputSymbolsToOutputDirectory)'=='true':
      Copy(
          DestinationFiles="@(_DebugSymbolsOutputPath)",
          ErrorIfLinkFails="$(ErrorIfLinkFailsForCopyFilesToOutputDirectory)",
          OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)",
          Retries="$(CopyRetryCount)",
          RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)",
          SkipUnchangedFiles="$(SkipCopyUnchangedFiles)",
          SourceFiles="@(_DebugSymbolsIntermediatePath)",
          UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)",
          UseSymboliclinksIfPossible="$(CreateSymbolicLinksForCopyFilesToOutputDirectoryIfPossible)")
        Output(ItemName="FileWrites", TaskParameter="DestinationFiles")
    // Copy the resulting XML documentation file, if any.
    if '$(_DocumentationFileProduced)'=='true' and '$(CopyDocumentationFileToOutputDirectory)'=='true':
      Copy(
          DestinationFiles="@(FinalDocFile)",
          ErrorIfLinkFails="$(ErrorIfLinkFailsForCopyFilesToOutputDirectory)",
          OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)",
          Retries="$(CopyRetryCount)",
          RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)",
          SkipUnchangedFiles="$(SkipCopyUnchangedFiles)",
          SourceFiles="@(DocFileItem)",
          UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)",
          UseSymboliclinksIfPossible="$(CreateSymbolicLinksForCopyFilesToOutputDirectoryIfPossible)")
        Output(ItemName="FileWrites", TaskParameter="DestinationFiles")
    // Copy satellite assemblies.
    if '@(IntermediateSatelliteAssembliesWithTargetPath)' != '':
      Copy(
          DestinationFiles="@(IntermediateSatelliteAssembliesWithTargetPath->'$(OutDir)%(Culture)\$(TargetName).resources.dll')",
          ErrorIfLinkFails="$(ErrorIfLinkFailsForCopyFilesToOutputDirectory)",
          OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)",
          Retries="$(CopyRetryCount)",
          RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)",
          SkipUnchangedFiles="$(SkipCopyUnchangedFiles)",
          SourceFiles="@(IntermediateSatelliteAssembliesWithTargetPath)",
          UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)",
          UseSymboliclinksIfPossible="$(CreateSymbolicLinksForCopyFilesToOutputDirectoryIfPossible)")
        Output(ItemName="FileWrites", TaskParameter="DestinationFiles")
    // Copy COM reference wrappers, isolated COM references, COM references included by
    // native (manifest) references, native (manifest) reference files themselves.
    if '@(ReferenceComWrappersToCopyLocal)' != '' or '@(ResolvedIsolatedComModules)' != '' or '@(_DeploymentLooseManifestFile)' != '' or '@(NativeReferenceFile)' != '':
      Copy(
          DestinationFolder="$(OutDir)",
          OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)",
          Retries="$(CopyRetryCount)",
          RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)",
          SkipUnchangedFiles="$(SkipCopyUnchangedFiles)",
          SourceFiles="@(ReferenceComWrappersToCopyLocal); @(ResolvedIsolatedComModules); @(_DeploymentLooseManifestFile); @(NativeReferenceFile)",
          UseHardlinksIfPossible="$(CreateHardLinksForCopyAdditionalFilesIfPossible)",
          UseSymboliclinksIfPossible="$(CreateSymbolicLinksForCopyAdditionalFilesIfPossible)")
        Output(ItemName="FileWritesShareable", TaskParameter="DestinationFiles")
    // Copy the build product of WinMDExp.
    if '$(SkipCopyWinMDArtifact)' != 'true' and '@(WinMDExpArtifacts)' != '':
      Copy(
          DestinationFolder="$(OutDir)",
          ErrorIfLinkFails="$(ErrorIfLinkFailsForCopyFilesToOutputDirectory)",
          OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)",
          Retries="$(CopyRetryCount)",
          RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)",
          SkipUnchangedFiles="$(SkipCopyUnchangedFiles)",
          SourceFiles="@(WinMDExpArtifacts)",
          UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)",
          UseSymboliclinksIfPossible="$(CreateSymbolicLinksForCopyFilesToOutputDirectoryIfPossible)")
        Output(ItemName="FileWrites", TaskParameter="DestinationFiles")
        Output(ItemName="FinalWinmdExpArtifacts", TaskParameter="DestinationFiles")
    if '$(SkipCopyWinMDArtifact)' != 'true' and '$(_WindowsMetadataOutputPath)' != '':
      Message(
          Importance="High",
          Text="$(MSBuildProjectName) -> $([System.IO.Path]::GetFullPath('$(_WindowsMetadataOutputPath)'))")
  // ============================================================
  // _CopyFilesMarkedCopyLocal
  //
  // Copy references that are marked as "CopyLocal" and their dependencies, including .pdbs, .xmls and satellites.
  // ============================================================
  if '@(ReferenceCopyLocalPaths)' != '':
    Target _CopyFilesMarkedCopyLocal
      PropertyGroup
        // By default we're not using Hard Links to copy to the output directory, and never when building in VS
        if '$(BuildingInsideVisualStudio)' == 'true' or '$(CreateHardLinksForCopyLocalIfPossible)' == '':
          CreateHardLinksForCopyLocalIfPossible = false
        if '$(BuildingInsideVisualStudio)' == 'true' or '$(CreateSymbolicLinksForCopyLocalIfPossible)' == '':
          CreateSymbolicLinksForCopyLocalIfPossible = false
      if '$(UseCommonOutputDirectory)' != 'true':
        Copy(
            DestinationFiles="@(ReferenceCopyLocalPaths->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')",
            OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)",
            Retries="$(CopyRetryCount)",
            RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)",
            SkipUnchangedFiles="$(SkipCopyUnchangedFiles)",
            SourceFiles="@(ReferenceCopyLocalPaths)",
            UseHardlinksIfPossible="$(CreateHardLinksForCopyLocalIfPossible)",
            UseSymboliclinksIfPossible="$(CreateSymbolicLinksForCopyLocalIfPossible)")
          Output(ItemName="FileWritesShareable", TaskParameter="DestinationFiles")
          Output(ItemName="ReferencesCopiedInThisBuild", TaskParameter="CopiedFiles")
          Output(PropertyName="WroteAtLeastOneFile", TaskParameter="WroteAtLeastOneFile")
      // Record whether copy-local (possibly transitive) references were actually copied on this
      // build. When they were, projects that depend on this one must not be considered up to date.
      // The marker file that carries that signal is touched once, later, in CopyFilesToOutputDirectory
      // (which depends on this target), so the same file isn't written twice in a normal build.
      PropertyGroup
        if '@(ReferencesCopiedInThisBuild)' != '' and '$(WroteAtLeastOneFile)' == 'true':
          _CopyLocalReferencesCopiedInThisBuild = true
      ItemGroup
        FileWrites += "@(CopyUpToDateMarker)"
  // ============================================================
  // _CopySourceItemsToOutputDirectory
  // ============================================================
  Target _CopySourceItemsToOutputDirectory(
      DependsOnTargets=[
        GetCopyToOutputDirectoryItems
        _CopyOutOfDateSourceItemsToOutputDirectory
        _CopyOutOfDateSourceItemsToOutputDirectoryAlways
        _CopyDifferingSourceItemsToOutputDirectory
      ])
  // ============================================================
  // GetCopyToOutputDirectoryItems
  //
  // Get all project items that may need to be transferred to the output directory.
  // This includes baggage items from transitively referenced projects.
  //
  // As of 17.0, content items are copied transitively by default.
  // Set `MSBuildCopyContentTransitively` to false to opt out.
  // See https://github.com/dotnet/msbuild/pull/6622 for more info.
  // ============================================================
  PropertyGroup
    _TargetsThatPrepareProjectReferences = _SplitProjectReferencesByFileExistence
    // GetCopyToOutputDirectoryItems depends on an unspecified dependency _SplitProjectReferencesByFileExistence -> AssignProjectConfiguration (https://github.com/dotnet/msbuild/issues/4677).
    // When the unspecified dependency does not happen by accident, content copying is only 1 level deep instead of transitive.
    // This target enforces the dependency.
    if '$(MSBuildCopyContentTransitively)' == '':
      MSBuildCopyContentTransitively = true
    if '$(MSBuildCopyContentTransitively)' == 'true':
      _TargetsThatPrepareProjectReferences =
        | AssignProjectConfiguration;
        |       _SplitProjectReferencesByFileExistence
    GetCopyToOutputDirectoryItemsDependsOn =
      | $(GetCopyToOutputDirectoryItemsDependsOn);
      |       AssignTargetPaths;
      |       $(_TargetsThatPrepareProjectReferences);
      |       _GetProjectReferenceTargetFrameworkProperties;
      |       _PopulateCommonStateForGetCopyToOutputDirectoryItems
    // Mitigation for https://github.com/dotnet/msbuild/issues/4677
    // When MSBuildCopyContentTransitively == true, all content copying is transitive.
    // When MSBuildCopyContentTransitively == false, content copying is 1 level deep.
    // When MSBuildCopyContentTransitively != {true, false}, the legacy behaviour in https://github.com/dotnet/msbuild/issues/4677 manifests.
    _RecursiveTargetForContentCopying = GetCopyToOutputDirectoryItems
    // Enforce 1 level deep content copying by replacing the recursive content target with the target that retrieves the content for the current project only.
    if '$(MSBuildCopyContentTransitively)' == 'false':
      _RecursiveTargetForContentCopying = _GetCopyToOutputDirectoryItemsFromThisProject
  // ============================================================
  // ProjectReferenceTargets for Static Graph
  //
  // Define the project-to-project calling patterns for graph builds.
  // These items tell the static graph which targets a project calls
  // on its referenced projects for Build, Clean, and Rebuild.
  //
  // These must accurately describe the MSBuild task calls in:
  // - ResolveProjectReferences (Build / GetTargetPath + GetNativeManifest)
  // - GetCopyToOutputDirectoryItems (_RecursiveTargetForContentCopying)
  // - CleanReferencedProjects (Clean)
  // - Rebuild (Clean + Build)
  //
  // SDKs can extend these by appending to the ProjectReferenceTargetsFor*
  // properties before this evaluation, or by adding additional
  // ProjectReferenceTargets items after import.
  // ============================================================
  // Properties for extension of ProjectReferenceTargets.
  // Append any current value which may have been provided in a Directory.Build.props since the intent was likely to append, not prepend.
  if '$(IsGraphBuild)' == 'true' and '$(IsCrossTargetingBuild)' != 'true':
    PropertyGroup
      // Empty case is for builds which do not import the target files that set BuildProjectReferences
      if '$(BuildProjectReferences)' == '' or '$(BuildProjectReferences)' == 'true':
        _MainReferenceTargetForBuild = .projectReferenceTargetsOrDefaultTargets
      if '$(_MainReferenceTargetForBuild)' == '':
        _MainReferenceTargetForBuild = GetTargetPath
      ProjectReferenceTargetsForBuild = $(_MainReferenceTargetForBuild);GetNativeManifest;$(_RecursiveTargetForContentCopying);$(ProjectReferenceTargetsForBuild)
  // Cross-targeting outer builds define their protocol in Microsoft.Common.CrossTargeting.targets
  if '$(IsGraphBuild)' == 'true':
    PropertyGroup
      ProjectReferenceTargetsForClean = Clean;$(ProjectReferenceTargetsForClean)
      ProjectReferenceTargetsForRebuild = $(ProjectReferenceTargetsForClean);$(ProjectReferenceTargetsForBuild);$(ProjectReferenceTargetsForRebuild)
  if '$(IsGraphBuild)' == 'true':
    ItemGroup
      if '$(ProjectReferenceTargetsForBuildInOuterBuild)' != '':
        ProjectReferenceTargets += "Build"(
            OuterBuild="true",
            Targets="$(ProjectReferenceTargetsForBuildInOuterBuild)")
      if '$(IsCrossTargetingBuild)' != 'true':
        ProjectReferenceTargets += "Build"(
            OuterBuild="true",
            SkipNonexistentTargets="true",
            Targets="GetTargetFrameworks")
      if '$(ProjectReferenceTargetsForBuild)' != '':
        ProjectReferenceTargets += "Build"(Targets="$(ProjectReferenceTargetsForBuild)")
      if '$(ProjectReferenceTargetsForCleanInOuterBuild)' != '':
        ProjectReferenceTargets += "Clean"(
            OuterBuild="true",
            Targets="$(ProjectReferenceTargetsForCleanInOuterBuild)")
      if '$(IsCrossTargetingBuild)' != 'true':
        ProjectReferenceTargets += "Clean"(
            OuterBuild="true",
            SkipNonexistentTargets="true",
            Targets="GetTargetFrameworks")
      if '$(ProjectReferenceTargetsForClean)' != '':
        ProjectReferenceTargets += "Clean"(Targets="$(ProjectReferenceTargetsForClean)")
      // Note: SkipNonexistentTargets="true" on the following three items means that an outer build node's call to its existent
      // GetTargetFrameworks target will fail if its inner build nodes don't define GetTargetFrameworksWithPlatformForSingleTargetFramework.
      // This is necessary since the P2P protocol cannot express the targets called from the outer build to the inner build.
      if '$(IsCrossTargetingBuild)' != 'true':
        ProjectReferenceTargets += "Build"(
            SkipNonexistentTargets="true",
            Targets="GetTargetFrameworksWithPlatformForSingleTargetFramework")
      if '$(IsCrossTargetingBuild)' != 'true':
        ProjectReferenceTargets += "Clean"(
            SkipNonexistentTargets="true",
            Targets="GetTargetFrameworksWithPlatformForSingleTargetFramework")
      if '$(IsCrossTargetingBuild)' != 'true':
        ProjectReferenceTargets += "Rebuild"(
            SkipNonexistentTargets="true",
            Targets="GetTargetFrameworksWithPlatformForSingleTargetFramework")
      if '$(ProjectReferenceTargetsForRebuild)' != '':
        ProjectReferenceTargets += "Rebuild"(Targets="$(ProjectReferenceTargetsForRebuild)")
  Target _PopulateCommonStateForGetCopyToOutputDirectoryItems
    // In the general case, clients need very little of the metadata which is generated by invoking this target on this project and its children.  For those
    // cases, we can immediately discard the unwanted metadata, reducing memory usage, particularly in very large and interconnected systems of projects.
    // However, if some client does require the original functionality, it is sufficient to set MSBuildDisableGetCopyToOutputDirectoryItemsOptimization to
    // a non-empty value and the original behavior will be restored.
    if '$(MSBuildDisableGetCopyToOutputDirectoryItemsOptimization)' == '':
      PropertyGroup
        _GCTODIKeepDuplicates = false
        _GCTODIKeepMetadata = CopyToOutputDirectory;TargetPath
  Target _GetCopyToOutputDirectoryItemsFromTransitiveProjectReferences(
      DependsOnTargets=[
        _PopulateCommonStateForGetCopyToOutputDirectoryItems
        _AddOutputPathToGlobalPropertiesToRemove
      ],
      Returns="@(_CopyToOutputDirectoryTransitiveItems)")
    // Get items from child projects first.
    if '@(_MSBuildProjectReferenceExistent)' != '' and '$(_GetChildProjectCopyToOutputDirectoryItems)' == 'true' and '%(_MSBuildProjectReferenceExistent.Private)' != 'false' and '$(UseCommonOutputDirectory)' != 'true':
      MSBuild(
          BuildInParallel="$(BuildInParallel)",
          ContinueOnError="$(ContinueOnError)",
          Projects="@(_MSBuildProjectReferenceExistent)",
          Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform); %(_MSBuildProjectReferenceExistent.SetTargetFramework)",
          RemoveProperties="%(_MSBuildProjectReferenceExistent.GlobalPropertiesToRemove)$(_GlobalPropertiesToRemoveFromProjectReferences)",
          SkipNonexistentTargets="true",
          Targets="$(_RecursiveTargetForContentCopying)")
        Output(ItemName="_AllChildProjectItemsWithTargetPath", TaskParameter="TargetOutputs")
    // Target outputs must be full paths because they will be consumed by a different project.
    ItemGroup
      if '%(_AllChildProjectItemsWithTargetPath.CopyToOutputDirectory)'=='Always':
        _CopyToOutputDirectoryTransitiveItems += "@(_AllChildProjectItemsWithTargetPath->'%(FullPath)')"(
            KeepDuplicates=" '$(_GCTODIKeepDuplicates)' != 'false' ",
            KeepMetadata="$(_GCTODIKeepMetadata)")
      if '%(_AllChildProjectItemsWithTargetPath.CopyToOutputDirectory)'=='PreserveNewest':
        _CopyToOutputDirectoryTransitiveItems += "@(_AllChildProjectItemsWithTargetPath->'%(FullPath)')"(
            KeepDuplicates=" '$(_GCTODIKeepDuplicates)' != 'false' ",
            KeepMetadata="$(_GCTODIKeepMetadata)")
      if '%(_AllChildProjectItemsWithTargetPath.CopyToOutputDirectory)'=='IfDifferent':
        _CopyToOutputDirectoryTransitiveItems += "@(_AllChildProjectItemsWithTargetPath->'%(FullPath)')"(
            KeepDuplicates=" '$(_GCTODIKeepDuplicates)' != 'false' ",
            KeepMetadata="$(_GCTODIKeepMetadata)")
    // Remove items which we will never again use - they just sit around taking up memory otherwise
    ItemGroup
      _AllChildProjectItemsWithTargetPath -= "@(_AllChildProjectItemsWithTargetPath)"
    // Copy paste _GetCopyToOutputDirectoryItemsFromThisProject but keep the items that came from other projects via ProjectReference's OutputItemType metadata
    ItemGroup
      if '%(ContentWithTargetPath.CopyToOutputDirectory)'=='Always' AND '%(ContentWithTargetPath.MSBuildSourceProjectFile)'!='':
        _CopyToOutputDirectoryTransitiveItems += "@(ContentWithTargetPath->'%(FullPath)')"(
            KeepMetadata="$(_GCTODIKeepMetadata)")
      if '%(ContentWithTargetPath.CopyToOutputDirectory)'=='PreserveNewest' AND '%(ContentWithTargetPath.MSBuildSourceProjectFile)'!='':
        _CopyToOutputDirectoryTransitiveItems += "@(ContentWithTargetPath->'%(FullPath)')"(
            KeepMetadata="$(_GCTODIKeepMetadata)")
      if '%(ContentWithTargetPath.CopyToOutputDirectory)'=='IfDifferent' AND '%(ContentWithTargetPath.MSBuildSourceProjectFile)'!='':
        _CopyToOutputDirectoryTransitiveItems += "@(ContentWithTargetPath->'%(FullPath)')"(
            KeepMetadata="$(_GCTODIKeepMetadata)")
    ItemGroup
      if '%(EmbeddedResource.CopyToOutputDirectory)'=='Always' AND '%(EmbeddedResource.MSBuildSourceProjectFile)'!='':
        _CopyToOutputDirectoryTransitiveItems += "@(EmbeddedResource->'%(FullPath)')"(
            KeepMetadata="$(_GCTODIKeepMetadata)")
      if '%(EmbeddedResource.CopyToOutputDirectory)'=='PreserveNewest' AND '%(EmbeddedResource.MSBuildSourceProjectFile)'!='':
        _CopyToOutputDirectoryTransitiveItems += "@(EmbeddedResource->'%(FullPath)')"(
            KeepMetadata="$(_GCTODIKeepMetadata)")
      if '%(EmbeddedResource.CopyToOutputDirectory)'=='IfDifferent' AND '%(EmbeddedResource.MSBuildSourceProjectFile)'!='':
        _CopyToOutputDirectoryTransitiveItems += "@(EmbeddedResource->'%(FullPath)')"(
            KeepMetadata="$(_GCTODIKeepMetadata)")
    ItemGroup
      if ('%(Compile.CopyToOutputDirectory)'=='Always' or '%(Compile.CopyToOutputDirectory)'=='PreserveNewest' or '%(Compile.CopyToOutputDirectory)'=='IfDifferent') AND '%(Compile.MSBuildSourceProjectFile)'!='':
        _CompileItemsToCopy += "@(Compile->'%(FullPath)')"
    AssignTargetPath(Files="@(_CompileItemsToCopy)", RootFolder="$(MSBuildProjectDirectory)")
      Output(ItemName="_CompileItemsToCopyWithTargetPath", TaskParameter="AssignedFiles")
    ItemGroup
      if '%(_CompileItemsToCopyWithTargetPath.CopyToOutputDirectory)'=='Always':
        _CopyToOutputDirectoryTransitiveItems += "@(_CompileItemsToCopyWithTargetPath)"(
            KeepMetadata="$(_GCTODIKeepMetadata)")
      if '%(_CompileItemsToCopyWithTargetPath.CopyToOutputDirectory)'=='PreserveNewest':
        _CopyToOutputDirectoryTransitiveItems += "@(_CompileItemsToCopyWithTargetPath)"(
            KeepMetadata="$(_GCTODIKeepMetadata)")
      if '%(_CompileItemsToCopyWithTargetPath.CopyToOutputDirectory)'=='IfDifferent':
        _CopyToOutputDirectoryTransitiveItems += "@(_CompileItemsToCopyWithTargetPath)"(
            KeepMetadata="$(_GCTODIKeepMetadata)")
    ItemGroup
      if '%(_NoneWithTargetPath.CopyToOutputDirectory)'=='Always' AND '%(_NoneWithTargetPath.MSBuildSourceProjectFile)'!='':
        _CopyToOutputDirectoryTransitiveItems += "@(_NoneWithTargetPath->'%(FullPath)')"(
            KeepMetadata="$(_GCTODIKeepMetadata)")
      if '%(_NoneWithTargetPath.CopyToOutputDirectory)'=='PreserveNewest' AND '%(_NoneWithTargetPath.MSBuildSourceProjectFile)'!='':
        _CopyToOutputDirectoryTransitiveItems += "@(_NoneWithTargetPath->'%(FullPath)')"(
            KeepMetadata="$(_GCTODIKeepMetadata)")
      if '%(_NoneWithTargetPath.CopyToOutputDirectory)'=='IfDifferent' AND '%(_NoneWithTargetPath.MSBuildSourceProjectFile)'!='':
        _CopyToOutputDirectoryTransitiveItems += "@(_NoneWithTargetPath->'%(FullPath)')"(
            KeepMetadata="$(_GCTODIKeepMetadata)")
  Target _GetCopyToOutputDirectoryItemsFromThisProject(
      DependsOnTargets=[
        AssignTargetPaths
        _PopulateCommonStateForGetCopyToOutputDirectoryItems
      ],
      Returns="@(_ThisProjectItemsToCopyToOutputDirectory)")
    ItemGroup
      if '%(ContentWithTargetPath.CopyToOutputDirectory)'=='Always' AND '%(ContentWithTargetPath.MSBuildSourceProjectFile)'=='':
        _ThisProjectItemsToCopyToOutputDirectory += "@(ContentWithTargetPath->'%(FullPath)')"(
            KeepMetadata="$(_GCTODIKeepMetadata)")
      if '%(ContentWithTargetPath.CopyToOutputDirectory)'=='PreserveNewest' AND '%(ContentWithTargetPath.MSBuildSourceProjectFile)'=='':
        _ThisProjectItemsToCopyToOutputDirectory += "@(ContentWithTargetPath->'%(FullPath)')"(
            KeepMetadata="$(_GCTODIKeepMetadata)")
      if '%(ContentWithTargetPath.CopyToOutputDirectory)'=='IfDifferent' AND '%(ContentWithTargetPath.MSBuildSourceProjectFile)'=='':
        _ThisProjectItemsToCopyToOutputDirectory += "@(ContentWithTargetPath->'%(FullPath)')"(
            KeepMetadata="$(_GCTODIKeepMetadata)")
    ItemGroup
      if '%(EmbeddedResource.CopyToOutputDirectory)'=='Always' AND '%(EmbeddedResource.MSBuildSourceProjectFile)'=='':
        _ThisProjectItemsToCopyToOutputDirectory += "@(EmbeddedResource->'%(FullPath)')"(
            KeepMetadata="$(_GCTODIKeepMetadata)")
      if '%(EmbeddedResource.CopyToOutputDirectory)'=='PreserveNewest' AND '%(EmbeddedResource.MSBuildSourceProjectFile)'=='':
        _ThisProjectItemsToCopyToOutputDirectory += "@(EmbeddedResource->'%(FullPath)')"(
            KeepMetadata="$(_GCTODIKeepMetadata)")
      if '%(EmbeddedResource.CopyToOutputDirectory)'=='IfDifferent' AND '%(EmbeddedResource.MSBuildSourceProjectFile)'=='':
        _ThisProjectItemsToCopyToOutputDirectory += "@(EmbeddedResource->'%(FullPath)')"(
            KeepMetadata="$(_GCTODIKeepMetadata)")
    ItemGroup
      if ('%(Compile.CopyToOutputDirectory)'=='Always' or '%(Compile.CopyToOutputDirectory)'=='PreserveNewest' or '%(Compile.CopyToOutputDirectory)'=='IfDifferent') AND '%(Compile.MSBuildSourceProjectFile)'=='':
        _CompileItemsToCopy += "@(Compile->'%(FullPath)')"
    AssignTargetPath(Files="@(_CompileItemsToCopy)", RootFolder="$(MSBuildProjectDirectory)")
      Output(ItemName="_CompileItemsToCopyWithTargetPath", TaskParameter="AssignedFiles")
    ItemGroup
      if '%(_CompileItemsToCopyWithTargetPath.CopyToOutputDirectory)'=='Always':
        _ThisProjectItemsToCopyToOutputDirectory += "@(_CompileItemsToCopyWithTargetPath)"(
            KeepMetadata="$(_GCTODIKeepMetadata)")
      if '%(_CompileItemsToCopyWithTargetPath.CopyToOutputDirectory)'=='PreserveNewest':
        _ThisProjectItemsToCopyToOutputDirectory += "@(_CompileItemsToCopyWithTargetPath)"(
            KeepMetadata="$(_GCTODIKeepMetadata)")
      if '%(_CompileItemsToCopyWithTargetPath.CopyToOutputDirectory)'=='IfDifferent':
        _ThisProjectItemsToCopyToOutputDirectory += "@(_CompileItemsToCopyWithTargetPath)"(
            KeepMetadata="$(_GCTODIKeepMetadata)")
    ItemGroup
      if '%(_NoneWithTargetPath.CopyToOutputDirectory)'=='Always' AND '%(_NoneWithTargetPath.MSBuildSourceProjectFile)'=='':
        _ThisProjectItemsToCopyToOutputDirectory += "@(_NoneWithTargetPath->'%(FullPath)')"(
            KeepMetadata="$(_GCTODIKeepMetadata)")
      if '%(_NoneWithTargetPath.CopyToOutputDirectory)'=='PreserveNewest' AND '%(_NoneWithTargetPath.MSBuildSourceProjectFile)'=='':
        _ThisProjectItemsToCopyToOutputDirectory += "@(_NoneWithTargetPath->'%(FullPath)')"(
            KeepMetadata="$(_GCTODIKeepMetadata)")
      if '%(_NoneWithTargetPath.CopyToOutputDirectory)'=='IfDifferent' AND '%(_NoneWithTargetPath.MSBuildSourceProjectFile)'=='':
        _ThisProjectItemsToCopyToOutputDirectory += "@(_NoneWithTargetPath->'%(FullPath)')"(
            KeepMetadata="$(_GCTODIKeepMetadata)")
  Target GetCopyToOutputDirectoryItems(
      DependsOnTargets="$(GetCopyToOutputDirectoryItemsDependsOn)",
      KeepDuplicateOutputs=" '$(MSBuildDisableGetCopyToOutputDirectoryItemsOptimization)' == '' ",
      Returns="@(AllItemsFullPathWithTargetPath)")
    // Compose the content items as the union between transitive content items and content items from this project.
    // Use CallTarget to avoid breaking targets that hook right before GetCopyToOutputDirectoryItems but expect to run after _GetCopyToOutputDirectoryItemsFromTransitiveProjectReferences and _GetCopyToOutputDirectoryItemsFromThisProject
    CallTarget(Targets="_GetCopyToOutputDirectoryItemsFromTransitiveProjectReferences")
      Output(ItemName="_TransitiveItemsToCopyToOutputDirectory", TaskParameter="TargetOutputs")
    CallTarget(Targets="_GetCopyToOutputDirectoryItemsFromThisProject")
      Output(ItemName="_ThisProjectItemsToCopyToOutputDirectory", TaskParameter="TargetOutputs")
    if '$(CopyConflictingTransitiveContent)' == 'false':
      ItemGroup
        _TransitiveItemsToCopyToOutputDirectory -= "@(_ThisProjectItemsToCopyToOutputDirectory)"(
            MatchOnMetadata="TargetPath",
            MatchOnMetadataOptions="PathLike")
    ItemGroup
      if '%(_TransitiveItemsToCopyToOutputDirectory.CopyToOutputDirectory)'=='Always':
        _TransitiveItemsToCopyToOutputDirectoryAlways += "@(_TransitiveItemsToCopyToOutputDirectory->'%(FullPath)')"(
            KeepDuplicates=" '$(_GCTODIKeepDuplicates)' != 'false' ",
            KeepMetadata="$(_GCTODIKeepMetadata)")
      if '%(_TransitiveItemsToCopyToOutputDirectory.CopyToOutputDirectory)'=='PreserveNewest':
        _TransitiveItemsToCopyToOutputDirectoryPreserveNewest += "@(_TransitiveItemsToCopyToOutputDirectory->'%(FullPath)')"(
            KeepDuplicates=" '$(_GCTODIKeepDuplicates)' != 'false' ",
            KeepMetadata="$(_GCTODIKeepMetadata)")
      if '%(_TransitiveItemsToCopyToOutputDirectory.CopyToOutputDirectory)'=='IfDifferent':
        _TransitiveItemsToCopyToOutputDirectoryIfDifferent += "@(_TransitiveItemsToCopyToOutputDirectory->'%(FullPath)')"(
            KeepDuplicates=" '$(_GCTODIKeepDuplicates)' != 'false' ",
            KeepMetadata="$(_GCTODIKeepMetadata)")
      if '%(_ThisProjectItemsToCopyToOutputDirectory.CopyToOutputDirectory)'=='Always':
        _ThisProjectItemsToCopyToOutputDirectoryAlways += "@(_ThisProjectItemsToCopyToOutputDirectory->'%(FullPath)')"(
            KeepDuplicates=" '$(_GCTODIKeepDuplicates)' != 'false' ",
            KeepMetadata="$(_GCTODIKeepMetadata)")
      if '%(_ThisProjectItemsToCopyToOutputDirectory.CopyToOutputDirectory)'=='PreserveNewest':
        _ThisProjectItemsToCopyToOutputDirectoryPreserveNewest += "@(_ThisProjectItemsToCopyToOutputDirectory->'%(FullPath)')"(
            KeepDuplicates=" '$(_GCTODIKeepDuplicates)' != 'false' ",
            KeepMetadata="$(_GCTODIKeepMetadata)")
      if '%(_ThisProjectItemsToCopyToOutputDirectory.CopyToOutputDirectory)'=='IfDifferent':
        _ThisProjectItemsToCopyToOutputDirectoryIfDifferent += "@(_ThisProjectItemsToCopyToOutputDirectory->'%(FullPath)')"(
            KeepDuplicates=" '$(_GCTODIKeepDuplicates)' != 'false' ",
            KeepMetadata="$(_GCTODIKeepMetadata)")
      // Append the items from this project last so that they will be copied last.
      _SourceItemsToCopyToOutputDirectoryAlways += "@(_TransitiveItemsToCopyToOutputDirectoryAlways);@(_ThisProjectItemsToCopyToOutputDirectoryAlways)"
      _SourceItemsToCopyToOutputDirectory += "@(_TransitiveItemsToCopyToOutputDirectoryPreserveNewest);@(_ThisProjectItemsToCopyToOutputDirectoryPreserveNewest)"
      _SourceItemsToCopyToOutputDirectoryIfDifferent += "@(_TransitiveItemsToCopyToOutputDirectoryIfDifferent);@(_ThisProjectItemsToCopyToOutputDirectoryIfDifferent)"
      AllItemsFullPathWithTargetPath += "@(_SourceItemsToCopyToOutputDirectoryAlways->'%(FullPath)');@(_SourceItemsToCopyToOutputDirectory->'%(FullPath)');@(_SourceItemsToCopyToOutputDirectoryIfDifferent->'%(FullPath)')"
      // Empty intermediate items to release memory
      _TransitiveItemsToCopyToOutputDirectoryAlways -= "@(_TransitiveItemsToCopyToOutputDirectoryAlways)"
      _TransitiveItemsToCopyToOutputDirectoryPreserveNewest -= "@(_TransitiveItemsToCopyToOutputDirectoryPreserveNewest)"
      _TransitiveItemsToCopyToOutputDirectoryIfDifferent -= "@(_TransitiveItemsToCopyToOutputDirectoryIfDifferent)"
      _ThisProjectItemsToCopyToOutputDirectoryAlways -= "@(_ThisProjectItemsToCopyToOutputDirectoryAlways)"
      _ThisProjectItemsToCopyToOutputDirectoryPreserveNewest -= "@(_ThisProjectItemsToCopyToOutputDirectoryPreserveNewest)"
      _ThisProjectItemsToCopyToOutputDirectory -= "@(_ThisProjectItemsToCopyToOutputDirectory)"
      _ThisProjectItemsToCopyToOutputDirectoryIfDifferent -= "@(_ThisProjectItemsToCopyToOutputDirectoryIfDifferent)"
  // ============================================================
  // GetCopyToPublishDirectoryItems
  //
  // Default implementation of GetCopyToPublishDirectoryItems for projects that do not
  // use Microsoft.NET.Sdk. It simply returns whatever GetCopyToOutputDirectoryItems
  // does with CopyToPublishDirectory implied  by CopyToOutputDirectory, which is the
  // same as Microsoft.NET.Sdk default when its CopyToPublishDirectory is not used.
  //
  // Microsoft.NET.Sdk projects  will override this to allow the publish output to be
  // customized independently from the build output.
  //
  // Having a default implementation here allows the Microsoft.NET.Sdk Publish target
  // to work when a Microsoft.NET.Sdk-based project references a non-Microsoft.NET.Sdk-based
  // project.
  // ============================================================
  Target GetCopyToPublishDirectoryItems(
      DependsOnTargets="GetCopyToOutputDirectoryItems",
      Returns="@(AllPublishItemsFullPathWithTargetPath)")
    ItemGroup
      AllPublishItemsFullPathWithTargetPath += "@(AllItemsFullPathWithTargetPath)"
        CopyToPublishDirectory = %(CopyToOutputDirectory)
  // ============================================================
  // _CopyOutOfDateSourceItemsToOutputDirectory
  //
  // Copy files that have the CopyToOutputDirectory attribute set to 'PreserveNewest'.
  // ============================================================
  if '@(_SourceItemsToCopyToOutputDirectory)' != '':
    Target _CopyOutOfDateSourceItemsToOutputDirectory(
        Inputs="@(_SourceItemsToCopyToOutputDirectory)",
        Outputs="@(_SourceItemsToCopyToOutputDirectory->'$(OutDir)%(TargetPath)')")
      // Not using SkipUnchangedFiles="true" because the items we pass in are already only those that have newer timestampts in the source (determined by _GetCopyToOutputDirectoryItemsFromThisProject).
      Copy(
          DestinationFiles="@(_SourceItemsToCopyToOutputDirectory->'$(OutDir)%(TargetPath)')",
          OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)",
          Retries="$(CopyRetryCount)",
          RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)",
          SourceFiles="@(_SourceItemsToCopyToOutputDirectory)",
          UseHardlinksIfPossible="$(CreateHardLinksForAdditionalFilesIfPossible)",
          UseSymboliclinksIfPossible="$(CreateSymbolicLinksForAdditionalFilesIfPossible)")
        Output(ItemName="FileWrites", TaskParameter="DestinationFiles")
  // ============================================================
  // _CopyOutOfDateSourceItemsToOutputDirectoryAlways
  //
  // Copy files that have the CopyToOutputDirectory attribute set to 'Always'.
  // ============================================================
  if '@(_SourceItemsToCopyToOutputDirectoryAlways)' != '':
    Target _CopyOutOfDateSourceItemsToOutputDirectoryAlways
      // Not using SkipUnchangedFiles="true" by default for backwards compatibility.
      PropertyGroup
        if '$(SkipUnchangedFilesOnCopyAlways)' == '':
          SkipUnchangedFilesOnCopyAlways = false
      Copy(
          DestinationFiles="@(_SourceItemsToCopyToOutputDirectoryAlways->'$(OutDir)%(TargetPath)')",
          OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)",
          Retries="$(CopyRetryCount)",
          RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)",
          SkipUnchangedFiles="$(SkipUnchangedFilesOnCopyAlways)",
          SourceFiles="@(_SourceItemsToCopyToOutputDirectoryAlways)",
          UseHardlinksIfPossible="$(CreateHardLinksForAdditionalFilesIfPossible)",
          UseSymboliclinksIfPossible="$(CreateSymbolicLinksForAdditionalFilesIfPossible)")
        Output(ItemName="FileWrites", TaskParameter="DestinationFiles")
  // ============================================================
  // _CopyDifferingSourceItemsToOutputDirectory
  //
  // Copy files that have the CopyToOutputDirectory attribute set to 'IfDifferent'.
  // ============================================================
  if '@(_SourceItemsToCopyToOutputDirectoryIfDifferent)' != '':
    Target _CopyDifferingSourceItemsToOutputDirectory
      // Using SkipUnchangedFiles="true" because we want only differing files.
      Copy(
          DestinationFiles="@(_SourceItemsToCopyToOutputDirectoryIfDifferent->'$(OutDir)%(TargetPath)')",
          OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)",
          Retries="$(CopyRetryCount)",
          RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)",
          SkipUnchangedFiles="true",
          SourceFiles="@(_SourceItemsToCopyToOutputDirectoryIfDifferent)",
          UseHardlinksIfPossible="$(CreateHardLinksForAdditionalFilesIfPossible)",
          UseSymboliclinksIfPossible="$(CreateSymbolicLinksForAdditionalFilesIfPossible)")
        Output(ItemName="FileWrites", TaskParameter="DestinationFiles")
  // ============================================================
  // _CopyAppConfigFile
  //
  // Copy the application config file.
  // ============================================================
  if '@(AppConfigWithTargetPath)' != '':
    Target _CopyAppConfigFile(
        Inputs="@(AppConfigWithTargetPath)",
        Outputs="@(AppConfigWithTargetPath->'$(OutDir)%(TargetPath)')")
      // Copy the application's .config file, if any.
      // Not using SkipUnchangedFiles="true" because the application may want to change
      // the app.config and not have an incremental build replace it.
      Copy(
          DestinationFiles="@(AppConfigWithTargetPath->'$(OutDir)%(TargetPath)')",
          OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)",
          Retries="$(CopyRetryCount)",
          RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)",
          SourceFiles="@(AppConfigWithTargetPath)",
          UseHardlinksIfPossible="$(CreateHardLinksForAdditionalFilesIfPossible)",
          UseSymboliclinksIfPossible="$(CreateSymbolicLinksForAdditionalFilesIfPossible)")
        Output(ItemName="FileWrites", TaskParameter="DestinationFiles")
  // ================================================================
  // _CopyManifestFiles
  // ================================================================
  //
  // Copy the built manifests (.exe.manifest, .application/.xbap) to the final directory.
  if '$(_DeploymentCopyApplicationManifest)'=='true' or '$(GenerateClickOnceManifests)'=='true':
    Target _CopyManifestFiles(DependsOnTargets="PrepareForBuild")
      if '$(GenerateClickOnceManifests)'=='true' or '$(_DeploymentCopyApplicationManifest)'=='true':
        Copy(
            DestinationFolder="$(OutDir)",
            OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)",
            Retries="$(CopyRetryCount)",
            RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)",
            SkipUnchangedFiles="$(SkipCopyUnchangedFiles)",
            SourceFiles="@(ApplicationManifest)",
            UseHardlinksIfPossible="$(CreateHardLinksForAdditionalFilesIfPossible)",
            UseSymboliclinksIfPossible="$(CreateSymbolicLinksForAdditionalFilesIfPossible)")
          Output(ItemName="_DeploymentMainApplicationManifest", TaskParameter="DestinationFiles")
          Output(ItemName="FileWrites", TaskParameter="DestinationFiles")
      if '$(_DeploymentCopyApplicationManifest)'=='true':
        Message(
            Importance="Normal",
            Text="$(MSBuildProjectName) -> @(_DeploymentMainApplicationManifest->'%(FullPath)')")
      if '$(GenerateClickOnceManifests)'=='true':
        Copy(
            DestinationFolder="$(OutDir)",
            OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)",
            Retries="$(CopyRetryCount)",
            RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)",
            SkipUnchangedFiles="$(SkipCopyUnchangedFiles)",
            SourceFiles="@(DeployManifest)",
            UseHardlinksIfPossible="$(CreateHardLinksForAdditionalFilesIfPossible)",
            UseSymboliclinksIfPossible="$(CreateSymbolicLinksForAdditionalFilesIfPossible)")
          Output(ItemName="_DeploymentMainDeployManifest", TaskParameter="DestinationFiles")
          Output(ItemName="FileWrites", TaskParameter="DestinationFiles")
      if '$(GenerateClickOnceManifests)'=='true':
        Message(
            Importance="Normal",
            Text="$(MSBuildProjectName) -> @(_DeploymentMainDeployManifest->'%(FullPath)')")
  // ================================================================
  // _CheckForCompileOutputs
  //
  // Checks each file output from the main "Compile" target to make sure they really exist.
  // If they do, then record them in the clean cache.
  // ============================================================
  Target _CheckForCompileOutputs
    // Record the main compile outputs.
    ItemGroup
      if Exists('@(IntermediateAssembly)'):
        FileWrites += "@(IntermediateAssembly)"
      if '$(ProduceReferenceAssembly)' == 'true' and Exists('@(IntermediateRefAssembly)'):
        FileWrites += "@(IntermediateRefAssembly)"
    // Record the .xml if one was produced.
    PropertyGroup
      if !Exists('@(DocFileItem)'):
        _DocumentationFileProduced = false
    ItemGroup
      if '$(_DocumentationFileProduced)'=='true':
        FileWrites += "@(DocFileItem)"
    // Record the .pdb if one was produced.
    PropertyGroup
      if !Exists('@(_DebugSymbolsIntermediatePath)'):
        _DebugSymbolsProduced = false
    ItemGroup
      if '$(_DebugSymbolsProduced)'=='true':
        FileWrites += "@(_DebugSymbolsIntermediatePath)"
  // ============================================================
  // _SGenCheckForOutputs
  //
  // Checks each file output from the "GenerateSerializationAssemblies" target to make sure they really exist.
  // If they do, then record them in the clean cache.
  // ============================================================
  if '$(_SGenGenerateSerializationAssembliesConfig)' == 'On' or ('@(WebReferenceUrl)'!='' and '$(_SGenGenerateSerializationAssembliesConfig)' == 'Auto'):
    Target _SGenCheckForOutputs
      // Record the serializer .dll if one was produced.
      PropertyGroup
        if Exists('$(IntermediateOutputPath)$(_SGenDllName)'):
          _SGenDllCreated = true
      ItemGroup
        if Exists('$(IntermediateOutputPath)$(_SGenDllName)'):
          FileWrites += "$(IntermediateOutputPath)$(_SGenDllName)"
  // ***********************************************************************************************
  // ***********************************************************************************************
  // UnmanagedRegistration Section
  // ***********************************************************************************************
  // ***********************************************************************************************
  // ============================================================
  // UnmanagedRegistration
  //
  // Registers the main assembly for COM interop.
  // ============================================================
  PropertyGroup
    UnmanagedRegistrationDependsOn
  if '$(RegisterForComInterop)'=='true' and '$(OutputType)'=='library':
    Target UnmanagedRegistration(DependsOnTargets="$(UnmanagedRegistrationDependsOn)")
      PropertyGroup
        if '$(RegisterAssemblyMSBuildArchitecture)' == '':
          RegisterAssemblyMSBuildArchitecture = $(PlatformTargetAsMSBuildArchitecture)
      if '$(TargetFrameworkAsMSBuildRuntime)' != '' and '$(RegisterAssemblyMSBuildArchitecture)' != '':
        PropertyGroup
          // Falling back to the current runtime if we are targeting CLR2 and the task host doesn't exist will lead to
          // incorrect behavior in some cases, but it's the same incorrect behavior as Visual Studio 2010, and thus better
          // than causing build breaks on upgrade to Win8 the way not doing so would.  For more details, see the
          // corresponding comment in GenerateResource.
          if '$(RegisterAssemblyMSBuildRuntime)' == '' and $([MSBuild]::DoesTaskHostExist(`$(TargetFrameworkAsMSBuildRuntime)`, `$(RegisterAssemblyMSBuildArchitecture)`)):
            RegisterAssemblyMSBuildRuntime = $(TargetFrameworkAsMSBuildRuntime)
          // If the targeted runtime doesn't exist, fall back to current
          if '$(RegisterAssemblyMSBuildRuntime)' == '':
            RegisterAssemblyMSBuildRuntime = CurrentRuntime
      if !Exists('@(_UnmanagedRegistrationCache)'):
        RegisterAssembly(
            Assemblies="@(_OutputPathItem->'%(FullPath)$(TargetFileName)')",
            AssemblyListFile="@(_UnmanagedRegistrationCache)",
            CreateCodeBase="true",
            MSBuildArchitecture="$(RegisterAssemblyMSBuildArchitecture)",
            MSBuildRuntime="$(RegisterAssemblyMSBuildRuntime)",
            TypeLibFiles="@(_OutputPathItem->'%(FullPath)$(TargetName).tlb')")
      ItemGroup
        FileWrites += "@(_OutputPathItem->'%(FullPath)$(TargetName).tlb')"
  // ***********************************************************************************************
  // ***********************************************************************************************
  // IncrementalClean Section
  // ***********************************************************************************************
  // ***********************************************************************************************
  // ============================================================
  // IncrementalClean
  //
  // Remove files that were produced in a prior build but weren't produced in the current build.
  // The reason is that if, for example, the name of the .exe has changed we want to delete the
  // old copy.
  //
  // Leave the Clean cache file containing only the files produced in the current build.
  // ============================================================
  Target IncrementalClean(
      DependsOnTargets=[
        $(IncrementalCleanDependsOn)
        _CleanGetCurrentAndPriorFileWrites
      ])
    // Subtract list of files produced in prior builds from list of files produced in this build.
    ItemGroup
      _CleanOrphanFileWrites += "@(_CleanPriorFileWrites)"(Exclude="@(_CleanCurrentFileWrites)")
    // Find all files in the final output directory.
    FindUnderPath(Files="@(_CleanOrphanFileWrites)", Path="$(OutDir)")
      Output(ItemName="_CleanOrphanFileWritesInOutput", TaskParameter="InPath")
    // Find all files in the intermediate output directory.
    FindUnderPath(Files="@(_CleanOrphanFileWrites)", Path="$(IntermediateOutputPath)")
      Output(ItemName="_CleanOrphanFileWritesInIntermediate", TaskParameter="InPath")
    // Delete the orphaned files.
    Delete(
        Files="@(_CleanOrphanFileWritesInIntermediate);@(_CleanOrphanFileWritesInOutput)",
        TreatErrorsAsWarnings="true")
      Output(ItemName="_CleanOrphanFilesDeleted", TaskParameter="DeletedFiles")
    // Create a list of everything that wasn't deleted or was outside
    // the current final output and intermediate output directories.
    ItemGroup
      _CleanRemainingFileWritesAfterIncrementalClean += "@(_CleanPriorFileWrites);@(_CleanCurrentFileWrites)"(
          Exclude="@(_CleanOrphanFilesDeleted)")
    // Remove duplicates.
    RemoveDuplicates(Inputs="@(_CleanRemainingFileWritesAfterIncrementalClean)")
      Output(
          ItemName="_CleanUniqueRemainingFileWritesAfterIncrementalClean",
          TaskParameter="Filtered")
    // Write new list of current files back to disk, replacing the existing list.
    if '@(_CleanUnfilteredPriorFileWrites)'!='@(_CleanUniqueRemainingFileWritesAfterIncrementalClean)':
      WriteLinesToFile(
          File="$(IntermediateOutputPath)$(CleanFile)",
          Lines="@(_CleanUniqueRemainingFileWritesAfterIncrementalClean)",
          Overwrite="true")
  // ============================================================
  // _CleanGetCurrentAndPriorFileWrites
  //
  // Get the list of files built in the current build and in prior builds.
  // ============================================================
  Target _CleanGetCurrentAndPriorFileWrites(
      DependsOnTargets=[
        _CheckForCompileOutputs
        _SGenCheckForOutputs
      ])
    // Read the list of files produced by a prior builds from disk.
    ReadLinesFromFile(File="$(IntermediateOutputPath)$(CleanFile)")
      Output(ItemName="_CleanUnfilteredPriorFileWrites", TaskParameter="Lines")
    // Convert the list of references to the absolute paths so we can make valid comparisons
    // across two lists
    ConvertToAbsolutePath(Paths="@(_ResolveAssemblyReferenceResolvedFiles)")
      Output(
          ItemName="_ResolveAssemblyReferenceResolvedFilesAbsolute",
          TaskParameter="AbsolutePaths")
    // Subtract any resolved assembly files from *prior* file writes because deleting
    // these would break subsequent builds because the assemblies would be unresolvable.
    ItemGroup
      _CleanPriorFileWrites += "@(_CleanUnfilteredPriorFileWrites)"(
          Exclude="@(_ResolveAssemblyReferenceResolvedFilesAbsolute)")
    PropertyGroup
      // Of shareable files, keep only those that are in the project's directory.
      // We never clean shareable files outside of the project directory because
      // the build may be to a common output directory and other projects may need
      // them.
      //
      // The default layout of projects is that everything particular to the project is
      // located under the MSBuildProjectDirectory, so it's considered safe to track/delete those.
      // The assumption was that anything outside the project's directory is shared between multiple projects
      // and should not be deleted by the Clean target.
      //
      // However, this is not always the case. The .NET SDK has a feature called Artifacts Layout
      // where project outputs are tracked in _project-specific_ locations under a root that is
      // outside of the project directory. In such cases, we need to be able to track FileWritesShareable
      // even from those locations.
      if '$(TrackFileWritesShareableOutsideOfProjectDirectory)' == '':
        TrackFileWritesShareableOutsideOfProjectDirectory = false
    // Even if we don't allow cleaning filewrites from outside of the project bubble, we should still include FileWritesShareable that are inside the bubble
    if !$(TrackFileWritesShareableOutsideOfProjectDirectory):
      FindUnderPath(
          Files="@(FileWritesShareable)",
          Path="$(MSBuildProjectDirectory)",
          UpdateToAbsolutePaths="true")
        Output(ItemName="FileWrites", TaskParameter="InPath")
    // Find all files in the final output directory. Use separate item includes for Files based on condition so we don't create a whole new
    // item list unnecessarily
    if !$(TrackFileWritesShareableOutsideOfProjectDirectory):
      FindUnderPath(Files="@(FileWrites)", Path="$(OutDir)", UpdateToAbsolutePaths="true")
        Output(ItemName="_CleanCurrentFileWritesInOutput", TaskParameter="InPath")
    if $(TrackFileWritesShareableOutsideOfProjectDirectory):
      FindUnderPath(
          Files="@(FileWrites);@(FileWritesShareable)",
          Path="$(OutDir)",
          UpdateToAbsolutePaths="true")
        Output(ItemName="_CleanCurrentFileWritesInOutput", TaskParameter="InPath")
    // Find all files in the intermediate output directory. Same as above, use Conditions to prevent new item list writes
    if !$(TrackFileWritesShareableOutsideOfProjectDirectory):
      FindUnderPath(
          Files="@(FileWrites)",
          Path="$(IntermediateOutputPath)",
          UpdateToAbsolutePaths="true")
        Output(ItemName="_CleanCurrentFileWritesInIntermediate", TaskParameter="InPath")
    if $(TrackFileWritesShareableOutsideOfProjectDirectory):
      FindUnderPath(
          Files="@(FileWrites);@(FileWritesShareable)",
          Path="$(IntermediateOutputPath)",
          UpdateToAbsolutePaths="true")
        Output(ItemName="_CleanCurrentFileWritesInIntermediate", TaskParameter="InPath")
    // Subtract any resolved assembly files from *current* file writes because deleting
    // these would break subsequent builds because the assemblies would be unresolvable.
    //
    // Only subtract the outputs from ResolveAssemblyReferences target because that's the
    // only "Resolve" target that tries to resolve assemblies directly from the output
    // directory.
    ItemGroup
      _CleanCurrentFileWritesWithNoReferences += "@(_CleanCurrentFileWritesInOutput);@(_CleanCurrentFileWritesInIntermediate)"(
          Exclude="@(_ResolveAssemblyReferenceResolvedFilesAbsolute)")
    // Remove duplicates from files produced in this build.
    RemoveDuplicates(Inputs="@(_CleanCurrentFileWritesWithNoReferences)")
      Output(ItemName="_CleanCurrentFileWrites", TaskParameter="Filtered")
  // ***********************************************************************************************
  // ***********************************************************************************************
  // Clean Section
  // ***********************************************************************************************
  // ***********************************************************************************************
  // ============================================================
  // Clean
  //
  // Delete all intermediate and final build outputs.
  // ============================================================
  PropertyGroup
    CleanDependsOn =
      | BeforeClean;
      |       UnmanagedUnregistration;
      |       CoreClean;
      |       CleanReferencedProjects;
      |       CleanPublishFolder;
      |       AfterClean
  if '$(_InvalidConfigurationWarning)' != 'true':
    Target Clean(DependsOnTargets="$(CleanDependsOn)")
  // ============================================================
  // BeforeClean
  //
  // Redefine this target in your project in order to run tasks just before Clean.
  // ============================================================
  Target BeforeClean
  // ============================================================
  // AfterClean
  //
  // Redefine this target in your project in order to run tasks just after Clean.
  // ============================================================
  Target AfterClean
  // ============================================================
  // CleanReferencedProjects
  //
  // Call Clean target on all Referenced Projects.
  // ============================================================
  Target CleanReferencedProjects(DependsOnTargets="PrepareProjectReferences")
    // When building the project directly from the command-line, clean those referenced projects
    // that exist on disk.  For IDE builds and command-line .SLN builds, the solution build manager
    // takes care of this.
    if '$(BuildingInsideVisualStudio)' != 'true' and '$(BuildProjectReferences)' == 'true' and '@(_MSBuildProjectReferenceExistent)' != '':
      MSBuild(
          BuildInParallel="$(BuildInParallel)",
          ContinueOnError="$(ContinueOnError)",
          Projects="@(_MSBuildProjectReferenceExistent)",
          Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform); %(_MSBuildProjectReferenceExistent.SetTargetFramework)",
          RemoveProperties="%(_MSBuildProjectReferenceExistent.GlobalPropertiesToRemove)$(_GlobalPropertiesToRemoveFromProjectReferences)",
          Targets="Clean")
  // ============================================================
  // CoreClean
  // ============================================================
  PropertyGroup
    CoreCleanDependsOn
  Target CoreClean(DependsOnTargets="$(CoreCleanDependsOn)")
    // First clean any explicitly specified cleanable files.
    // Declare items of this type if you want Clean to delete them.
    Delete(Files="@(Clean)", TreatErrorsAsWarnings="true")
    // Read in list of files that were written to disk in past builds.
    ReadLinesFromFile(File="$(IntermediateOutputPath)$(CleanFile)")
      Output(ItemName="_CleanPriorFileWrites", TaskParameter="Lines")
    // Find all files in the final output directory.
    FindUnderPath(Files="@(_CleanPriorFileWrites)", Path="$(OutDir)")
      Output(ItemName="_CleanPriorFileWritesInOutput", TaskParameter="InPath")
    // Find all files in the intermediate output directory.
    FindUnderPath(Files="@(_CleanPriorFileWrites)", Path="$(IntermediateOutputPath)")
      Output(ItemName="_CleanPriorFileWritesInIntermediate", TaskParameter="InPath")
    // Delete those files.
    Delete(
        Files="@(_CleanPriorFileWritesInOutput);@(_CleanPriorFileWritesInIntermediate)",
        TreatErrorsAsWarnings="true")
      Output(ItemName="_CleanPriorFileWritesDeleted", TaskParameter="DeletedFiles")
    // Create a list of everything that wasn't deleted.
    ItemGroup
      _CleanRemainingFileWritesAfterClean += "@(_CleanPriorFileWrites)"(
          Exclude="@(_CleanPriorFileWritesDeleted)")
    // Remove duplicates.
    RemoveDuplicates(Inputs="@(_CleanRemainingFileWritesAfterClean)")
      Output(ItemName="_CleanUniqueRemainingFileWrites", TaskParameter="Filtered")
    // Make sure the directory exists.
    MakeDir(Directories="$(IntermediateOutputPath)")
    // Write new list of current files back to disk.
    WriteLinesToFile(
        File="$(IntermediateOutputPath)$(CleanFile)",
        Lines="@(_CleanUniqueRemainingFileWrites)",
        Overwrite="true",
        WriteOnlyWhenDifferent="true")
  // ============================================================
  // _CleanRecordFileWrites
  //
  // Save the list of all files written to disk so that it can be used for "Clean" later.
  //
  // Files written in prior builds are not removed from Clean cache.
  // ============================================================
  Target _CleanRecordFileWrites(DependsOnTargets="_CleanGetCurrentAndPriorFileWrites")
    // Merge list of files from prior builds with the current build and then
    // remove duplicates.
    RemoveDuplicates(Inputs="@(_CleanPriorFileWrites);@(_CleanCurrentFileWrites)")
      Output(ItemName="_CleanUniqueFileWrites", TaskParameter="Filtered")
    // Make sure the directory exists.
    MakeDir(Directories="$(IntermediateOutputPath)")
    // Write merged file list back to disk, replacing existing contents.
    WriteLinesToFile(
        File="$(IntermediateOutputPath)$(CleanFile)",
        Lines="@(_CleanUniqueFileWrites)",
        Overwrite="true",
        WriteOnlyWhenDifferent="true")
  // ============================================================
  // CleanPublishFolder
  // ============================================================
  Target CleanPublishFolder
    if '$(ClickOncePublishDir)'=='$(OutputPath)app.publish\' and Exists('$(ClickOncePublishDir)'):
      RemoveDir(Directories="$(ClickOncePublishDir)")
  // ***********************************************************************************************
  // ***********************************************************************************************
  // PostBuildEvent Section
  // ***********************************************************************************************
  // ***********************************************************************************************
  // ============================================================
  // PostBuildEvent
  //
  // Run the post-build event. This step is driven by two parameters:
  //
  // (1) The $(RunPostBuildEvent) property is set by the user through the IDE and can be one of four values.
  //
  // - OnBuildSuccess: In this case, every step of the build must succeed for the post-build step to run.
  // - <Blank>: This is the same as OnBuildSuccess.
  // - OnOutputUpdated: In this case, the post-build step will run only if the main output assembly was
  // actually updated.
  // - Always: The post-build step is always run.
  //
  // (2) The $(_AssemblyTimestampBeforeCompile) and $(_AssemblyTimestampAfterCompile) values are
  // set by the _TimeStampBeforeCompile and _TimeStampAfterCompile targets.  If the assembly was actually
  // rebuilt during this build, then the two values will be different.
  // ============================================================
  PropertyGroup
    PostBuildEventDependsOn
  if '$(PostBuildEvent)' != '' and ('$(RunPostBuildEvent)' != 'OnOutputUpdated' or '$(_AssemblyTimestampBeforeCompile)' != '$(_AssemblyTimestampAfterCompile)'):
    Target PostBuildEvent(DependsOnTargets="$(PostBuildEventDependsOn)")
      Exec(Command="$(PostBuildEvent)", WorkingDirectory="$(OutDir)")
  // ***********************************************************************************************
  // ***********************************************************************************************
  // Publish Section
  // ***********************************************************************************************
  // ***********************************************************************************************
  PropertyGroup
    DeploymentComputeClickOnceManifestInfoDependsOn =
      | CleanPublishFolder;
      |       $(_RecursiveTargetForContentCopying);
      |       _DeploymentGenerateTrustInfo;
      |       $(DeploymentComputeClickOnceManifestInfoDependsOn)
  // ============================================================
  // Publish
  //
  // This target is only called when doing ClickOnce publishing outside the IDE, which implicitly builds before publishing.
  // ============================================================
  PropertyGroup
    if '$(PublishableProject)'=='true':
      PublishDependsOn =
        | SetGenerateManifests;
        |       Build;
        |       PublishOnly
    if '$(PublishableProject)'!='true':
      PublishDependsOn = _DeploymentUnpublishable
  Target Publish(DependsOnTargets="$(PublishDependsOn)")
  // ============================================================
  // _DeploymentUnpublishable
  //
  // This target is used to block an attempt to ClickOnce publish a non-publishable project, such as a ClassLibrary, when building outside the IDE.
  // ============================================================
  Target _DeploymentUnpublishable
    MSBuildInternalMessage(ResourceName="CommonSdk.DeploymentUnpublishable", Severity="Message")
  // ============================================================
  // SetGenerateManifests
  //
  // This target simply assures the GenerateClickOnceManifests property is set whenever the publish target is invoked.
  // ============================================================
  Target SetGenerateManifests
    if '$(OutputType)'!='winexe' and '$(OutputType)'!='exe' and '$(OutputType)'!='appcontainerexe':
      MSBuildInternalMessage(ResourceName="CommonSdk.GenerateManifestsOnlyForExe", Severity="Error")
    if '$(_DeploymentSignClickOnceManifests)'=='true' and '$(ManifestCertificateThumbprint)'=='' and '$(ManifestKeyFile)'=='':
      MSBuildInternalMessage(ResourceName="CommonSdk.SigningKeyRequired", Severity="Error")
    PropertyGroup
      GenerateClickOnceManifests = true
  // ============================================================
  // PublishOnly
  //
  // The "PublishOnly" target is intended for ClickOnce publishing inside the IDE, where the build has already been done
  // by the BuildManager.
  // ============================================================
  PropertyGroup
    PublishOnlyDependsOn =
      | SetGenerateManifests;
      |       PublishBuild;
      |       BeforePublish;
      |       GenerateManifests;
      |       CopyFilesToOutputDirectory;
      |       _CopyFilesToPublishFolder;
      |       _DeploymentGenerateBootstrapper;
      |       ResolveKeySource;
      |       _DeploymentSignClickOnceDeployment;
      |       AfterPublish
  Target PublishOnly(DependsOnTargets="$(PublishOnlyDependsOn)")
  // ============================================================
  // BeforePublish
  //
  // Redefine this target in your project in order to run tasks just before Publish.
  // ============================================================
  Target BeforePublish
  // ============================================================
  // AfterPublish
  //
  // Redefine this target in your project in order to run tasks just after Publish.
  // ============================================================
  Target AfterPublish
  // ============================================================
  // PublishBuild
  //
  // Defines the set of targets that publishing is directly dependent on.
  // ============================================================
  PropertyGroup
    PublishBuildDependsOn =
      | BuildOnlySettings;
      |       PrepareForBuild;
      |       ResolveReferences;
      |       PrepareResources;
      |       ResolveKeySource;
      |       GenerateSerializationAssemblies;
      |       CreateSatelliteAssemblies;
  Target PublishBuild(DependsOnTargets="$(PublishBuildDependsOn)")
  // ============================================================
  // _CopyFilesToPublishFolder
  // ============================================================
  Target _CopyFilesToPublishFolder
    // Compute name of application folder, which includes the assembly name plus formatted application version.
    // The application version is formatted to use "_" in place of "." chars (i.e. "1_0_0_0" instead of "1.0.0.0").
    // This is done because some servers misinterpret "." as a file extension.
    FormatVersion(
        FormatType="Path",
        Revision="$(ApplicationRevision)",
        Version="$(ApplicationVersion)")
      Output(PropertyName="_DeploymentApplicationVersionFragment", TaskParameter="OutputVersion")
    PropertyGroup
      _DeploymentApplicationFolderName = Application Files\$(AssemblyName)_$(_DeploymentApplicationVersionFragment)
      _DeploymentApplicationDir = $(ClickOncePublishDir)$(_DeploymentApplicationFolderName)\
    PropertyGroup
      // By default we're not using Hard or Symbolic Links to copy to the publish directory, and never when building in VS
      if '$(BuildingInsideVisualStudio)' == 'true' or '$(CreateHardLinksForPublishFilesIfPossible)' == '':
        CreateHardLinksForPublishFilesIfPossible = false
      if '$(BuildingInsideVisualStudio)' == 'true' or '$(CreateSymbolicLinksForPublishFilesIfPossible)' == '':
        CreateSymbolicLinksForPublishFilesIfPossible = false
    // Copy files to publish folder
    if '$(PublishSingleFile)' != 'true':
      Copy(
          DestinationFiles="@(_ApplicationManifestFinal->'$(_DeploymentApplicationDir)%(TargetPath)');
                @(_DeploymentManifestEntryPoint->'$(_DeploymentApplicationDir)%(TargetPath)$(_DeploymentFileMappingExtension)');
                @(_DeploymentManifestFiles->'$(_DeploymentApplicationDir)%(TargetPath)$(_DeploymentFileMappingExtension)');
                @(ReferenceComWrappersToCopyLocal->'$(_DeploymentApplicationDir)%(FileName)%(Extension)$(_DeploymentFileMappingExtension)');
                @(ResolvedIsolatedComModules->'$(_DeploymentApplicationDir)%(FileName)%(Extension)$(_DeploymentFileMappingExtension)');
                @(_DeploymentLooseManifestFile->'$(_DeploymentApplicationDir)%(FileName)%(Extension)$(_DeploymentFileMappingExtension)')",
          OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)",
          Retries="$(CopyRetryCount)",
          RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)",
          SkipUnchangedFiles="$(SkipCopyUnchangedFiles)",
          SourceFiles="@(_ApplicationManifestFinal);
                @(_DeploymentResolvedManifestEntryPoint);
                @(_DeploymentManifestFiles);
                @(ReferenceComWrappersToCopyLocal);
                @(ResolvedIsolatedComModules);
                @(_DeploymentLooseManifestFile)",
          UseHardlinksIfPossible="$(CreateHardLinksForPublishFilesIfPossible)",
          UseSymboliclinksIfPossible="$(CreateSymbolicLinksForPublishFilesIfPossible)")
    if '$(PublishSingleFile)' != 'true' and '%(_DeploymentManifestDependencies.DependencyType)'=='Install':
      Copy(
          DestinationFiles="@(_DeploymentManifestDependencies->'$(_DeploymentApplicationDir)%(TargetPath)$(_DeploymentFileMappingExtension)')",
          OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)",
          Retries="$(CopyRetryCount)",
          RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)",
          SkipUnchangedFiles="$(SkipCopyUnchangedFiles)",
          SourceFiles="@(_DeploymentManifestDependencies)",
          UseHardlinksIfPossible="$(CreateHardLinksForPublishFilesIfPossible)",
          UseSymboliclinksIfPossible="$(CreateSymbolicLinksForPublishFilesIfPossible)")
    if '$(PublishSingleFile)' != 'true':
      Copy(
          DestinationFiles="@(_ReferenceScatterPaths->'$(_DeploymentApplicationDir)%(Filename)%(Extension)$(_DeploymentFileMappingExtension)')",
          OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)",
          Retries="$(CopyRetryCount)",
          RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)",
          SkipUnchangedFiles="$(SkipCopyUnchangedFiles)",
          SourceFiles="@(_ReferenceScatterPaths)",
          UseHardlinksIfPossible="$(CreateHardLinksForPublishFilesIfPossible)",
          UseSymboliclinksIfPossible="$(CreateSymbolicLinksForPublishFilesIfPossible)")
    if '$(PublishSingleFile)' == 'true':
      ItemGroup
        PublishedSingleFileToBeCopied += "@(_DeploymentManifestFiles)"
    // For single-file publish case, we need to only copy the clickonce manifest, manifest entry point (launcher) and the SF EXE
    if '$(PublishSingleFile)' == 'true':
      Copy(
          DestinationFiles="@(_ApplicationManifestFinal->'$(_DeploymentApplicationDir)%(TargetPath)');
                 @(_DeploymentManifestEntryPoint->'$(_DeploymentApplicationDir)%(TargetPath)$(_DeploymentFileMappingExtension)');
                 @(PublishedSingleFileToBeCopied->'$(_DeploymentApplicationDir)%(TargetPath)$(_DeploymentFileMappingExtension)')",
          OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)",
          Retries="$(CopyRetryCount)",
          RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)",
          SkipUnchangedFiles="$(SkipCopyUnchangedFiles)",
          SourceFiles="@(_ApplicationManifestFinal);
                 @(_DeploymentResolvedManifestEntryPoint);
                 @(PublishedSingleFileToBeCopied);",
          UseHardlinksIfPossible="$(CreateHardLinksForPublishFilesIfPossible)",
          UseSymboliclinksIfPossible="$(CreateSymbolicLinksForPublishFilesIfPossible)")
    FormatUrl(InputUrl="$(_DeploymentApplicationUrl)")
      Output(PropertyName="_DeploymentFormattedApplicationUrl", TaskParameter="OutputUrl")
    FormatUrl(InputUrl="$(_DeploymentComponentsUrl)")
      Output(PropertyName="_DeploymentFormattedComponentsUrl", TaskParameter="OutputUrl")
  // ============================================================
  // _DeploymentGenerateBootstrapper
  // ============================================================
  Target _DeploymentGenerateBootstrapper
    // Build setup.exe bootstrapper and copy referenced packages
    if '$(BootstrapperEnabled)'=='true':
      GenerateBootstrapper(
          ApplicationFile="$(TargetDeployManifestFileName)",
          ApplicationName="$(AssemblyName)",
          ApplicationUrl="$(_DeploymentFormattedApplicationUrl)",
          BootstrapperItems="@(BootstrapperPackage)",
          ComponentsLocation="$(BootstrapperComponentsLocation)",
          ComponentsUrl="$(_DeploymentFormattedComponentsUrl)",
          Culture="$(TargetCulture)",
          FallbackCulture="$(FallbackCulture)",
          OutputPath="$(ClickOncePublishDir)",
          Path="$(GenerateBootstrapperSdkPath)",
          SupportUrl="$(_DeploymentFormattedSupportUrl)",
          VisualStudioVersion="$(VisualStudioVersion)")
  // ============================================================
  // _DeploymentSignClickOnceDeployment
  // ============================================================
  Target _DeploymentSignClickOnceDeployment
    // Sign manifests and the bootstrapper
    if '$(_DeploymentSignClickOnceManifests)'=='true':
      SignFile(
          CertificateThumbprint="$(_DeploymentResolvedManifestCertificateThumbprint)",
          DisallowMansignTimestampFallback="$(DisallowMansignTimestampFallback)",
          SigningTarget="$(_DeploymentApplicationDir)$(_DeploymentTargetApplicationManifestFileName)",
          TargetFrameworkIdentifier="$(TargetFrameworkIdentifier)",
          TargetFrameworkVersion="$(TargetFrameworkVersion)",
          TimestampUrl="$(ManifestTimestampUrl)")
    // Update entry point path in deploy manifest
    UpdateManifest(
        ApplicationManifest="$(_DeploymentApplicationDir)$(_DeploymentTargetApplicationManifestFileName)",
        ApplicationPath="$(_DeploymentApplicationFolderName)\$(_DeploymentTargetApplicationManifestFileName)",
        InputManifest="$(OutDir)$(TargetDeployManifestFileName)",
        OutputManifest="$(ClickOncePublishDir)$(TargetDeployManifestFileName)",
        TargetFrameworkVersion="$(_DeploymentManifestTargetFrameworkVersion)")
      Output(ItemName="PublishedDeployManifest", TaskParameter="OutputManifest")
    if '$(_DeploymentSignClickOnceManifests)'=='true':
      SignFile(
          CertificateThumbprint="$(_DeploymentResolvedManifestCertificateThumbprint)",
          DisallowMansignTimestampFallback="$(DisallowMansignTimestampFallback)",
          SigningTarget="$(ClickOncePublishDir)$(TargetDeployManifestFileName)",
          TargetFrameworkIdentifier="$(TargetFrameworkIdentifier)",
          TargetFrameworkVersion="$(TargetFrameworkVersion)",
          TimestampUrl="$(ManifestTimestampUrl)")
    if '$(BootstrapperEnabled)'=='true' and '$(_DeploymentSignClickOnceManifests)'=='true':
      SignFile(
          CertificateThumbprint="$(_DeploymentResolvedManifestCertificateThumbprint)",
          SigningTarget="$(ClickOncePublishDir)setup.exe",
          TimestampUrl="$(ManifestTimestampUrl)")
  // ***********************************************************************************************
  // ***********************************************************************************************
  // AllProjectOutputGroups Section
  // ***********************************************************************************************
  // ***********************************************************************************************
  // ============================================================
  // AllProjectOutputGroups
  //
  // The targets below drive output groups, which provide generic information about a
  // project's inputs (e.g., content files, compilation sources, etc.) and built outputs
  // (e.g., built EXE/DLL, PDB, XML documentation files, etc.)
  //
  // Each target may produce two kinds of items:  outputs and dependencies.  Outputs are
  // items from the current project; dependencies are items that are brought into the
  // current project as a result of referencing other projects or components.
  //
  // For both outputs and dependencies, the Include attribute
  // specifies the location of the output/dependency; it must be a full path.  Any number
  // of additional attributes may be placed on an output/dependency item.
  // ============================================================
  Target AllProjectOutputGroups(
      DependsOnTargets=[
        BuiltProjectOutputGroup
        DebugSymbolsProjectOutputGroup
        DocumentationProjectOutputGroup
        SatelliteDllsProjectOutputGroup
        SourceFilesProjectOutputGroup
        ContentFilesProjectOutputGroup
        SGenFilesOutputGroup
      ])
  // This is the key output for the BuiltProjectOutputGroup and is meant to be read directly from the IDE.
  // Reading an item is faster than invoking a target.
  if '$(OutputType)' != 'winmdobj':
    ItemGroup
      BuiltProjectOutputGroupKeyOutput += "@(IntermediateAssembly->'%(FullPath)')"
        IsKeyOutput = true
        FinalOutputPath = $(TargetPath)
        TargetPath = $(TargetFileName)
        if '$(RegisterForComInterop)'=='true' and '$(OutputType)'=='library':
          COM2REG = true
  if '$(OutputType)' == 'winmdobj':
    ItemGroup
      if '$(_IntermediateWindowsMetadataPath)' != '':
        WinMDExpOutputWindowsMetadataFileItem += "$(_IntermediateWindowsMetadataPath)"
      BuiltProjectOutputGroupKeyOutput += "@(WinMDExpOutputWindowsMetadataFileItem->'%(FullPath)')"
        IsKeyOutput = true
        FinalOutputPath = $(TargetPath)
        TargetPath = $(TargetFileName)
  // ============================================================
  // BuiltProjectOutputGroup
  // ============================================================
  PropertyGroup
    BuiltProjectOutputGroupDependsOn = PrepareForBuild
    if ('$(AddAppConfigToBuildOutputs)'=='') and ('$(OutputType)'!='library' and '$(OutputType)'!='winmdobj'):
      AddAppConfigToBuildOutputs = true
  Target BuiltProjectOutputGroup(
      DependsOnTargets="$(BuiltProjectOutputGroupDependsOn)",
      Returns="@(BuiltProjectOutputGroupOutput)")
    ItemGroup
      _BuiltProjectOutputGroupOutputIntermediate += "@(BuiltProjectOutputGroupKeyOutput)"
    // This item represents the app.config file
    ItemGroup
      if '$(AddAppConfigToBuildOutputs)'=='true':
        _BuiltProjectOutputGroupOutputIntermediate += "$(AppConfig)"
          FinalOutputPath = $(TargetDir)$(TargetFileName).config
          TargetPath = $(TargetFileName).config
          // For compatibility with 2.0
          OriginalItemSpec = $(AppConfig)
    ItemGroup
      if '%(COMReference.Isolated)' == 'true':
        _IsolatedComReference += "@(COMReference)"
      if '%(COMFileReference.Isolated)' == 'true':
        _IsolatedComReference += "@(COMFileReference)"
    // This item represents the native manifest, example: WindowsApplication1.exe.manifest or Native.ClassLibrary1.manifest
    ItemGroup
      if ('@(NativeReference)'!='' or '@(_IsolatedComReference)'!='') And Exists('$(OutDir)$(_DeploymentTargetApplicationManifestFileName)'):
        _BuiltProjectOutputGroupOutputIntermediate += "$(OutDir)$(_DeploymentTargetApplicationManifestFileName)"
          TargetPath = $(_DeploymentTargetApplicationManifestFileName)
          // For compatibility with 2.0
          OriginalItemSpec = $(OutDir)$(_DeploymentTargetApplicationManifestFileName)
    // Convert intermediate items into final items; this way we can get the full path for each item
    ItemGroup
      BuiltProjectOutputGroupOutput += "@(_BuiltProjectOutputGroupOutputIntermediate->'%(FullPath)')"
        // For compatibility with 2.0
        if '%(_BuiltProjectOutputGroupOutputIntermediate.OriginalItemSpec)' == '':
          OriginalItemSpec = %(_BuiltProjectOutputGroupOutputIntermediate.FullPath)
  // ============================================================
  // DebugSymbolsProjectOutputGroup
  //
  // This target performs population of the Debug Symbols project output group.
  // ============================================================
  PropertyGroup
    DebugSymbolsProjectOutputGroupDependsOn
  if '$(_DebugSymbolsProduced)' != 'false' and '$(OutputType)' != 'winmdobj':
    ItemGroup
      DebugSymbolsProjectOutputGroupOutput += "@(_DebugSymbolsIntermediatePath->'%(FullPath)')"
        FinalOutputPath = @(_DebugSymbolsOutputPath->'%(FullPath)')
        TargetPath = @(_DebugSymbolsIntermediatePath->'%(Filename)%(Extension)')
  if '$(_DebugSymbolsProduced)' != 'false' and '$(OutputType)' == 'winmdobj':
    ItemGroup
      if '$(WinMDExpOutputPdb)' != '':
        WinMDExpOutputPdbItem += "$(WinMDExpOutputPdb)"
      if '$(_WinMDDebugSymbolsOutputPath)' != '':
        WinMDExpFinalOutputPdbItem += "$(_WinMDDebugSymbolsOutputPath)"
      DebugSymbolsProjectOutputGroupOutput += "@(WinMDExpOutputPdbItem->'%(FullPath)')"
        FinalOutputPath = @(WinMDExpFinalOutputPdbItem->'%(FullPath)')
        TargetPath = @(WinMDExpOutputPdbItem->'%(Filename)%(Extension)')
  Target DebugSymbolsProjectOutputGroup(
      DependsOnTargets="$(DebugSymbolsProjectOutputGroupDependsOn)",
      Returns="@(DebugSymbolsProjectOutputGroupOutput)")
  // ============================================================
  // DocumentationProjectOutputGroup
  //
  // This target performs population of the Documentation project output group.
  // ============================================================
  PropertyGroup
    DocumentationProjectOutputGroupDependsOn
  if '$(DocumentationFile)'!='' and '$(OutputType)' != 'winmdobj':
    ItemGroup
      DocumentationProjectOutputGroupOutput += "@(DocFileItem->'%(FullPath)')"
        FinalOutputPath = @(FinalDocFile->'%(FullPath)')
        IsKeyOutput = true
        TargetPath = @(DocFileItem->'%(Filename)%(Extension)')
  if '$(DocumentationFile)' != '' and '$(OutputType)' == 'winmdobj':
    ItemGroup
      if '$(WinMDOutputDocumentationFile)' != '':
        WinMDOutputDocumentationFileItem += "$(WinMDOutputDocumentationFile)"
      if '$(_WinMDDocFileOutputPath)' != '':
        WinMDExpFinalOutputDocItem += "$(_WinMDDocFileOutputPath)"
      DocumentationProjectOutputGroupOutput += "@(WinMDOutputDocumentationFileItem->'%(FullPath)')"
        FinalOutputPath = @(WinMDExpFinalOutputDocItem->'%(FullPath)')
        TargetPath = @(WinMDOutputDocumentationFileItem->'%(Filename)%(Extension)')
  Target DocumentationProjectOutputGroup(
      DependsOnTargets="$(DocumentationProjectOutputGroupDependsOn)",
      Returns="@(DocumentationProjectOutputGroupOutput)")
  // ============================================================
  // SatelliteDllsProjectOutputGroup
  //
  // This target performs population of the Satellite Files project output group.
  // ============================================================
  PropertyGroup
    SatelliteDllsProjectOutputGroupDependsOn = $(SatelliteDllsProjectOutputGroupDependsOn);PrepareForBuild;PrepareResourceNames
  Target SatelliteDllsProjectOutputGroup(
      DependsOnTargets="$(SatelliteDllsProjectOutputGroupDependsOn)",
      Returns="@(SatelliteDllsProjectOutputGroupOutput)")
    ItemGroup
      if '%(EmbeddedResource.WithCulture)' == 'true':
        SatelliteDllsProjectOutputGroupOutputIntermediate += "$(IntermediateOutputPath)%(EmbeddedResource.Culture)\$(TargetName).resources.dll"
          TargetPath = %(EmbeddedResource.Culture)\$(TargetName).resources.dll
          Culture = %(EmbeddedResource.Culture)
    // Convert intermediate items into final items; this way we can get the full path for each item.
    ItemGroup
      SatelliteDllsProjectOutputGroupOutput += "@(SatelliteDllsProjectOutputGroupOutputIntermediate->'%(FullPath)')"
        if '%(SatelliteDllsProjectOutputGroupOutputIntermediate.FinalOutputPath)' == '':
          FinalOutputPath = $(TargetDir)%(SatelliteDllsProjectOutputGroupOutputIntermediate.TargetPath)
        // For compatibility with 2.0
        OriginalItemSpec = %(SatelliteDllsProjectOutputGroupOutputIntermediate.Identity)
  // ============================================================
  // SourceFilesProjectOutputGroup
  //
  // This target performs population of the Source Files project output group.
  // Source files are items in the project whose type is "Compile" and "EmbeddedResource".
  // ============================================================
  PropertyGroup
    SourceFilesProjectOutputGroupDependsOn = PrepareForBuild;AssignTargetPaths
  Target SourceFilesProjectOutputGroup(
      DependsOnTargets="$(SourceFilesProjectOutputGroupDependsOn)",
      Returns="@(SourceFilesProjectOutputGroupOutput)")
    AssignTargetPath(Files="@(Compile)", RootFolder="$(MSBuildProjectDirectory)")
      Output(ItemName="_CompileWithTargetPath", TaskParameter="AssignedFiles")
    ItemGroup
      // First we deal with Compile, EmbeddedResource and AppConfig
      SourceFilesProjectOutputGroupOutput += "@(_CompileWithTargetPath->'%(FullPath)');@(EmbeddedResource->'%(FullPath)');@(_LicxFile->'%(FullPath)');@(AppConfigWithTargetPath->'%(FullPath)')"
      // Include the project file
      SourceFilesProjectOutputGroupOutput += "$(MSBuildProjectFullPath)"
        // For compatibility with 2.0
        OriginalItemSpec = $(MSBuildProjectFullPath)
        TargetPath = $(ProjectFileName)
  // Get just the compile items
  Target GetCompile(Returns="@(Compile)")
  // ============================================================
  // ContentFilesProjectOutputGroup
  //
  // This target performs population of the Content Files project output group.
  // Content files are items in the project whose type is "Content".
  // ============================================================
  PropertyGroup
    ContentFilesProjectOutputGroupDependsOn = PrepareForBuild;AssignTargetPaths
  Target ContentFilesProjectOutputGroup(
      DependsOnTargets="$(ContentFilesProjectOutputGroupDependsOn)",
      Returns="@(ContentFilesProjectOutputGroupOutput)")
    // Convert items into final items; this way we can get the full path for each item.
    ItemGroup
      ContentFilesProjectOutputGroupOutput += "@(ContentWithTargetPath->'%(FullPath)')"
  // ============================================================
  // SGenFilesOutputGroup
  //
  // This target performs population of the GenerateSerializationAssemblies Files project output group.
  // GenerateSerializationAssemblies files are those generated by the GenerateSerializationAssemblies target and task.
  // ============================================================
  PropertyGroup
    SGenFilesOutputGroupDependsOn
  if '$(_SGenGenerateSerializationAssembliesConfig)' == 'On' or ('@(WebReferenceUrl)'!='' and '$(_SGenGenerateSerializationAssembliesConfig)' == 'Auto'):
    ItemGroup
      SGenFilesOutputGroupOutput += "@(_OutputPathItem->'%(FullPath)$(_SGenDllName)')"
        FinalOutputPath = @(_OutputPathItem->'%(FullPath)$(_SGenDllName)')
        TargetPath = $(_SGenDllName)
  Target SGenFilesOutputGroup(
      DependsOnTargets="$(SGenFilesOutputGroupDependsOn)",
      Returns="@(SGenFilesOutputGroupOutput)")
  // ============================================================
  // SDKRelated Output groups
  //
  // These targets are to gather information from the SDKs.
  // ============================================================
  // Get the resolved SDK reference items
  Target GetResolvedSDKReferences(
      DependsOnTargets="ResolveSDKReferences",
      Returns="@(ResolvedSDKReference)")
  // Target will return no results by default but will be populated by other targets elsewhere.
  // Needed for certain build environments that import partial sets of targets.
  Target CollectReferencedNuGetPackages(Returns="@(ReferencedNuGetPackages)")
  // Get the TargetFrameworks that are supported for the Visual Studio TargetFramework drop down
  Target GenerateSupportedTargetFrameworkAlias(Returns="@(SupportedTargetFrameworkAlias)")
  // ============================================================
  // PriFilesOutputGroup
  //
  // This target performs population of the pri files output group
  // ============================================================
  if '@(_ReferenceRelatedPaths)' != '':
    Target PriFilesOutputGroup(
        DependsOnTargets=[
          BuildOnlySettings
          PrepareForBuild
          AssignTargetPaths
          ResolveReferences
        ],
        Returns="@(PriFilesOutputGroupOutput)")
      // This item represents dependent pri file's
      ItemGroup
        if '%(Extension)' == '.pri':
          PriFilesOutputGroupOutput += "@(_ReferenceRelatedPaths->'%(FullPath)')"
  PropertyGroup
    SDKRedistOutputGroupDependsOn = ResolveSDKReferences;ExpandSDKReferences
  // ============================================================
  // SDKRedistOutputGroup
  //
  // This target gathers the Redist folders from the SDKs which have been resolved.
  // ============================================================
  Target SDKRedistOutputGroup(
      DependsOnTargets="$(SDKRedistOutputGroupDependsOn)",
      Returns="@(SDKRedistOutputGroupOutput)")
    // This list starts with the least specific files to the most specific so that later files can overwrite earlier files
    ItemGroup
      SDKRedistOutputGroupOutput += "@(ResolvedRedistFiles)"
  // ***********************************************************************************************
  // ***********************************************************************************************
  // AllProjectOutputGroupsDependencies Section
  // ***********************************************************************************************
  // ***********************************************************************************************
  // ============================================================
  // CommonOutputGroupsDependsOn
  //
  // Dependencies common to many of the *OutputGroupDependencies targets.
  // ============================================================
  PropertyGroup
    CommonOutputGroupsDependsOn =
      | $(CommonOutputGroupsDependsOn);
      |       BuildOnlySettings;
      |       PrepareForBuild;
      |       AssignTargetPaths;
      |       ResolveReferences
  // ============================================================
  // AllProjectOutputGroupsDependencies
  // ============================================================
  Target AllProjectOutputGroupsDependencies(
      DependsOnTargets=[
        BuiltProjectOutputGroupDependencies
        DebugSymbolsProjectOutputGroupDependencies
        SatelliteDllsProjectOutputGroupDependencies
        DocumentationProjectOutputGroupDependencies
        SGenFilesOutputGroupDependencies
      ])
  // ============================================================
  // BuiltProjectOutputGroupDependencies
  //
  // This target performs population of the Built project output group dependencies.
  // ============================================================
  PropertyGroup
    BuiltProjectOutputGroupDependenciesDependsOn =
      | $(BuiltProjectOutputGroupDependenciesDependsOn);
      |       $(CommonOutputGroupsDependsOn)
  Target BuiltProjectOutputGroupDependencies(
      DependsOnTargets="$(BuiltProjectOutputGroupDependenciesDependsOn)",
      Returns="@(BuiltProjectOutputGroupDependency)")
    ItemGroup
      BuiltProjectOutputGroupDependency += "@(ReferencePath->'%(FullPath)');
                                                         @(ReferenceDependencyPaths->'%(FullPath)');
                                                         @(NativeReferenceFile->'%(FullPath)');
                                                         @(_DeploymentLooseManifestFile->'%(FullPath)');
                                                         @(ResolvedIsolatedComModules->'%(FullPath)')"
  // ============================================================
  // DebugSymbolsProjectOutputGroupDependencies
  //
  // This target performs population of the dependencies for the debug symbols project output group.
  // ============================================================
  PropertyGroup
    DebugSymbolsProjectOutputGroupDependenciesDependsOn =
      | $(DebugSymbolsProjectOutputGroupDependenciesDependsOn);
      |       $(CommonOutputGroupsDependsOn)
  if '$(DebugSymbols)'!='false':
    Target DebugSymbolsProjectOutputGroupDependencies(
        DependsOnTargets="$(DebugSymbolsProjectOutputGroupDependenciesDependsOn)",
        Returns="@(DebugSymbolsProjectOutputGroupDependency)")
      // This item represents dependent PDB's
      ItemGroup
        if '%(Extension)' == '.pdb':
          DebugSymbolsProjectOutputGroupDependency += "@(_ReferenceRelatedPaths->'%(FullPath)')"
  // ============================================================
  // SatelliteDllsProjectOutputGroupDependencies
  //
  // This target performs population of the dependencies for the satellite files project output group.
  // ============================================================
  PropertyGroup
    SatelliteDllsProjectOutputGroupDependenciesDependsOn =
      | $(SatelliteDllsProjectOutputGroupDependenciesDependsOn);
      |       $(CommonOutputGroupsDependsOn)
  Target SatelliteDllsProjectOutputGroupDependencies(
      DependsOnTargets="$(SatelliteDllsProjectOutputGroupDependenciesDependsOn)",
      Returns="@(SatelliteDllsProjectOutputGroupDependency)")
    // This item represents dependent satellites
    ItemGroup
      SatelliteDllsProjectOutputGroupDependency += "@(ReferenceSatellitePaths->'%(FullPath)')"
  // ============================================================
  // DocumentationProjectOutputGroupDependencies
  //
  // This target performs population of the dependencies for the documentation project output group.
  // ============================================================
  PropertyGroup
    DocumentationProjectOutputGroupDependenciesDependsOn =
      | $(DocumentationProjectOutputGroupDependenciesDependsOn);
      |       $(CommonOutputGroupsDependsOn)
  if '$(DocumentationFile)'!='':
    Target DocumentationProjectOutputGroupDependencies(
        DependsOnTargets="$(DocumentationProjectOutputGroupDependenciesDependsOn)",
        Returns="@(DocumentationProjectOutputGroupDependency)")
      // This item represents dependent XMLs
      ItemGroup
        if '%(Extension)' == '.xml':
          DocumentationProjectOutputGroupDependency += "@(_ReferenceRelatedPaths->'%(FullPath)')"
  // ============================================================
  // SGenFilesOutputGroupDependencies
  //
  // This target performs population of the dependencies for the GenerateSerializationAssemblies project output group.
  // ============================================================
  PropertyGroup
    SGenFilesOutputGroupDependenciesDependsOn =
      | $(SGenFilesOutputGroupDependenciesDependsOn);
      |       $(CommonOutputGroupsDependsOn)
  Target SGenFilesOutputGroupDependencies(
      DependsOnTargets="$(SGenFilesOutputGroupDependenciesDependsOn)",
      Returns="@(SGenFilesOutputGroupDependency)")
    // This item represents sgen xml serializer dll's
    ItemGroup
      if '%(Extension)' == '.dll':
        SGenFilesOutputGroupDependency += "@(_ReferenceSerializationAssemblyPaths->'%(FullPath)')"
  // ============================================================
  // ReferenceCopyLocalPathsOutputGroup
  //
  // Exposes the set of items that should be copied locally based on the project's references.
  // ============================================================
  PropertyGroup
    ReferenceCopyLocalPathsOutputGroupDependsOn =
      | $(ReferenceCopyLocalPathsOutputGroupDependsOn);
      |       $(CommonOutputGroupsDependsOn)
  Target ReferenceCopyLocalPathsOutputGroup(
      DependsOnTargets="$(ReferenceCopyLocalPathsOutputGroupDependsOn)",
      Returns="@(ReferenceCopyLocalPathsOutputGroupOutput)")
    ItemGroup
      ReferenceCopyLocalPathsOutputGroupOutput += "@(ReferenceCopyLocalPaths)"
        TargetPath = %(ReferenceCopyLocalPaths.DestinationSubDirectory)%(ReferenceCopyLocalPaths.Filename)%(ReferenceCopyLocalPaths.Extension)
  // ============================================================
  // DesignerRuntimeImplementationProjectOutputGroup
  //
  // Exposes build items to be used by designer. The default is empty, but
  // SDKs can override it as appropriate. The empty stub is required so that
  // the project system can always rely on calling it even if it is not
  // overridden.
  // ============================================================
  PropertyGroup
    DesignerRuntimeImplementationProjectOutputGroupDependsOn =
      | $(DesignerRuntimeImplementationProjectOutputGroupDependsOn);
      |       $(CommonOutputGroupsDependsOn)
  Target DesignerRuntimeImplementationProjectOutputGroup(
      DependsOnTargets="$(DesignerRuntimeImplementationProjectOutputGroupDependsOn)",
      Returns="@(DesignerRuntimeImplementationProjectOutputGroupOutput)")
  // ============================================================
  // .editorconfig support
  // ============================================================
  // Expose the set of potential .editorconfig files so the project system can
  // retrieve them.
  Target GetPotentialEditorConfigFiles(Returns="@(PotentialEditorConfigFiles)")
  PropertyGroup
    if '$(CodeAnalysisTargets)'=='':
      CodeAnalysisTargets = $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeAnalysis\Microsoft.CodeAnalysis.targets
  if Exists('$(CodeAnalysisTargets)'):
    Import "$(CodeAnalysisTargets)"
  if Exists('$(ReportingServicesTargets)'):
    Import "$(ReportingServicesTargets)"
  if ('$(TargetFrameworkIdentifier)' == '' or '$(TargetFrameworkIdentifier)' == '.NETFramework') and ('$(TargetRuntime)' == 'Managed'):
    Import "$(MSBuildToolsPath)\Microsoft.NETFramework.targets"
  PropertyGroup
    if '$(ImportXamlTargets)'=='' and ('$(TargetFrameworkVersion)' != 'v2.0' and '$(TargetFrameworkVersion)' != 'v3.5') and Exists('$(MSBuildToolsPath)\Microsoft.Xaml.targets'):
      ImportXamlTargets = true
  if ('$(ImportXamlTargets)' == 'true'):
    Import "$(MSBuildToolsPath)\Microsoft.Xaml.targets"
  // imports Microsoft.WorkflowBuildExtensions.targets only if TargetFrameworkVersion is v4.5 or above or TargetFrameworkfVersion specified does not conform to the format of vX.X[.X.X]
  // Underlying assumption is that there shouldn't be any other versions between v4.0.* and v4.5
  if ('$(TargetFrameworkVersion)' != 'v2.0' and '$(TargetFrameworkVersion)' != 'v3.5' and (!$([System.String]::IsNullOrEmpty('$(TargetFrameworkVersion)')) and !$(TargetFrameworkVersion.StartsWith('v4.0')))) and Exists('$(MSBuildToolsPath)\Microsoft.WorkflowBuildExtensions.targets'):
    Import "$(MSBuildToolsPath)\Microsoft.WorkflowBuildExtensions.targets"
  // This import is temporary and will be removed once it is moved into the silverlight targets
  if '$(TargetFrameworkIdentifier)' == 'Silverlight' and Exists('$(MSBuildToolsPath)\Microsoft.WinFX.targets'):
    Import "$(MSBuildToolsPath)\Microsoft.WinFX.targets"
  PropertyGroup
    if '$(MsTestToolsTargets)'=='':
      MsTestToolsTargets = $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TeamTest\Microsoft.TeamTest.targets
  if Exists('$(MsTestToolsTargets)'):
    Import "$(MsTestToolsTargets)"
  PropertyGroup
    if '$(UseMSBuildTestInfrastructure)' == '':
      UseMSBuildTestInfrastructure = false
  if '$(UseMSBuildTestInfrastructure)' == 'true':
    Import "$(MSBuildToolsPath)\Microsoft.Common.Test.targets"
  // App packaging support
  // Following two targets are needed to be present in every project being built
  // because the app packaging targets recursively scan all projects referenced
  // from projects that generate app packages for them.
  Target CleanAppxPackage
  Target GetPackagingOutputs
  PropertyGroup
    if '$(MsAppxPackageTargets)'=='':
      MsAppxPackageTargets = $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\AppxPackage\Microsoft.AppXPackage.Targets
    // Opt-out switch to allow disabling importing the 'AppxPackage' targets for UWP class libraries using modern .NET
    if '$(EnableAppxPackageTargetsForUwpClassLibraries)' == '':
      EnableAppxPackageTargetsForUwpClassLibraries = true
  // We want to import the 'AppXPackage' .targets in two scenarios:
  // - For legacy UWP, in all cases (original behavior). These projects will always set 'WindowsAppContainer' by default.
  // - For UWP (XAML) apps and libraries on modern .NET, we only enable this for class libraries. This allows the existing
  // .appx tooling to take care of generating .pri resources without the need to pull in WinAppSDK or other external tools.
  // We cannot use this for applications, because the rest of that tooling is not capable of handling modern .NET projects.
  // In that case, we either leverage the tooling in WinAppSDK, or DesktopBridge (via a .wapproj project for packaging).
  if ('$(WindowsAppContainer)' == 'true' or ('$(UseUwpTools)' == 'true' and '$(OutputType)' == 'Library' and '$(EnableAppxPackageTargetsForUwpClassLibraries)' != 'false')) and Exists('$(MsAppxPackageTargets)'):
    Import "$(MsAppxPackageTargets)"
  // This import is temporary and will be removed once it is moved into the silverlight targets
  if '$(TargetFrameworkIdentifier)' == 'Silverlight' and Exists('$(MSBuildToolsPath)\Microsoft.Data.Entity.targets'):
    Import "$(MSBuildToolsPath)\Microsoft.Data.Entity.targets"
  // Import NuGet.targets (required for GetReferenceNearestTargetFrameworkTask and used for Restore functionality)
  PropertyGroup
    if '$(MSBuildUseVisualStudioDirectoryLayout)'=='':
      MSBuildUseVisualStudioDirectoryLayout = $([MSBuild]::IsRunningFromVisualStudio())
    if '$(NuGetRestoreTargets)'=='' and '$(MSBuildUseVisualStudioDirectoryLayout)'=='true':
      NuGetRestoreTargets = $([MSBuild]::GetToolsDirectory32())\..\..\..\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.targets
    if '$(NuGetRestoreTargets)'=='':
      NuGetRestoreTargets = $(MSBuildToolsPath)\NuGet.targets
  if '$(IsRestoreTargetsFileLoaded)' != 'true' and Exists('$(NuGetRestoreTargets)'):
    Import "$(NuGetRestoreTargets)"
  if '$(CustomAfterMicrosoftCommonTargets)' != '' and Exists('$(CustomAfterMicrosoftCommonTargets)'):
    Import "$(CustomAfterMicrosoftCommonTargets)"
  if '$(ImportByWildcardAfterMicrosoftCommonTargets)' == 'true' and exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.targets\ImportAfter'):
    Import "$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.targets\ImportAfter\*"
  if '$(ImportUserLocationsByWildcardAfterMicrosoftCommonTargets)' == 'true' and exists('$(MSBuildUserExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.targets\ImportAfter'):
    Import "$(MSBuildUserExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.targets\ImportAfter\*"