Skip to content

Commit 97ed499

Browse files
ThomasGoulet73singhashish-wpf
authored andcommitted
Fix build when using source generators (#6534)
Fixes #6522
1 parent 939e70b commit 97ed499

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft.WinFX.targets

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@
464464
MSBuildBinPath="$(MSBuildBinPath)"
465465
ReferencePathTypeName="ReferencePath"
466466
CompileTypeName="Compile"
467+
AnalyzerTypeName="Analyzer"
467468
GeneratedCodeFiles="@(_GeneratedCodeFiles)"
468469
ReferencePath="@(ReferencePath)"
469470
BaseIntermediateOutputPath="$(BaseIntermediateOutputPath)"
@@ -472,7 +473,7 @@
472473
CompileTargetName="$(_CompileTargetNameForLocalType)"
473474
GenerateTemporaryTargetAssemblyDebuggingInformation="$(GenerateTemporaryTargetAssemblyDebuggingInformation)"
474475
IncludePackageReferencesDuringMarkupCompilation="$(IncludePackageReferencesDuringMarkupCompilation)"
475-
Analyzers="$(Analyzers)"
476+
Analyzers="@(Analyzer)"
476477
TemporaryTargetAssemblyProjectName="$(_TemporaryTargetAssemblyProjectName)"
477478
MSBuildProjectExtensionsPath="$(MSBuildProjectExtensionsPath)"
478479
>

src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/GenerateTemporaryTargetAssembly.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,9 @@ private bool ExecuteGenerateTemporaryTargetAssemblyWithPackageReferenceSupport()
262262
// Add GeneratedCodeFiles to Compile item list.
263263
AddNewItems(xmlProjectDoc, CompileTypeName, GeneratedCodeFiles);
264264

265+
// Add Analyzers to Analyzer item list.
266+
AddNewItems(xmlProjectDoc, AnalyzerTypeName, Analyzers);
267+
265268
// Replace implicit SDK imports with explicit SDK imports
266269
ReplaceImplicitImports(xmlProjectDoc);
267270

@@ -273,7 +276,6 @@ private bool ExecuteGenerateTemporaryTargetAssemblyWithPackageReferenceSupport()
273276
( nameof(BaseIntermediateOutputPath), BaseIntermediateOutputPath ),
274277
( nameof(MSBuildProjectExtensionsPath), MSBuildProjectExtensionsPath ),
275278
( "_TargetAssemblyProjectName", Path.GetFileNameWithoutExtension(CurrentProject) ),
276-
( nameof(Analyzers), Analyzers )
277279
};
278280

279281
AddNewProperties(xmlProjectDoc, properties);
@@ -480,9 +482,20 @@ public bool GenerateTemporaryTargetAssemblyDebuggingInformation
480482
/// Required for Source Generator support. May be null.
481483
///
482484
/// </summary>
483-
public string Analyzers
485+
public ITaskItem[] Analyzers
484486
{ get; set; }
485487

488+
/// <summary>
489+
/// AnalyzerTypeName
490+
/// The appropriate item name which can be accepted by managed compiler task.
491+
/// It is "Analyzer" for now.
492+
///
493+
/// Adding this property is to make the type name configurable, if it is changed,
494+
/// No code is required to change in this task, but set a new type name in project file.
495+
/// </summary>
496+
[Required]
497+
public string AnalyzerTypeName { get; set; }
498+
486499
/// <summary>
487500
/// BaseIntermediateOutputPath
488501
///

0 commit comments

Comments
 (0)