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

466 Коммитов

Автор SHA1 Сообщение Дата
Chris Hamons 6ce1ff7093
[NET6] Add binding project template for iOS and MacCatalyst (#13840)
- Fixes https://github.com/xamarin/xamarin-macios/issues/13578
- Uses older-style namespace with {} instead of top level due to https://github.com/xamarin/xamarin-macios/issues/13837
2022-01-25 10:05:56 -06:00
Rolf Bjarne Kvinge fa2173e5ef
[CFNetwork] Move the CFHost and CFHTTP* types to the CFNetwork namespace in .NET. (#13761)
These types come from the CFNetwork.framework, but for some reason they were bound inside CoreServices many years ago.

This resolves a potential issue where we might end up linking with the
CoreServices framework instead of CFNetwork framework (because we use the
namespace of types to determine which framework they belong to).
2022-01-19 08:07:06 +01:00
Rolf Bjarne Kvinge 6564841c6a Merge remote-tracking branch 'origin/main' into dotnet-resolvedfiletopublish 2022-01-14 11:00:16 +01:00
Rolf Bjarne Kvinge 9894605c4f
[SceneKit] Make SCNMatrix4 column-major in .NET. Fixes #4652. (#13695)
* Implement a column-major version of SCNMatrix4 in .NET to match native code.
* This was done by copying the existing SCMatrix4 implementation, and modify it
  as required (doing it with conditional compilation in the same file turned out
  to be quite messy, so I opted for using different files for legacy Xamarin and
  .NET).
* There was one major change: the matrix inversion algorithm is new (copied from
   .NET instead), because the legacy Xamarin version showed strange results with
  some test values.
* Add setters for SCNMatrix4.Column[0-3] for legacy Xamarin to match the .NET API.
* Add CreateFromColumns methods for legacy Xamarin to match the .NET API.
* Add tests for all the new API.

Fixes https://github.com/xamarin/xamarin-macios/issues/4652.
2022-01-14 07:30:19 +01:00
Rolf Bjarne Kvinge b5908a72d2 [dotnet] Use a task to collect decompressed *.[xc]frameworks. 2022-01-13 22:36:41 +01:00
Mauro Agnoletti 5c342f0283
Include Broker satellite assemblies to the sign list (#13688) 2022-01-13 16:30:33 -05:00
Rolf Bjarne Kvinge a2e4438536 Merge remote-tracking branch 'origin/main' into dotnet-resolvedfiletopublish 2022-01-13 22:13:00 +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 473df24a2e
[dotnet] Update breaking changes documentation to talk about nint/nuint. (#13675) 2022-01-12 12:45:52 +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
James Parsons 321ceb62a4
Remove xamarin iOS designtime targets import (#13659)
These files are no longer used by the XamarinVS extension and the import is therefore unnecessary.
2022-01-10 13:03:33 +01: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 19de8ca69e [dotnet] Add documentation about how we determine where files go in the app bundle 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 b169c806fc
[dotnet] Remove Runtime.Arch and ObjCRuntime.Arch from Mac Catalyst. Fixes #10312. (#13562)
Remove Runtime.Arch and ObjCRuntime.Arch from Mac Catalyst, because they don't
apply for a Mac Catalyst app (which is neither a simulator environment, nor a
device environment).

This means that code using these APIs will have to be re-evaluated to
determine what's the correct behavior for Mac Catalyst.

Also update our tests accordingly.

Fixes https://github.com/xamarin/xamarin-macios/issues/10312.
2021-12-15 22:32:14 +01: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 cc75748c90 [builds] Download & install the Mono workload as well. 2021-12-07 20:59:52 +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 f8b6699ab2 Merge remote-tracking branch 'origin/main' into arm64-sim 2021-12-02 09:38:36 +01:00
Rolf Bjarne Kvinge 5cc92ac564
[src] Add a new ObjCRuntime.NativeHandle type to represent native handles for .NET. Fixes #13126. (#13356)
Add a new struct, ObjCRuntime.NativeHandle, which will be used to represent
native handles for .NET (instead of using IntPtr). The main purpose is to be
able to use 'nint' as a number in API while not being prevented from using
native handles as well.

One example is NSMutableString, which has a constructor that takes a single
'nint capacity' parameter. With this change, we'll also be able to have a
constructor that takes a native handle in .NET - otherwise we'd have two
constructors with the same signature, because a C# 'nint' is just an 'IntPtr'.

This change required numerous changes pretty much everywhere. The work is
split up in commits as well as I was able to, and each commit explains what it
does.

Fixes https://github.com/xamarin/xamarin-macios/issues/13126.
2021-12-02 08:38:39 +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 c60e03baa1 [dotnet] Add documentation about this breaking change. 2021-11-29 08:54:17 +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
Matthew Leibowitz 5b61ea59a9
Use the MANIFEST_VERSION_BAND for the manifests (#13386)
It appears that the package IDs for the manifests retain the main .NET version band, such as 100 and 200, and the packs use the full version of 101 or 203.

This PR just uses the version band for the manifest packages.

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2021-11-19 09:24:30 +01:00
dotnet-maestro[bot] b2d97ffd3f
[main] Update dependencies from dotnet/installer (#13353)
* Update dependencies from https://github.com/dotnet/installer build 20211111.4

Microsoft.Dotnet.Sdk.Internal
 From Version 6.0.100-rtm.21552.8 -> To Version 6.0.101-servicing.21561.4

* Update dependencies from https://github.com/dotnet/installer build 20211112.12

Microsoft.Dotnet.Sdk.Internal
 From Version 6.0.100-rtm.21552.8 -> To Version 6.0.101-servicing.21562.12

* [dotnet] Use X.Y.Z00 as the version band for the sdk-manifests path.

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2021-11-15 22:54:55 +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
dotnet-maestro[bot] 48ef9469af
[main] Update dependencies from dotnet/installer (#13093)
* Update dependencies from https://github.com/dotnet/installer build 20211022.1

Microsoft.Dotnet.Sdk.Internal
 From Version 6.0.100-rtm.21521.3 -> To Version 6.0.100-rtm.21522.1

* Update dependencies from https://github.com/dotnet/installer build 20211022.16

Microsoft.Dotnet.Sdk.Internal
 From Version 6.0.100-rtm.21521.3 -> To Version 6.0.100-rtm.21522.16

* Update dependencies from https://github.com/dotnet/installer build 20211023.8

Microsoft.Dotnet.Sdk.Internal
 From Version 6.0.100-rtm.21521.3 -> To Version 6.0.100-rtm.21523.8

* Update dependencies from https://github.com/dotnet/installer build 20211024.1

Microsoft.Dotnet.Sdk.Internal
 From Version 6.0.100-rtm.21521.3 -> To Version 6.0.100-rtm.21524.1

* Add a dependency to Microsoft.NETCore.App.Ref.

That way we match what XA did here: 16c1226dde

It also makes Maestro update our NuGet.config for us, which additional feeds we seem
to need to build.

* [dotnet] Use all the sources in the NuGet.config when installing workloads.

* Update dependencies from https://github.com/dotnet/installer build 20211025.3

Microsoft.Dotnet.Sdk.Internal
 From Version 6.0.100-rtm.21521.3 -> To Version 6.0.100-rtm.21525.3

* Add dependency on Microsoft.AspNetCore.App.Ref.

* Update dependencies from https://github.com/dotnet/installer build 20211026.10

Microsoft.Dotnet.Sdk.Internal
 From Version 6.0.100-rtm.21521.3 -> To Version 6.0.100-rtm.21526.10

* [tests] Disable the implicit FSharp.Core reference.

Fixes this:

    xamarin-macios/tests/fsharp/dotnet/macOS/fsharp.fsproj : error NU1103: Unable to find a stable package FSharp.Core with version (>= 6.0.1)
    xamarin-macios/tests/fsharp/dotnet/macOS/fsharp.fsproj : error NU1103:   - Found 792 version(s) in dotnet-tools [ Nearest version: 6.0.2-beta.21519.1 ]
    xamarin-macios/tests/fsharp/dotnet/macOS/fsharp.fsproj : error NU1103:   - Found 46 version(s) in dotnet-public [ Nearest version: 6.0.0 ]
    xamarin-macios/tests/fsharp/dotnet/macOS/fsharp.fsproj : error NU1103:   - Found 0 version(s) in xamarin-impl
    xamarin-macios/tests/fsharp/dotnet/macOS/fsharp.fsproj : error NU1103:   - Found 0 version(s) in darc-pub-dotnet-aspnetcore-ae1a6cb-1
    xamarin-macios/tests/fsharp/dotnet/macOS/fsharp.fsproj : error NU1103:   - Found 0 version(s) in darc-pub-dotnet-aspnetcore-ae1a6cb
    xamarin-macios/tests/fsharp/dotnet/macOS/fsharp.fsproj : error NU1103:   - Found 0 version(s) in darc-pub-dotnet-runtime-4822e3c-1
    xamarin-macios/tests/fsharp/dotnet/macOS/fsharp.fsproj : error NU1103:   - Found 0 version(s) in darc-pub-dotnet-runtime-4822e3c-2
    xamarin-macios/tests/fsharp/dotnet/macOS/fsharp.fsproj : error NU1103:   - Found 0 version(s) in darc-pub-dotnet-runtime-4822e3c-4
    xamarin-macios/tests/fsharp/dotnet/macOS/fsharp.fsproj : error NU1103:   - Found 0 version(s) in darc-pub-dotnet-runtime-4822e3c-5
    xamarin-macios/tests/fsharp/dotnet/macOS/fsharp.fsproj : error NU1103:   - Found 0 version(s) in Dotnet arcade
    xamarin-macios/tests/fsharp/dotnet/macOS/fsharp.fsproj : error NU1103:   - Found 0 version(s) in dotnet6
    xamarin-macios/tests/fsharp/dotnet/macOS/fsharp.fsproj : error NU1103:   - Found 0 version(s) in macios-dependencies

* [tests] Use a specific FSharp.Core version.

* Update dependencies from https://github.com/dotnet/installer build 20211027.11

Microsoft.Dotnet.Sdk.Internal
 From Version 6.0.100-rtm.21521.3 -> To Version 6.0.100-rtm.21527.11

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2021-10-29 18:46:00 +02:00
Rolf Bjarne Kvinge 02431b9fc8
[.NET] Move the nfloat type to the ObjCRuntime namespace for .NET. (#13092)
Also move the NMath type from the System namespace to the ObjCRuntime namespace.

Ref: https://github.com/xamarin/xamarin-macios/issues/13087
2021-10-28 11:06:31 +02:00
Chris Hamons ab5c0c6b56
[net6] Fix ILStrip'ed apps to actually work again (#13098)
* [net6] Fix ILStrip'ed apps to actually work again

- In a late minute change to the ILStrip PR (https://github.com/xamarin/xamarin-macios/pull/12563) a change to support XVS support broke execution of Apps that were stripped
- Applications were broken because none of the stripped assemblies were actually copied into the bundle
- However, the tests still passed, because all assemblies that were there had no IL (zero assemblies total)

Now why did this happen?
- The stripped assemblies were changed to return via an msbuild Output Element
- Output Element can return an Property or ItemGroup, depending if you use the PropertyName or ItemName attributes
- Unfortunately I used PropertyName, when I expected an ItemGroup. So I silently had a property created instead.
- Thus zero items were added to the list of files to copy into the bundle
- Which was undetected as the test did not confirm files were copied in, and manual tests were not run so late into the PR (3 weeks after PR was opened)

How was it fixed?
- Correctly using ItemName on Output created a valid item group to reference
- However, that still failed with an absurdly confusing error:

 PATH/Microsoft.NET.Publish.targets(277,5): error MSB3024: Could not copy the file FILE to the destination file PATH, because the destination is a folder instead of a file. To copy the source file into a folder, consider using the DestinationFolder parameter instead of DestinationFiles.

- After a splunking through netcore targets, I found the metadata on these assemblies references really matters. Without it, they are not processed correctly at all.
- Thus, I updated ILStripBase to clone the existing metadata when changing the original assembly reference to the stripped path
- Finally, I corrected the test to assert that required files are copied in. I also manually ran our device test.

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2021-10-25 11:31:42 -05:00
Alex Soto 9c90fa8842
[CI] Update SignList.xml to fix publishing 2021-10-20 21:46:13 -04:00
Peter Collins c930ef845c
[dotnet/Templates] Add preview language (#12965)
Fixes: https://github.com/xamarin/xamarin-macios/issues/12955

Update the .NET 6 project templates to include "(Preview)" in the title
and include the "Mobile" classification where applicable. The phrase
".NET 6" has also been added to the description to help them stand out
from the regular Xamarin templates.
2021-10-11 08:00:01 +02:00
Chris Hamons a300dfc56b
[msbuild] Add ILStrip'ing for net6 applications. Fixes #11445. (#12563)
- Controlled by EnableAssemblyILStripping which defaults to true
- Integration test included

Before - https://gist.github.com/chamons/c7886f7bacbc2e5ac5966e4251d13e71
After - https://gist.github.com/chamons/148e1bef22fa336f953f3d02dcf20667

859,136 -> 527,872 managed

Fixes https://github.com/xamarin/xamarin-macios/issues/11445.
2021-10-05 09:43:22 -05:00
Rolf Bjarne Kvinge 10f833b032
[dotnet] Implement support for the MtouchFloat32 MSBuild property. Fixes #12524. (#12882)
Implement support for the MtouchFloat32 MSBuild property, and do so in a way
that allows us to change the default in the future, if we so wish.

Fixes https://github.com/xamarin/xamarin-macios/issues/12524.
2021-10-01 08:31:11 +02:00
Rolf Bjarne Kvinge 9286bfb793
[msbuild/dotnet] Compile project-level assets in the outer build for multi-rid builds. Fixes #12410. (#12847)
We don't need to compile project-level assets for every RuntimeIdentifier in
multi-rid builds, we can instead compile them just once in the outer build.

There is also a correctness issue here: we can't compile assets more than once
and expect to get the exact same compiled result every time (in particular
actool seems to be adding random bytes in to the compiled output), and this
creates a problem when trying to merge the different runtime-specific compiled
output into a universal binary.

We accomplish this by:

* Processing these assets in the outer build, before we execute the
  rid-specific inner builds.
* Store the paths to the assets we've processed in a file.
* In the inner builds, we read that file, and remove any matches from the
  corresponding item group.
* Make sure to copy the compiled assets to the app bundle at the end of the
  outer build.

These are the assets we currently handle this way:

* BundleResource
* ImageAsset
* InterfaceDefinition
* SceneKitAsset
* Collada
* TextureAtlas
* CoreMLModel

Also:

* Add a new test case (AppWithResource) that contains all these different
  types of assets.
* Add support for the ScnTool task on Mac Catalyst (which the new test case
  revealed was missing).

Fixes https://github.com/xamarin/xamarin-macios/issues/12410.
2021-09-30 08:25:10 +02:00
Rolf Bjarne Kvinge e2d1777cc7
[dotnet] Show an error if we must link, but linking has been disabled. Fixes #12372. (#12832)
For executable projects, we must run the linker (otherwise we won't produce
something that can be executed).

We'll enable the linker by default in these cases, but if the developer has
manually disabled the linker (if the linker fails to execute for any reason,
it will suggest that the developer disables it), then we should show an error
explaining why.

Fixes https://github.com/xamarin/xamarin-macios/issues/12372.
2021-09-27 07:28:10 +02:00
Rolf Bjarne Kvinge 4d5616687a
[dotnet] Fix an issue where we wouldn't re-link if some files changed. (#12794) 2021-09-24 13:20:03 +02:00
Chris Hamons a6eb528197
[net6][msbuild] Set SelfContained for AppExtensions sooner to fix publishing (#12703)
This PR resolves a crash when running the linker on publishing iOS extensions.

The crash would occur here in failing to resolve corelib.

The reason this would fail was System.Private.CoreLib.dll was not in input_assemblies.

This was because we were passes the set of reference assemblies not the expected 'real' ones, and those do not include CoreLib.

After a bunch of digging, this was because _ComputeManagedRuntimePackAssembliesIfSelfContained target was not being set as a condition of _ComputeAssembliesToPostprocessOnPublish.

_ComputeManagedRuntimePackAssembliesIfSelfContained happened to be the place these were added, and wasn't being set since it has a condition of $(SelfContained) == 'true'

Now confusingly SelfContained WAS being set to true, but only in the targets file, which was too late, as it was checked in a 'global' property group outside of a target.

This means we'd fail to set SelfContained until after the condition, and not run.

This was verified by setting /p:SelfContained=true to true.

I also looked at removing the condition above, since https://github.com/dotnet/runtime/issues/54406 is fixed, however this caused project that didn't set RuntimeIdentifier to fail.
2021-09-20 09:40:41 -05:00
Rolf Bjarne Kvinge 499a69e772
[dotnet] Enable default compile items for binding projects. Fixes #12532. (#12758)
Enable default compile items for binding projects, and just exclude any api definition
and core source from any automatically included files.

Fixes https://github.com/xamarin/xamarin-macios/issues/12532.
2021-09-20 13:41:20 +02:00
Rolf Bjarne Kvinge 728347ad63
[dotnet] Remove watchOS code and from our .NET support. (#12764)
It's not tested, and thus has probably already bitrotted. If we add support
for watchOS to .NET in the future, it would likely be easier to start from
scratch (copying some of the other platforms), than having incomplete and
bitrotted code.
2021-09-20 07:40:03 +02:00
Rolf Bjarne Kvinge 04548c7da0
[msbuild/dotnet] Include font files by default in .NET apps, and implement a way to automatically register them. Fixes #12536. (#12752)
* Automatically include *.ttf, *.ttc and *.otf in .NET projects as BundleResource
  items (if these files are found within the Resources/ subdirectory).
* Add support for a 'RegisterFont' metadata on BundleResource items, where if set
  to 'true', we'll register the font file in the Info.plist as required by the target
  platform.
* Add tests.

Fixes https://github.com/xamarin/xamarin-macios/issues/12536.
2021-09-17 10:18:09 +02:00
Rolf Bjarne Kvinge 2534607148
[dotnet-linker] Mark protocol interfaces when using the dynamic registrar. Fixes #12644. (#12737)
Fixes this test failure when running monotouch-test with the dynamic registrar and
linking has been enabled:

    MonoTouchFixtures.ObjCRuntime.RegistrarTest
        [FAIL] TestProtocolRegistration :   UIApplicationDelegate/17669
            Expected: True
            But was:  False

This is a port of what we do during linking for legacy Xamarin apps.

Ref: 682f54da87

Fixes https://github.com/xamarin/xamarin-macios/issues/12644.
2021-09-16 08:16:39 +02:00
Rolf Bjarne Kvinge bfb27da6b6
[msbuild/dotnet] Make 'LinkSdk' the default linker mode for Mac Catalyst when building for Release, and 'None' the default when building for Debug. Fixes #12264. (#12701)
Fixes https://github.com/xamarin/xamarin-macios/issues/12264.
2021-09-13 16:12:58 +02:00
Filip Navara 219fb1a753
Remove IsXcode8 (#12671)
* Remove IsXcode8

* Remove other _ForgeMetal references
2021-09-09 09:23:32 +02:00
Rolf Bjarne Kvinge cb998a3589
[msbuild/dotnet] Don't use the built-in publishing logic in .NET to copy frameworks to the app bundle. Fixes #12369. (#12656)
.NET/MSBuild don't handle symlinks properly [1], which means that we can't ask
.NET to copy frameworks to the app bundle, since frameworks may contain
symlinks.

In our case, the symptom was that instead of copying symlinks, the file the
symlink pointed to was copied instead, and then codesign complained about
invalid bundle format when we tried to sign the framework.

We fix this by having our own target (_CopyFrameworksToBundle) to copy
frameworks to the app bundle (instead of adding all the files in the
frameworks to the ResolvedFileToPublish item group), and then using 'ditto' to
copy the frameworks.

In order to create a test case for this, I also made the macOS and Mac
Catalyst versions of the XTest framework use symlinks:

* Create a proper XTest framework bundle hierarchy for macOS and Mac Catalyst
  by using the typical symlink structure (actual files in the Versions/A
  subdirectory, and then symlinks pointing into that directory).
* Create a separate Info.plist for each platform for XTest.framework, since
  using an otherwise correct framework makes tooling (such as codesign)
  complain if the Info.plist isn't correct too.

This made our existing tests show the bug.

Finally I had to fix signing frameworks where the executable is a symlink.

We were first resolving symlinks for the input - say we had an
Example.framework/Example symlink to Example.framework/Versions/A/Example -
and then checking the parent directory if it's a framework. The parent
directory of 'Example.framework/Versions/A/Example' is 'A', which did not meet
our framewrok condition (if it ends with '.framework').

The fix is to adjust the logic to resolve symlinks after checking if the input
is a framework or not.

[1]: https://github.com/dotnet/msbuild/issues/6821

Fixes https://github.com/xamarin/xamarin-macios/issues/12369.
2021-09-09 09:11:25 +02:00
Rolf Bjarne Kvinge c2fda6ebf9
[dotnet] Enable LLVM by default for release builds. Fixes #12147. (#12660)
Fixes https://github.com/xamarin/xamarin-macios/issues/12147.
2021-09-08 18:04:39 +02:00
Jonathan Peppers 1de22290d7
[dotnet] rename $(AppleShortVersion) to $(ApplicationDisplayVersion) (#12647)
Context: https://github.com/dotnet/maui/issues/1662
Context: https://github.com/xamarin/xamarin-android/pull/6139

Previously:

* `$(ApplicationVersion)` mapped to `CFBundleVersion`
* `$(AppleShortVersion)` mapped to `CFBundleShortVersionString`

To be able to leverage identical property names on iOS/Android,
we're changing this to:

* `$(ApplicationVersion)` maps to `CFBundleVersion`
* `$(ApplicationDisplayVersion)` maps to `CFBundleShortVersionString`

Lastly, let's allow `$(ApplicationDisplayVersion)` to set `$(Version)`,
so the various C# assembly-level attributes are all set to the same value.
2021-09-08 10:13:29 -04:00
Rolf Bjarne Kvinge 24ea02759f
[dotnet] Support SupportedOSPlatformVersion. Fixes #12336. (#12638)
* Add support for the SupportedOSPlatformVersion MSBuild property, and write
  it to the Info.plist for the corresponding minimum OS version.
* If there are any minimum OS version in the Info.plist, we'll now show an
  error if it doesn't match SupportedOSPlatformVersion.

This unfortunately means that if there's any minimum OS version in any
Info.plist, then that will most likely have to be moved to the
SupportedOSPlatformVersion property (or removed entirely if that's the right
choice), since it's unlikely to match the default value for
SupportedOSPlatformVersion. However, this was deemed to be the best option for
the future (it's a one-time pain during migration).

Also add new tests, update existing tests, and update the templates.

Fixes https://github.com/xamarin/xamarin-macios/issues/12336.
2021-09-08 09:20:05 +02:00
Matthew Leibowitz 14b77dc8ea
Generate msi files and VS setup authoring for all .NET 6 platforms (#12581)
* Update vs-insertion-prep.yml

* Remove filters from symbol package download as well

* [temp] Changes for testing

* Shorten manifest name

* Shorten manifest name take 2

* Add ComponentResources and WorkloadPackages for tvOS and macOS

* Don't shorten MacCatalyst name, version string replacement should suffice

* Revert "Don't shorten MacCatalyst name, version string replacement should suffice"

This reverts commit d1c1d1d89d.

* Replace long macOS versions in .msi files

* Shorten tvossimulator msi names

* Test with real signing

* Revert testing changes

* Enable tests

Co-authored-by: Peter Collins <pecolli@microsoft.com>
2021-09-01 13:55:08 -04:00
Peter Collins 12d8b37f4f
[ci] Authenticode sign Mono.Options.dll (#12585)
Commit 91c6517f bumped to a new Mono.Options package version that
included symbol files, however it appears to be missing a Microsoft
digital signature.  We can fix this by signing the file ourselves rather
than skipping it.
2021-08-30 20:53:46 -04:00
James Parsons 8ff26838ec
Import .NET 6 property page targets path in iOS sdk targets (#12556)
* Import .NET 6 property page targets path in iOS sdk targets

* Fixes MSBuildExtensionsPath casing on Microsoft.iOS.Windows.Sdk.targets

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Co-authored-by: Emanuel Fernandez Dell'Oca <ema@xamarin.com>
2021-08-27 12:17:06 +02:00
Rolf Bjarne Kvinge 93b2b7f2b7
Merge branch 'main' into dotnet-compileappmanifest 2021-08-26 17:29:19 +02:00
Filip Navara e3c915b3cf
Remove duplicate mention of "SceneKit Assets" (#12543) 2021-08-25 14:49:19 +02:00
Rolf Bjarne Kvinge 197b564c21 Merge remote-tracking branch 'origin/main' into darc-main-971a17ce-2b67-4dbe-bb13-8308d33e5f58 2021-08-24 07:26:26 +02:00
Rolf Bjarne Kvinge b3dff34ea5 [msbuild] Rework how the app manifest is created.
How we create the app manifest (Info.plist) has to be modified so that we can add
support for getting all the values from MSBuild properties (i.e. no Info.plist in
the project), as well as having multiple partial app manifests as well, that gets
merged into the final app manifest.

Here's the new process:

1. The user can specify values in multiple ways:

    * An Info.plist in their project file (by using a `None` item with
      filename "Info.plist" or with a `Link` metadata with filename
      "Info.plist"). We figure this out in the DetectAppManifest target.
    * A partial plist in their project (using the `PartialAppManifest` item group)
    * Some MSBuild properties can also add values.

    The precedence is: MSBuild properties can be overridden by the Info.plist,
    which can be overridden by a partial plist.

2. In the `CompileAppManifest` target we get all the inputs from above, and compute
a temporary app manifest, which is written to a temporary output file.

3. In the `ReadAppManifest` target, we read the temporary output file and outputs
numerous MSBuild properties (most of then private)

4. We run other targets that may add more entries to the final app manifest (these
tasks might depend on the values from `ReadAppManifest`). These entries are written
to partial plists, and added to the _PostCompilePartialAppManifest item group.

   The targets in question are:

	* _CompileImageAssets * _CompileCoreMLModels

5. In the new `WriteAppManifest` target, we read the temporary output file from `ReadAppManifest`
+ any `_PartialAppManfiest` items and merge them all together to get the final Info.plist.

This also required moving the computation of CFBundleIdentifier from the DetectSigningIdentity
task to the CompileAppManifest task. This also meant reordering these two tasks,
so that the DetectSigningIdentity task is executed after the CompileAppManifest task
(technically after the ReadAppManifest task), because the DetectSigningIdentity task
needs to know the bundle identifier.

This way we can handle multiple scenarios easily (most of this is not covered by
these changes, and will be implemented separately):

* No Info.plist at all, all non-default values come from MSBuild properties.
* A single Info.plist, where everything is specified.
* An Info.plist with multiple partial app manifests as well.
2021-08-23 17:46:33 +02:00
Rolf Bjarne Kvinge fa8e792040 [dotnet/msbuild] Create *DependsOn properties for several targets. 2021-08-23 17:46:33 +02:00
Rolf Bjarne Kvinge 92c00452a6 [dotnet] Use lowercase in several places due to https://github.com/dotnet/sdk/issues/19994. 2021-08-23 15:13:24 +02:00
Rolf Bjarne Kvinge 81ab58d897 [dotnet] Stop using DOTNETSDK_WORKLOAD_MANIFEST_ROOTS. Fixes #12101.
I can't seem to make it work anyway.

Fixes https://github.com/xamarin/xamarin-macios/issues/12101.
2021-08-23 15:13:24 +02:00
Rolf Bjarne Kvinge 49e142243d [dotnet] Remove the workaround for a broken Microsoft.NET.Sdk.Maui workload.
It's not needed anymore, and it also breaks our build because .NET gets confused.
2021-08-23 15:13:24 +02:00
Rolf Bjarne Kvinge 91d663be3d [dotnet] Install the runtime packs too, now they can be resolved from the packs folder. 2021-08-23 15:13:24 +02:00
Peter Collins c272040bdb
[ci] Push .NET 6 packages to dnceng dotnet6 feed (#12492)
We should now have the ability to push to the `dotnet6` feed that
contains the rest of the .NET 6 SDK Workload packages.  This should help
simplify workload acquisition.  The .nupkg files containing .msi the
.msi installers used for VS insertions will also now be pushed to this
feed.
2021-08-20 11:33:47 +02:00