Skip to content

Conversation

huulinhnguyen-dev
Copy link
Contributor

Fixes #
Fix the issue: Suppress CS1701 and CS1702 warnings by default in RoslynCodeTaskFactory to align with .NET SDK #12101

Context

When using RoslynCodeTaskFactory, MSBuild emits CS1701 and CS1702 assembly binding warnings for version mismatches (e.g., between System.Memory and System.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 by RoslynCodeTaskFactory

Testing

Added a new unit test RoslynCodeTaskFactoryWithoutCS1702Warning in the MSBuild test suite to verify that no CS1702 warnings are emitted when using RoslynCodeTaskFactory with references to System.Memory (v4.6.3) and System.Text.Json (v9.0.7).

Create a project file base on example of user for test dotnet/roslyn#19640 (comment)

Notes

Copy link
Member

@JanProvaznik JanProvaznik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't commit the package dlls and xml files to the repo... This would increase maintenace burden and potentially cause security flagging in the future.

@huulinhnguyen-dev huulinhnguyen-dev marked this pull request as draft August 21, 2025 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants