diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft.WinFX.targets b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft.WinFX.targets
index 903018db4bf..69112522630 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft.WinFX.targets
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft.WinFX.targets
@@ -441,6 +441,7 @@
MSBuildBinPath="$(MSBuildBinPath)"
ReferencePathTypeName="ReferencePath"
CompileTypeName="Compile"
+ AnalyzerTypeName="Analyzer"
GeneratedCodeFiles="@(_GeneratedCodeFiles)"
ReferencePath="@(ReferencePath)"
BaseIntermediateOutputPath="$(BaseIntermediateOutputPath)"
@@ -449,7 +450,7 @@
CompileTargetName="$(_CompileTargetNameForLocalType)"
GenerateTemporaryTargetAssemblyDebuggingInformation="$(GenerateTemporaryTargetAssemblyDebuggingInformation)"
IncludePackageReferencesDuringMarkupCompilation="$(IncludePackageReferencesDuringMarkupCompilation)"
- Analyzers="$(Analyzers)"
+ Analyzers="@(Analyzer)"
TemporaryTargetAssemblyProjectName="$(_TemporaryTargetAssemblyProjectName)"
MSBuildProjectExtensionsPath="$(MSBuildProjectExtensionsPath)"
>
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/GenerateTemporaryTargetAssembly.cs b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/GenerateTemporaryTargetAssembly.cs
index 3be2dc23773..3cb7ac44c50 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/GenerateTemporaryTargetAssembly.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/GenerateTemporaryTargetAssembly.cs
@@ -263,6 +263,9 @@ private bool ExecuteGenerateTemporaryTargetAssemblyWithPackageReferenceSupport()
// Add GeneratedCodeFiles to Compile item list.
AddNewItems(xmlProjectDoc, CompileTypeName, GeneratedCodeFiles);
+ // Add Analyzers to Analyzer item list.
+ AddNewItems(xmlProjectDoc, AnalyzerTypeName, Analyzers);
+
// Replace implicit SDK imports with explicit SDK imports
ReplaceImplicitImports(xmlProjectDoc);
@@ -274,7 +277,6 @@ private bool ExecuteGenerateTemporaryTargetAssemblyWithPackageReferenceSupport()
( nameof(BaseIntermediateOutputPath), BaseIntermediateOutputPath ),
( nameof(MSBuildProjectExtensionsPath), MSBuildProjectExtensionsPath ),
( "_TargetAssemblyProjectName", Path.GetFileNameWithoutExtension(CurrentProject) ),
- ( nameof(Analyzers), Analyzers )
};
AddNewProperties(xmlProjectDoc, properties);
@@ -481,9 +483,20 @@ public bool GenerateTemporaryTargetAssemblyDebuggingInformation
/// Required for Source Generator support. May be null.
///
///
- public string Analyzers
+ public ITaskItem[] Analyzers
{ get; set; }
+ ///
+ /// AnalyzerTypeName
+ /// The appropriate item name which can be accepted by managed compiler task.
+ /// It is "Analyzer" for now.
+ ///
+ /// Adding this property is to make the type name configurable, if it is changed,
+ /// No code is required to change in this task, but set a new type name in project file.
+ ///
+ [Required]
+ public string AnalyzerTypeName { get; set; }
+
///
/// BaseIntermediateOutputPath
///