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.
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 theExeproject to theClass Libraryproject. Both projects are freshnet10.0-macosprojects afterdotnet 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
TargetPlatformVersionscalculated for the projectsTargetPlatformVersions=26.2TargetPlatformVersions=26.0The
NSBindingOptionsbindings 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 theTargetPlatformVersionswithout any visible differences in the projects configuration.Steps to Reproduce
ViewController.csandClass1.csdotnet build ./macOsApp- success.dotnet build ./lib-error CS0246: The type or namespace name 'NSBindingOptions' could not be foundExpected: uniform behavior. Either both projects succeed or both fail.
Did you find any workaround?
Workaround: explicitly set tfm=
net10.0-macos26.2for the class library project.Build logs
See the test.zip inside per-project folders.