Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[msbuild] Add support for bundling original resources in libraries. Fixes #19028. #20557

Conversation

rolfbjarne
Copy link
Member

@rolfbjarne rolfbjarne commented May 3, 2024

If a library references resources, until now we've pre-compile/pre-processed
some of those before embedding them the library. This applies to resources of
the following item groups:

  • AtlasTexture
  • BundleResource
  • Collada
  • CoreMLModel
  • ImageAsset
  • InterfaceDefinition
  • SceneKitAsset

However, pre-processing resources as a few problems:

  • It requires a native (Xcode) toolchain.
    • This is unfortunate when building from Windows: the current approach is
      that when building a library as a referenced project, the remoting part
      is skipped, so all such resources are just dropped.
    • It also means building on Linux doesn't work.
  • It makes it impossible to merge resources with the same name, if we wanted
    to do that.

So I'm adding support for bundling the original resources in library projects.

This is enabled using the MSBuild property BundleOriginalResources=true,
which is turned off by default for .NET 8 and turned on by default for .NET 9+.

Additionally I've added PartialAppManifest items to the list of bundled
resources from class libraries.

Fixes #19028.

rolfbjarne and others added 10 commits May 3, 2024 10:35
This looks like an incorrect merge conflict resolution: the property
_UnpackLibraryResourcesDependsOn was declared twice, the second time
overwriting the first.

Pick the first declaration, since it's the newest and more complete one
(70a5d0d).
…ixes xamarin#19028.

If a library references resources, until now we've pre-compile/pre-processed
some of those before embedding them the library. This applies to resources of
the following item groups:

* AtlasTexture
* BundleResource
* Collada
* CoreMLModel
* ImageAsset
* InterfaceDefinition
* SceneKitAsset

However, pre-processing resources as a few problems:

* It requires a native (Xcode) toolchain.
    * This is unfortunate when building from Windows: the current approach is
      that when building a library as a referenced project, the remoting part
      is skipped, so all such resources are just dropped.
    * It also means building on Linux doesn't work.
* It makes it impossible to merge resources with the same name, if we wanted
  to do that.

So I'm adding support for bundling the original resources in library projects.

This is enabled using the MSBuild property `BundleOriginalResources=true`,
which is turned off by default for .NET 8 and turned on by default for .NET 9.

Fixes xamarin#19028.
Also enable nullability and fix any issues.
The SceneKitAsset items contains all the resources within a .scnasset directory.
However, we need to pass the .scnasset directory to the native tooling, so we compute
the path to the .scnasset directory, and create a new item for it.

This new item must have the correct LogicalName set, which is accomplished by:

* Not deleting the LogicalName from the original item before using it to compute
  the new item's LogicalName.
* Compute the correct LogicalName for the .scnasset, and actually set it.

This fixes an issue where we'd be unable to detec previously processed SceneKitAsset
items in universal builds, because the files wouldn't located where they should be
on disk.
Copy link
Contributor

github-actions bot commented May 3, 2024

⚠️ Your code has been reformatted. ⚠️

If this is not desired, add the actions-disable-autoformat label, and revert the reformatting commit.

If files unrelated to your change were modified, try reverting the reformatting commit + merging with the target branch (and push those changes).

@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.

@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] Tests on macOS X64 - Mac Sonoma (14) passed 💻

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

Pipeline on Agent
Hash: 2954c944923724ae551f9af6d57b2010963d7609 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: 2954c944923724ae551f9af6d57b2010963d7609 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: 2954c944923724ae551f9af6d57b2010963d7609 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

❌ [CI Build] Windows Integration Tests failed ❌

❌ Failed ❌

Pipeline on Agent
Hash: 2954c944923724ae551f9af6d57b2010963d7609 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

❌ [CI Build] Tests on macOS M1 - Mac Big Sur (11) failed ❌

Tests timed out

Pipeline on Agent
Hash: 2954c944923724ae551f9af6d57b2010963d7609 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build] Tests on macOS M1 - Mac Big Sur (11) passed 💻

All tests on macOS M1 - Mac Big Sur (11) passed.

Pipeline on Agent
Hash: 2954c944923724ae551f9af6d57b2010963d7609 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

❌ [CI Build] Windows Integration Tests failed ❌

❌ Failed ❌

Pipeline on Agent
Hash: 2954c944923724ae551f9af6d57b2010963d7609 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🔥 [CI Build] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

7 tests crashed, 9 tests failed, 139 tests passed.

Failures

❌ interdependent-binding-projects tests

🔥 Failed catastrophically on VSTS: test results - interdependent-binding-projects (no summary found).

Html Report (VSDrops) Download

❌ monotouch tests (MacCatalyst)

🔥 Failed catastrophically on VSTS: test results - monotouch_maccatalyst (no summary found).

Html Report (VSDrops) Download

❌ monotouch tests (macOS)

2 tests failed, 10 tests passed.
  • monotouch-test/Mac [dotnet]/Debug [dotnet]: TimedOut
  • monotouch-test/Mac Catalyst [dotnet]/Debug (ARM64) [dotnet]: BuildFailure

Html Report (VSDrops) Download

❌ monotouch tests (tvOS)

5 tests failed, 8 tests passed.
  • monotouch-test/tvOS - simulator/Debug (managed static registrar) [dotnet]: Failed
  • monotouch-test/tvOS - simulator/Release (managed static registrar, all optimizations) [dotnet]: Failed
  • monotouch-test/tvOS - simulator/Debug (LinkSdk): Failed
  • monotouch-test/tvOS - simulator/Debug (static registrar): Failed
  • monotouch-test/tvOS - simulator/Release (all optimizations): Failed

Html Report (VSDrops) Download

❌ monotouch tests (watchOS)

🔥 Failed catastrophically on VSTS: test results - monotouch_watchos (no summary found).

Html Report (VSDrops) Download

❌ msbuild tests

🔥 Failed catastrophically on VSTS: test results - msbuild (no summary found).

Html Report (VSDrops) Download

❌ mtouch tests

🔥 Failed catastrophically on VSTS: test results - mtouch (no summary found).

Html Report (VSDrops) Download

❌ xammac tests

🔥 Failed catastrophically on VSTS: test results - xammac (no summary found).

Html Report (VSDrops) Download

❌ xcframework tests

2 tests failed, 6 tests passed.
  • xcframework-test/iOS Unified 64-bits - simulator/Debug [dotnet]: TimedOut
  • xcframework-test/tvOS - simulator/Debug [dotnet]: TimedOut

Html Report (VSDrops) Download

❌ xtro tests

🔥 Failed catastrophically on VSTS: test results - xtro (no summary found).

Html Report (VSDrops) Download

Successes

✅ 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. 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 6 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 7 tests passed. Html Report (VSDrops) Download
✅ generator: All 2 tests passed. Html Report (VSDrops) Download
✅ install-source: All 1 tests passed. Html Report (VSDrops) Download
✅ introspection: All 8 tests passed. Html Report (VSDrops) Download
✅ linker: All 65 tests passed. Html Report (VSDrops) Download
✅ mac-binding-project: All 1 tests passed. Html Report (VSDrops) Download
✅ mmp: All 2 tests passed. Html Report (VSDrops) Download
✅ mononative: All 6 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 11 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: 2954c944923724ae551f9af6d57b2010963d7609 [PR build]

@rolfbjarne
Copy link
Member Author

Closing in favor of #20822.

@rolfbjarne rolfbjarne closed this Jul 5, 2024
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.

Add support for bundling original assets in library projects
2 participants