Skip to content

Conversation

@rolfbjarne
Copy link
Member

@rolfbjarne rolfbjarne commented Nov 5, 2025

Since this may result in unintuitive behavior (library projects are built differently than executable projects, so code that works in an executable project may not compile when moved to a library project), an escape hatch was implemented as well.

One unintuitive behavior was when building an executable project with a library project from Windows: if the library project needs the remote connection, it would use a different workload, and different remote connection, than the executable project, which just wouldn't work. So we don't enable this new behavior when library projects need the remote connection (which is when bundle resources are precompiled for the library project; aka when BundleOriginalResources=false - note that it's enabled by default in .NET 10, so developers must opt in to run into this problem and thus not getting this new behavior).

Fixes #24043.

…Fixes #24043.

Since this may result in unintuitive behavior (library projects are built
differently than executable projects, so code that works in an executable
project may not compile when moved to a library project), an escape hatch was
implemented as well.

Fixes #24043.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a default Target Platform Version (TPV) for library projects across all Apple platforms (iOS, tvOS, macOS, MacCatalyst). When building a class library without an explicit TPV, the system now defaults to the lowest supported TPV for the current .NET version. This allows libraries to be built without specifying a TPV while maintaining compatibility.

Key changes:

  • Modified build system to set default TPV for libraries via new Makefile variables
  • Updated workload manifest generator to recognize lowest TPV per .NET version and conditionally import it for libraries
  • Enhanced test infrastructure to validate the default TPV behavior
  • Consolidated MyClassLibrary test projects to use shared source files

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/dotnet/UnitTests/ProjectTest.cs Added assertions to verify default TPV is correctly applied to library builds
tests/Makefile Added export of *_TARGET_PLATFORM_VERSION_LIBRARY variables to test configurations
scripts/generate-workloadmanifest-targets/generate-workloadmanifest-targets.cs Added logic to compute lowest TPV per .NET version and conditionally import for libraries
tests/dotnet/MyClassLibrary/shared.csproj New shared project file for consolidating common source files
tests/dotnet/MyClassLibrary/*/MyClassLibrary.csproj Updated to import shared project instead of duplicating code
tests/dotnet/MyClassLibrary/*/MyClass.cs Removed platform-specific duplicates
tests/dotnet/MyClassLibrary/MyClass.cs Now inherits from NSObject to ensure platform-specific behavior

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@dalexsoto
Copy link
Member

@rolfbjarne backport all the things!

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #502b6aa] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 502b6aab7c2e6bfb894688297b47cf811a5fbc1a [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [PR Build #502b6aa] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: 502b6aab7c2e6bfb894688297b47cf811a5fbc1a [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #502b6aa] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 502b6aab7c2e6bfb894688297b47cf811a5fbc1a [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #502b6aa] Tests on macOS X64 - Mac Sonoma (14) passed 💻

All tests on macOS X64 - Mac Sonoma (14) passed.

Pipeline on Agent
Hash: 502b6aab7c2e6bfb894688297b47cf811a5fbc1a [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #502b6aa] Tests on macOS M1 - Mac Monterey (12) passed 💻

All tests on macOS M1 - Mac Monterey (12) passed.

Pipeline on Agent
Hash: 502b6aab7c2e6bfb894688297b47cf811a5fbc1a [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #502b6aa] Tests on macOS M1 - Mac Ventura (13) passed 💻

All tests on macOS M1 - Mac Ventura (13) passed.

Pipeline on Agent
Hash: 502b6aab7c2e6bfb894688297b47cf811a5fbc1a [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #502b6aa] Tests on macOS arm64 - Mac Tahoe (26) passed 💻

All tests on macOS arm64 - Mac Tahoe (26) passed.

Pipeline on Agent
Hash: 502b6aab7c2e6bfb894688297b47cf811a5fbc1a [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #502b6aa] Tests on macOS arm64 - Mac Sequoia (15) passed 💻

All tests on macOS arm64 - Mac Sequoia (15) passed.

Pipeline on Agent
Hash: 502b6aab7c2e6bfb894688297b47cf811a5fbc1a [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 502b6aab7c2e6bfb894688297b47cf811a5fbc1a [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🚀 [CI Build #502b6aa] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 117 tests passed 🎉

Tests counts

✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
✅ linker: All 44 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 8 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 9 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 10 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: 502b6aab7c2e6bfb894688297b47cf811a5fbc1a [PR build]

@dalexsoto dalexsoto merged commit 60eda76 into main Nov 6, 2025
45 checks passed
dalexsoto pushed a commit that referenced this pull request Nov 6, 2025
…Fixes #24043. (#24181)

Since this may result in unintuitive behavior (library projects are
built differently than executable projects, so code that works in an
executable project may not compile when moved to a library project), an
escape hatch was implemented as well.

One unintuitive behavior was when building an executable project with a
library project from Windows: if the library project needs the remote
connection, it would use a different workload, and different remote
connection, than the executable project, which just wouldn't work. So we
don't enable this new behavior when library projects need the remote
connection (which is when bundle resources are precompiled for the
library project; aka when `BundleOriginalResources=false` - note that
it's enabled by default in .NET 10, so developers must opt in to run
into this problem and thus not getting this new behavior).

Fixes #24043.

---------

Co-authored-by: GitHub Copilot <copilot@github.com>
Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
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.

$(DefineConstants) is based off of $(TargetFramework) and may be inconsistent with actual referenced assemblies

4 participants