Граф коммитов

320 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge b5908a72d2 [dotnet] Use a task to collect decompressed *.[xc]frameworks. 2022-01-13 22:36:41 +01:00
Rolf Bjarne Kvinge 4c2d0fe103 [dotnet] Split decompressing zip files and figuring out what was inside the zip files in two different tasks.
Split decompressing zip files and figuring out what was inside the zip files
in two different tasks, so that we do the second part even if the first part
isn't done (it could have been done in a previous build).

This is required for rebuilds to work correctly.
2022-01-13 22:11:58 +01:00
Rolf Bjarne Kvinge 205f22ff75 [dotnet] Touch all the destination files when copying a directory to an app bundle.
This fixes the following problem:

* App with framework is built and signed.
* App is rebuilt, and the framework is copied in again.
* This time, the framework's executable's timestamp will be earlier than the
  timestamp when it was last signed, and as such it won't be signed again.

Fix this by touching all the copied files when copying a directory to the app bundle.
2022-01-13 22:09:02 +01:00
Rolf Bjarne Kvinge 214064d430 Merge remote-tracking branch 'origin/main' into dotnet-resolvedfiletopublish 2022-01-11 17:32:26 +01:00
TJ Lambert a0ad207ea7
[Dotnet] Automatically Allow Assets of all types and Test (#13346) 2022-01-10 08:32:05 -06:00
Rolf Bjarne Kvinge fa8f6a6f5c [dotnet] Update comment. 2021-12-22 10:17:35 +01:00
Rolf Bjarne Kvinge acdd27a9ef [dotnet] Update the relative path of every item left in ResolveFileToPublish.
Update the relative path of every item in the ResolveFileToPublish item group to
be relative to the root of the app bundle.
2021-12-22 10:17:35 +01:00
Rolf Bjarne Kvinge 62e5655009 [dotnet] Collect binding resource packages and remove them from the ResolvedFileToPublish item group.
Collect all the binding resource packages, add our binding resource packages to the
items that need to be resolved, and remove them from the ResolvedFileToPublish item
group.

Depending on the resolved content (static library, dynamic library, framework) of
a binding resource package, we must do different things , so these items must be
removed from the ResolvedFileToPublish item group.
2021-12-22 10:17:35 +01:00
Rolf Bjarne Kvinge 007bd92830 [dotnet] Collect dynamic libraries, add them to the _FileNativeReference item group, and remove them from the ResolvedFileToPublish item group.
Any dynamic libraries in _FileNativeReference will be copied to the app bundle elsewhere.
2021-12-22 10:17:35 +01:00
Rolf Bjarne Kvinge 6331fc6f23 [dotnet] Link with any static libraries, but remove them from the ResolvedFileToPublish item group.
Static libraries are not copied to the app bundle.
2021-12-22 10:17:35 +01:00
Rolf Bjarne Kvinge 434178fa2d [dotnet] Collect compressed plugins and remove them from the ResolvedFileToPublish item group.
The _DecompressPlugIns target will process all the items in the _CompressedPlugIns
item group, decompress them and add them to _DirectoriesToPublish. The compressed
file itself is not copied to the app bundle.
2021-12-22 10:17:35 +01:00
Rolf Bjarne Kvinge b27ef8033d [dotnet] Collect plugins and remove them from the ResolvedFileToPublish item group.
We can't keep plugins in the ResolvedFileToPublish item group, because plugins are
usually directories, which may contain symlinks, which the built-in publish logic
doesn't handle correctly.
2021-12-22 10:17:35 +01:00
Rolf Bjarne Kvinge 5423457fd8 [dotnet] Collect compressed frameworks into the _CompressedAppleFrameworks item group and remove them from ResolvedFileToPublish.
The _DecompressAppleFrameworks target will process all the items in the _CompressedAppleFrameworks
item group, decompress them and add them to _FrameworkNativeReference. The compressed
file itself is not copied to the app bundle.
2021-12-22 10:17:35 +01:00
Rolf Bjarne Kvinge 2244a45e56 [dotnet] Collect and resolve .xcframeworks into .frameworks and add the result to the _FrameworkNativeReference item group. 2021-12-22 10:17:35 +01:00
Rolf Bjarne Kvinge c61c71409a [dotnet] Add frameworks to the _FrameworkNativeReference item group, and remove them from ResolvedFileToPublish. 2021-12-22 10:17:35 +01:00
Rolf Bjarne Kvinge 010e7e216b [dotnet] The first thing we do after computing the bundle location for each path, is to re-populate the ResolvedFileToPublish item group with the results. 2021-12-22 10:17:35 +01:00
Rolf Bjarne Kvinge 583230824d [dotnet] Remove _BundleResourceWithOutputPath from ResolvedFileToPublish, we're already handling those files elsewhere. 2021-12-22 10:17:35 +01:00
Rolf Bjarne Kvinge 86b9fb4ea9 [dotnet] The 'createdump' executable goes in the same directory as all the assemblies 2021-12-22 10:17:35 +01:00
Rolf Bjarne Kvinge 7096d7626d [msbuild] Remove the static libraries (.a) we ship with Xamarin from ResolvedFileToPublish 2021-12-22 10:17:35 +01:00
Rolf Bjarne Kvinge 07f0f3eefb [dotnet] Only publish a single icu*.dat file 2021-12-22 10:17:35 +01:00
Rolf Bjarne Kvinge 59096ba942 [dotnet] We're not bundling the runtimeconfig.json file.
It's parsed at build time (in the _CreateRuntimeConfiguration target), and stored
in a binary format, so we don't need the original json file.
2021-12-22 10:17:35 +01:00
Rolf Bjarne Kvinge 22220b149c [dotnet] Start using the new ComputeBundleLocation task 2021-12-22 10:17:35 +01:00
Rolf Bjarne Kvinge 3dc0fe881a [dotnet] Add target to decompress compressed binding resource packages.
This new target will process all the items in the _CompressedAppleBindingResourcePackage
item group, decompress them, and then resolve the extracted results.
2021-12-22 10:17:35 +01:00
Rolf Bjarne Kvinge ee55170feb [dotnet] Add target to decompress compressed plugins.
This new target will process all the items in the _CompressedPlugIns item group,
decompress them, and add them to _DirectoriesToPublish for later copying into the
app bundle.
2021-12-22 10:17:35 +01:00
Rolf Bjarne Kvinge e617903fac [dotnet] Add target to decompress compressed frameworks.
This new target will process all the items in the _CompressedAppleFrameworks item
group, decompress them, resolve them if necessary (for .xcframeworks) and add them
to _FrameworkNativeReference.
2021-12-22 10:17:34 +01:00
Rolf Bjarne Kvinge 0d0b0bc86b [dotnet] Always set 'UseAppHost' and '_RuntimeIdentifierUsesAppHost' to 'false' in .NET.
Otherwise .NET might want to include an app host in the app, which ends up with a
build warning, because we don't use apphosts.
2021-12-22 10:17:34 +01:00
Rolf Bjarne Kvinge 86a3689b77 [dotnet] Make sure that MSBuild doesn't strip away our PublishFolderType metadata 2021-12-22 10:17:34 +01:00
Rolf Bjarne Kvinge 94b1536ba8 [dotnet] There's no need to compute the publish location if we're not building a (publishable) app 2021-12-22 10:17:34 +01:00
Rolf Bjarne Kvinge 3b187b4075 [msbuild] Rename the _CopyFrameworksToBundle target to _CopyDirectoriesToBundle
We're soon going to use this task to copy other types of directories (such as plugins)
as well, and in that case the old target name would be misleading.
2021-12-22 10:17:34 +01:00
Rolf Bjarne Kvinge 55f11650b3 [msbuild] Move list of target dependencies for _ComputeFrameworkFilesToPublish to a separate property 2021-12-22 10:17:33 +01:00
Rolf Bjarne Kvinge b695c8c837
[dotnet] Don't add FileNativeReferences to the main libraries to link with. Fixes #13503. (#13598)
Don't add FileNativeReferences to the main libraries to link with, because we
pass that list of main libraries to the LinkNativeCodeTask, and we're already
passing the FileNativeReferences for a different task parameter.

This means that we end up adding the file native reference twice to the linker
arguments, and that's wasteful. It can also cause problems if those linker
arguments aren't always computed in the same way (once as a relative path,
once as an absolute path for instance).

Fixes https://github.com/xamarin/xamarin-macios/issues/13503.
2021-12-21 08:13:53 +01:00
Rolf Bjarne Kvinge 40905dd1f7
[msbuild/dotnet] Add a FilterStaticFramework task to filter out frameworks of static libraries from frameworks we copy to the app bundle. (#13551)
A later PR will include a test case for this.
2021-12-16 07:41:53 +01:00
Chris Hamons 4cf12e3623
[msbuild] Teach _StripAssemblyIL task to support inputs with duplicate file names but different paths (#13571)
- Fixes https://github.com/xamarin/xamarin-macios/issues/13526
- F#, along with some other cases, have files to publish that have the same filename but different folder
- The most obvious example being resources assemblies: cs/FSharp.Core.resources.dll vs de/FSharp.Core.resources.dll
- I naively copied all files into one directory ignoring path, which does not work here at all
- DestinationSubPath seems to be set unconditionally by ResolvePackageAssets but #msbuild suggested not assuming it was always there (0fc72ddb75/src/Tasks/Common/ItemUtilities.cs (L126-L128))
- So use DestinationSubPath when it is around, else fall back to the old Filename + Extension
- Since there are now subdirectories inside stripped folder, extend MakeDir to cover all file's Directory path
- Tested by hand with FSharpiOSCoolApp (.NET), I can extend an auto test if desired
2021-12-15 16:35:41 -06:00
Rolf Bjarne Kvinge 69015b3cec
[dotnet] Honor 'TrimMode' to specify linker behavior if LinkMode/MtouchLink aren't set. Fixes #13518. (#13543)
* Change dotnet-linker to only care about whether we're actually trimming anything or not.
* Allow LinkMde/MtouchLink to not be set if TrimMode is set.
* Detect if any assemblies are linked or not by checking the global TrimMode
  property + any TrimMode properties on assemblies.

Fixes https://github.com/xamarin/xamarin-macios/issues/13518.
2021-12-15 09:27:00 +01:00
Marek Safar 462d6286c5
Include recently two more feature switches (#13532)
NullabilityInfoContextSupport - saves a lot by trimming all C# compiler generated nullable information
BuiltInComInteropSupport - no COM support on iOS
2021-12-15 08:17:37 +01:00
Rolf Bjarne Kvinge 342b312a73
Our current behavior is to detect any None, BundleResource or Content item that's (#13550)
named 'Info.plist', and assume that's the app manifest.

That doesn't quite work when we end up with multiple 'Info.plist' entries in any
of those item groups (one example being a framework as a BundleResource - all frameworks
have an Info.plist, and there's no good way to distinguish what the developer's intention
was).

So:

1. Implement a 'AppManifestDetectionEnabled' property to disable automatic app manifest
   detection.

2. Add a public 'AppBundleManifest' property that specifies the app manifest
   (this is just a renamed version of our previously private '_AppManifest' property).

This makes it possible for app developers to:

* Disable automatic app manifest detection.
* Still have an app manifest by specifying it manually.
* Disable automatic app manifest detection, but also not specify an app manifest
  manually (so no custom app manifest at all).

Also:

* Rename '_AppBundleManifest' to '_AppBundleManifestPath' to make it less confusing
  with the new 'AppBundleManifest' property.
2021-12-14 20:56:52 +01:00
Rolf Bjarne Kvinge c85d7721d5
[dotnet] Pass -dead_strip to the native linker when we can. (#13541)
Pass -dead_strip to the native linker like we do for legacy Xamarin:

* If there are no custom linker arguments.
* If all third-party bindings in the app has SmartLink = true (this doesn't
  show up in the PR, but the logic exists for legacy Xamarin and is already
  executed for .NET, the resulting Application.DeadStrip value just wasn't
  taken into account).

This shrinks the app size a bot for a Hello World app:

* Before:     10.659.731 (https://gist.github.com/rolfbjarne/b5892a5c7fb8663d38e2b69f67bce90c)
* After:       9.940.240 (https://gist.github.com/rolfbjarne/8404394180fb9971bd2f1475b747c70a)
* Difference:   -719.491 (-6.7 %)
2021-12-13 20:41:43 +01:00
Rolf Bjarne Kvinge b8e9c61409
[dotnet] Parse the -gcc_flags and -link_flags mtouch/mmp arguments and pass them to the native linker. (#13521) 2021-12-13 08:33:26 +01:00
Marek Safar c3943dbe58
Enable AggressiveAttributeTrimming (#13523)
This enables removing all kinds of infrastructure attributes for example SupportedOSPlatformAttribute (like old XI did).
2021-12-10 08:23:10 +01:00
Rolf Bjarne Kvinge 80dec2841f
[dotnet] Generate an itemgroup with the valid runtime identifiers and use it to detect invalid runtime identifiers. (#13484)
This way we don't have to update the runtime identifier validation when we add
support for new runtime identifiers.

We'll also have an item group that lists the valid runtime identifiers, which
is making it possible (although the item group is currently private) to query
the valid runtime identifiers (which is something the IDEs have expressed
interest in).
2021-12-03 07:57:08 +01:00
Rolf Bjarne Kvinge 6d5aeb1ab3 [dotnet] Fix detecting simulator builds for fat apps. 2021-12-01 22:13:31 +01:00
Rolf Bjarne Kvinge 4b17520a17 [dotnet] Run the AOT compiler for ARM64 bullds for the simulator 2021-11-30 18:20:43 +01:00
Rolf Bjarne Kvinge ac441c1106 [msbuild] Detect SdkIsSimulator better for .NET by using the RuntimeIdentifier instead of only the architecture.
This way we're able to detect that "iossimulator-arm64" is actually a RID for the simulator.
2021-11-30 18:20:43 +01:00
Rolf Bjarne Kvinge c7110dbd42 [dotnet] Add runtime packs. 2021-11-30 18:20:43 +01:00
Rolf Bjarne Kvinge 2aa21751a6
[dotnet] Show an error if an app developer tries to publish a simulator architecture. (#13462)
* [dotnet] Show an error if an app developer tries to publish a simulator architecture.

* We can't publish a simulator build, so show an error in that case.
* We can't change the default runtime identifier when publishing (to a
  publishable runtime identifier), because by the time we know we're
  publishing, it's too late to change the runtime identifier. This means that
  it'll be required for app developers to specify a runtime identifier when
  publishing to a mobile platform, since the current default runtime
  identifier is for a simulator build.

Partial fix for https://github.com/xamarin/xamarin-macios/issues/12997.

* Fix typo and improve naming.

* [dotnet] Don't use '_UsingDefaultRuntimeIdentifier', it's already used elsewhere in .NET
2021-11-29 23:13:48 +01:00
Rolf Bjarne Kvinge 4afc8f7e3f
[dotnet] Put packages (.ipa/.pkg) in the publish directory by default. (#13436)
Partial fix for #12997.
2021-11-24 16:00:16 +01:00
Rolf Bjarne Kvinge dbdebb4522
[dotnet] Import the aliased pack name, not the actual pack name. (#13426)
This fixes an issue where dotnet restore would fail trying to find the pack.

Also make the aliased name look more like the other names.
2021-11-23 15:53:08 +01:00
Rolf Bjarne Kvinge 639db2a2c8
[dotnet] Make sure that the relative publish dir has a trailing slash. (#13395)
Other code elsewhere assumes this is the case.
2021-11-19 17:14:30 +01:00
Rolf Bjarne Kvinge ab5bf2faba
[msbuild/dotnet] Build the Xamarin.PreBuilt.iOS app bundle. Fixes #12945. (#13342)
Build the Xamarin.PreBuilt.iOS app bundle instead of using a prebuilt bundle.

This makes sure that we're always using the latest BCL.

Some accurate build massaging was needed, because:

* To build the prebuilt app we need the iOS workload installed (into our build-local
  .NET installation).
* The iOS workload contains the Microsoft.iOS.Windows.Sdk pack.
* The Microsoft.iOS.Windows.Sdk pack contains the prebuilt app.

Thus we had a circular reference. Fortunately, the Microsoft.iOS.Windows.Sdk pack
is only required on Windows, which means we can break this circular reference by:

* Mark Microsoft.iOS.Windows.Sdk pack as only to be installed on Windows (unfortunately
  it seems we have to list the exact runtime identifiers for the platforms where
  to install the pack, so we can't do something like "win-*", but new variations
  of the "win-*" runtime identifier shouldn't show up all that often).
* Build the prebuilt app on macOS.

This way we don't need the Microsoft.iOS.Windows.Sdk pack when installing the iOS
workload locally.

The .NET build order is now:

* Build general sdk, runtime and ref packs for .NET.
* Build the prebuilt app.
* Build the Microsoft.iOS.Windows.Sdk pack.

Fixes https://github.com/xamarin/xamarin-macios/issues/12945.
2021-11-12 07:38:07 +01:00
Jonathan Peppers 7fb9bc98f0
[dotnet] add %(Platform) to any global @(Using) (#13196)
Context: https://github.com/dotnet/maui/pull/3018#pullrequestreview-792369556

In order for the .NET MAUI workload to properly implement implicit
global usings:

1. The .NET MAUI workload will add many `@(Using)` entries that
   conflict with each platform's APIs.

2. We need *something* to identify `@(Using)` is for a specific
   platform, so we can use a new `%(Platform)` metadata for this.

3. Late in .NET MAUI's MSBuild targets, we can do:

    <ItemGroup Condition=" '$(UseMaui)' == 'true' and ('$(ImplicitUsings)' == 'true' or '$(ImplicitUsings)' == 'enable') ">
      <Using Remove="@(Using->HasMetadata('Platform'))" />
    </ItemGroup>

In .NET 7, we might have a nicer design around this, but for now this
is the plan for .NET 6.
2021-11-02 07:37:58 +01:00