Skip to content

Different default values of TargetPlatformVersions for the Class Library (26.0) and Exe (26.2) #25149

@snechaev

Description

@snechaev

Apple platform

macOS

Framework version

net10.0-*

Affected platform version

.net 10.0.201 / macos workload 26.2.10217/10.0.100

Description

I tried to move simple code var opts = new NSBindingOptions(); from the Exe project to the Class Library project. Both projects are fresh net10.0-macos projects after dotnet new.
Exe project with this code compiles and runs without problems.
Library project won't compile: Error CS0246 : The type or namespace name 'NSBindingOptions' could not be found.
After short investigation I realized that there are different TargetPlatformVersions calculated for the projects

  • for Exe TargetPlatformVersions=26.2
  • for Library TargetPlatformVersions=26.0

The NSBindingOptions bindings was added in the 26.2 SDK, so it become clear why the library project won't compile. But it is not clear why we get different values of the TargetPlatformVersions without any visible differences in the projects configuration.

Steps to Reproduce

  • Grab test solution test.zip
    • test code contained in the ViewController.cs and Class1.cs
  • build exe project dotnet build ./macOsApp - success.
  • build lib project dotnet build ./lib - error CS0246: The type or namespace name 'NSBindingOptions' could not be found

Expected: uniform behavior. Either both projects succeed or both fail.

Did you find any workaround?

Workaround: explicitly set tfm=net10.0-macos26.2 for the class library project.

Build logs

See the test.zip inside per-project folders.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions