Skip to content

Package validation fail in .NET 8 with Unnecessary suppressions found #34936

@McMlok

Description

@McMlok

Describe the bug

When I switch SDK to 8.0.100-preview.7.23376.3 I'm not able to pack my packages with error

"Unnecessary suppressions found. The APICompat suppression file can be updated by
rebuilding with '/p:ApiCompatGenerateSuppressionFile=true'"

I think an issue is in different check in CP0007 and CP0002 rules between SDK 7.0.400 and 8.0.100-preview.7.23376.3. With .NET 7 SDK it does not recognise that base class is located in referenced nuget package which is not included in actual solution and mark that property is missing in new version. But in .NET 8 this works and in suppression file are unnecessary records. This behavior breaks our work when some developers in a team already play with .NET 8 and others and also build servers are still using .NET 7 SDK and we are not able to have same content in suppression file for all.

I know workaround is to explicitly specify SDK version in global.json but change behavior of base line validator to not throw error when there are unnecessary suppressions and instead report them as warning will help.

To Reproduce

  • download repro
  • set SOME_LOCAL_FOLDER to your nuget sources
  • create nuget package to your local nuget feed with command dotnet pack . --output SOME_LOCAL_FOLDER and SDK .NET 7.0.400
  • switch to branch newVersion
  • change used SDK in global.json to 8.0.100-preview.7.23376.3
  • create new version of the nuget package with enable baseline validation with command dotnet pack . --output SOME_LOCAL_FOLDER

Thank you

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions