Remove warning CS1701 and CS1702 when using RoslynCodeTaskFactory #12346
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #
Fix the issue: Suppress CS1701 and CS1702 warnings by default in
RoslynCodeTaskFactory
to align with .NET SDK #12101Context
When using
RoslynCodeTaskFactory
, MSBuild emits CS1701 and CS1702 assembly binding warnings for version mismatches (e.g., betweenSystem.Memory
andSystem.Text.Json
). These warnings are not actionable in modern .NET scenarios and are already suppressed by default in the .NET SDK and Roslyn. This issue causes unnecessary warning noise and confusion in custom task or non-SDK builds.Changes Made
Added a new property in the task factory configuration to include
NoWarn="1701;1702"
for all tasks generated byRoslynCodeTaskFactory
Testing
Added a new unit test
RoslynCodeTaskFactoryWithoutCS1702Warning
in the MSBuild test suite to verify that no CS1702 warnings are emitted when usingRoslynCodeTaskFactory
with references toSystem.Memory
(v4.6.3) andSystem.Text.Json
(v9.0.7).Create a project file base on example of user for test dotnet/roslyn#19640 (comment)
Notes