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

466 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge 9c185e1fff
[msbuild] Ask ditto to thin native libraries according to the architectures we're targetting. Fixes #13081. (#14403)
Ask ditto to thin native libraries and frameworks when copying them to the app
bundle to remove slices for architectures we're not building for.

Also add tests.

Fixes https://github.com/xamarin/xamarin-macios/issues/13081.

Co-authored-by: TJ Lambert <50846373+tj-devel709@users.noreply.github.com>
2022-04-07 08:17:01 +02:00
Rolf Bjarne Kvinge 7a0c7428b8
[dotnet] Don't list OS versions we don't support. (#14665)
Our min OS target versions are different between legacy Xamarin and .NET
(former supports earlier versions). The list of versions in the Versions.plist
contain all the versions supported by legacy Xamarin, but that's not correct
for .NET, so don't list any version in Version.plist that's lower than the
minimum OS version we support for a given platform.
2022-04-06 17:53:06 +02:00
Emanuel Fernandez Dell'Oca 3af92421f9
[dotnet] Adds platform specific RID options (#14643)
This enables Visual Studio to set a specific `RuntimeIdentifier` for each platform when building all target frameworks in a MAUI project.

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2022-04-06 09:39:33 +02:00
Rolf Bjarne Kvinge 6e348f0e65
[dotnet] Port the iOS tabbed app template to .NET. (#14592)
Ref: https://github.com/xamarin/xamarin-macios/issues/10747
2022-04-04 10:05:08 +02:00
Rolf Bjarne Kvinge c4879f5142
[dotnet] Adjust template descriptions to not say .NET 6, just plain .NET instead. (#14607) 2022-04-04 09:52:02 +02:00
Chris Hamons 11a7c84d52
[dotnet] Update macos template to visible at launch (#14581)
Fixes https://github.com/xamarin/xamarin-macios/issues/14420

Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2022-04-01 10:20:28 -05:00
Rolf Bjarne Kvinge 6fa6b75f19
[dotnet] Don't include @(Compile) and @(EmbeddedResource) items in @(BundleResource) items by default. Fixes #14442. (#14571)
Fixes https://github.com/xamarin/xamarin-macios/issues/14442.
2022-03-31 08:17:53 +02:00
Alexander Köplinger b8c493c3e1
Set IsImplicitlyDefined="true" on the System.Runtime.InteropServices.NFloat.Internal PackageReference (#14532)
* Set IsImplicitlyDefined="true" on the System.Runtime.InteropServices.NFloat.Internal

This unbreaks Central Package Management via https://github.com/microsoft/MSBuildSdks/tree/main/src/CentralPackageVersions which is being worked on for NuGet, see https://github.com/NuGet/Home/issues/6764

* Add test case

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2022-03-30 10:13:39 +02:00
Rolf Bjarne Kvinge 43f87ec4c1
[msbuild] Only conditionally copy the entire input directory from Windows in the Ditto task. (#14495)
Sometimes we want to copy the entire input directory from Windows to the Mac
when executing the Ditto task remotely, and sometimes we don't.

In particular we do not want to copy the input directory when the directory on
Windows is an incomplete mirror of what's on the Mac - one scenario being when
copying the app bundle to prepare for IPA creation. The .app directory on
Windows is not complete - all the files are there (maybe? not quite sure, but
that's beside the point here), but some may be empty, because when we only
care about the timestamp for a file, we'll create an empty file on Windows to
mirror the actual file on Mac. Copying this incomplete directory to the Mac,
overwriting the correct files there, will break things badly.

However, sometimes we're not mirroring a directory on Windows, but instead we
have directories as actual build input (for instances frameworks from NuGets),
and in that case we want to copy everything to the Mac.

So this PR adds a parameter to the Ditto task to optionally copy the directory
from Windows for remote builds, and we enable this behavior when we want it -
specifically when copying frameworks.

Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1506009 while not
regressing https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1492635.

Ref: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1506009
Ref: https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1492635
Ref: https://github.com/xamarin/xamarin-macios/pull/14375
2022-03-25 14:08:05 +01:00
Rolf Bjarne Kvinge a1a4771448
[dotnet] Update doc about breaking nfloat changes and when we generate a global using directive. (#14487) 2022-03-25 07:40:23 +01:00
Rolf Bjarne Kvinge d95f2d15ad
[dotnet] Use a variable for 'net6.0' instead of hardcoding it. (#14481)
This makes it easier to bump to 'net7.0' when that time comes.
2022-03-24 16:41:29 +01:00
Rolf Bjarne Kvinge 78963700e7
[dotnet] Only add a global nfloat using if we're compiling for C# 10 or later. Fixes #14434. (#14475)
Fixes https://github.com/xamarin/xamarin-macios/issues/14434.
2022-03-24 10:14:16 +01:00
Rolf Bjarne Kvinge d9e3206125
Merge branch 'main' into dotnet-dsyms 2022-03-23 22:24:51 +01:00
Rolf Bjarne Kvinge e44d0fd047
[.NET] Rename several DOTNET6_* variables to to DOTNET_*. (#14463)
Also rename DOTNET_VERSION to SYSTEM_DOTNET_VERSION to make it clear what it's
referring to (and to not clash with DOTNET6_VERSION which has now been renamed
to DOTNET_VERSION).

.NET 7 is right around the corner.
2022-03-23 08:07:34 +01:00
Rolf Bjarne Kvinge e5c81564e2 [msbuild/dotnet] Rework how we handle app bundle post processing. Fixes #14067.
Change dSYM generation and native stripping to occur immediately before code signing,
in a newly minted post processing target.

Challenges:

* Both calling 'strip' and 'codesign' on an executable modifies that executable,
  which means that we must make sure to not call 'dsymutil' on the same binary at
  a later point unless it's been rebuilt.
* Thus we must make sure to update 'dsymutil's stamp file whenever we call 'strip'
  and/or 'codesign' on an executable.
* Just like for code signing, we must store the libraries (either static or dynamic)
  we post process in extension/watch/rid-specific projects, so that these libraries
  can be loaded in containing projects and processed there.
* In universal .NET builds, debug symbols are created for the universal app bundle,
  not for each rid-specific version of the app bundle. So I had to add logic to create
  the native symbol lists (MtouchSymbolsList) for each rid-specific build, but then
  collect them and merge those lists for the universal app bundle.

The existing SymbolStrip call we did right after linking the native executable has
been removed, because we have to do that after creating the dSYM (which the GenerateDebugSymbols
target does).

Also add tests.

Fixes https://github.com/xamarin/xamarin-macios/issues/14067.
2022-03-22 16:14:26 +01:00
Rolf Bjarne Kvinge e369f466f7
[dotnet] Rename the DOTNET6 make variable to DOTNET. (#14441)
This is the follow-up to where the DOTNET variable was renamed SYSTEM_DOTNET.
2022-03-21 15:56:57 +01:00
Rolf Bjarne Kvinge 8b6d7d5914
[dotnet] Update template strings. (#14399)
When adding support for localizing template strings, this wasn't included
because it was merged after the template localization work started.
2022-03-14 18:21:16 +01:00
Bekir Ozturk af30c26381
[Localization] Turn on template localization on dotnet CLI (#14213) 2022-03-11 10:30:47 -05:00
Tim Miller d61f187614
Update code-behind templates to correctly support Dark Mode, bind text to the center of the screen (#14367) 2022-03-11 09:05:59 +01:00
Rolf Bjarne Kvinge bb655a3840
[dotnet] Only validate the RuntimeIdentifier if we need/use it. Fixes #13482. (#14339)
Fixes https://github.com/xamarin/xamarin-macios/issues/13482.
2022-03-09 08:22:52 +01:00
Rolf Bjarne Kvinge 3da0665ff5
[msbuild] Make the _NoSymbolStrip and _NoDSymUtil properties public by removing the leading underscore. (#14248)
These are useful properties that were exposed in legacy Xamarin as Mtouch*
properties.
2022-02-28 11:27:44 +01:00
Rolf Bjarne Kvinge c589b4cf4e
[msbuild] Store the .NET version in the app's Info.plist when building an app using .NET. Fixes #14108. (#14215)
Also change the key for our Info.plist entry with the version number in .NET, and document the change.

We now use "com.microsoft.<platform in lower case>" instead of "com.xamarin.ios" (for all platforms).

Fixes https://github.com/xamarin/xamarin-macios/issues/14108.

Co-authored-by: TJ Lambert <50846373+tj-devel709@users.noreply.github.com>
2022-02-24 20:44:42 +01:00
Rolf Bjarne Kvinge bd97933b60
[runtime] Remove ObjCRuntime.nfloat in favor of System.Runtime.InteropServices.NFloat. (#14197)
* Remove ObjCRuntime.nfloat (in favor of   System.Runtime.InteropServices.NFloat).
* Automatically add a reference to the System.Runtime.InteropServices.Internal
  package, so that developers get the new NFloat API (with operators) we've
  added post .NET 6 (but don't do this for .NET 7).
* Automatically add a global using alias for
  System.Runtime.InteropServices.NFloat -> nfloat. This is not behind the
  usual `ImplicitUsings` condition our other implicit usings are, because
  they're off by default for existing projects, and the main target for the
  global using alias for nfloat is upgraded projects.
* Automatically generate a global using alias (like above) in the generator
  for all code the generator compiles.
* Update xtro entries to reference System.Runtime.InteropServices.NFloat
  instead of ObjCRuntime.nfloat.
* Add a workaround for a hopefully temporary issue with .NET/CoreCLR where the
  wrong runtime pack is selected otherwise (without the new NFloat API, so
  nothing works at runtime).

Ref: https://github.com/xamarin/xamarin-macios/issues/13087
2022-02-24 16:51:12 +01:00
Rolf Bjarne Kvinge c0074d0c79
[dotnet] Hardcode the version band instead of inferring it. (#14225) 2022-02-23 20:43:27 +01:00
Rolf Bjarne Kvinge 4fd770c3c4
[msbuild/generator] Pass .NET's C# compiler to bgen to use. Fixes #12922. (#14192)
We can't execute mono's C# compiler when using .NET, so we need to tell bgen
where csc is in that case.

Fixes https://github.com/xamarin/xamarin-macios/issues/12922.
2022-02-23 09:36:43 +01:00
Rolf Bjarne Kvinge 166f42b987
[dotnet] Name all templates as preview templates. (#14210)
All templates except one were named "... (Preview)".

Now the one outlier has joined the rest.
2022-02-23 08:19:23 +01:00
Rolf Bjarne Kvinge 96c32e380e
[msbuild/dotnet] Make codesigning createdump work in universal apps. Fixes #14155. (#14196)
We don't sign each rid-specific bundle, but we sign the final merged app bundle instead.
This means that we must store the list of files to codesign from the rid-specific
build and load those lists before running codesign on the merged app bundle.

https://github.com/xamarin/xamarin-macios/issues/14155.
2022-02-21 08:24:09 +01:00
Alex Soto 72aa44989b
Update SignList.xml to look for our new Microsoft.* assemblies 2022-02-18 11:36:52 -05:00
Rolf Bjarne Kvinge 21d7dd8de3
[msbuild] Move debug-related targets to shared code. (#14180) 2022-02-18 16:35:28 +01:00
Rolf Bjarne Kvinge e25163f573
[.NET] Rename our product assemblies. Fixes #13748. (#13847)
Rename our product assemblies to:

* Microsoft.iOS.dll
* Microsoft.tvOS.dll
* Microsoft.macOS.dll
* Microsoft.MacCatalyst.dll

This makes it easy to distinguish between legacy Xamarin and .NET whenever the
product assembly is mentioned, and I've also chosen the platform part of the
name to match how the platforms are named elsewhere (this also makes it
possible to simplify our build logic, since we can remove a lot of special
casing).

Fixes https://github.com/xamarin/xamarin-macios/issues/13748.
2022-02-16 21:30:32 +01:00
Rolf Bjarne Kvinge 5b8250486f
[dotnet/msbuild] Run install_name_tool to fix the id for dylibs. Fixes #13999. (#14147)
Fixes https://github.com/xamarin/xamarin-macios/issues/13999.
2022-02-16 21:13:40 +01:00
Rolf Bjarne Kvinge a404081365
[dotnet] Add support for the PublishFolderType metadata on Content and BundleResource items. (#14162)
Add support for the PublishFolderType metadata on Content and BundleResource
items, which makes it possible to change the location in the app bundle for
these items (this was possible to do before with the Link metadata), but most
importantly it also makes it possible to choose to *not* bundle these items in
the app bundle (which was not possible before with the Link metadata, nor any
other means).

At first I thought setting CopyToPublishDirectory /
CopyToOutputDirectory=Never would accomplish that, but it turns out we don't
honor those, and since we already have this behavior of ignoring
CopyToPublishDirectory / CopyToOutputDirectory in legacy Xamarin, I didn't
want to change it in .NET.

So I added support for honoring the PublishFolderType metadata instead, which
is new and we already support for other item groups. This is accomplished by
adding all Content and BundleResource items with PublishFolderType set to the
ResolvedFileToPublish item group (where we already handle any
PublishFolderType values), and then we ignore such Content and BundleResource
items in our CollectBundleResources task.

Also update the documentation and add tests.
2022-02-16 20:54:14 +01:00
Rolf Bjarne Kvinge 404b6e9af5
[msbuild/dotnet] Set NoBindingEmbedding to 'true' by default in .NET. Fixes #12530. (#12694)
Not embedding third-party libraries in the binding assembly is the future, and
let's try to enable it by default starting with .NET.

Fixes https://github.com/xamarin/xamarin-macios/issues/12530.

Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2022-02-16 10:30:41 +01:00
Eric Erhardt 0f68a8231b
Default VerifyDependencyInjectionOpenGenericServiceTrimmability (#14130)
We need to use better default values for `$(VerifyDependencyInjectionOpenGenericServiceTrimmability)`.

This feature switch ensures that DynamicallyAccessedMembers are applied correctly to open generic types used in Dependency Injection.

In the base SDK, this switch is enabled when `PublishTrimmed=true`. However, iOS apps don't set `PublishTrimmed=true` until a Target. So devs are missing out on this validation.

Conversely, in published apps, we don't want to pay the cost of doing this validation. It was showing up in startup profiles on Android. So turning the feature switch off in Release builds (builds without debugging enabled).

Port of 90f546cacc

Note, in Android we used `PublishTrimmed` to set this property, but in iOS `PublishTrimmed` isn't set yet. So I followed the same pattern as `UseSystemResourceKeys`, which is the same scenario - when a dev is developing the app vs. a production build.
2022-02-15 08:39:28 +01:00
Rolf Bjarne Kvinge d8e7d2c854
[dotnet] Sign the 'createdump' executable. Fixes #13417. (#14111)
Fixes https://github.com/xamarin/xamarin-macios/issues/13417.
2022-02-15 08:28:29 +01:00
Rolf Bjarne Kvinge 8b3b6a7adf
[dotnet/runtime] Fix a few issues with regards to extensions in .NET. Fixes #13742. (#14115)
* Propagate the IsAppExtension variable correctly.

* Don't try to call mono_domain_set_config for app extensions in .NET.

  It doesn't look like it's needed, and it also immediately aborts anyway, so
  if it turns out to be needed, another solution would have to be implemented.

Fixes https://github.com/xamarin/xamarin-macios/issues/13742.
2022-02-15 08:27:25 +01:00
Rolf Bjarne Kvinge 5e462b1c21
[dotnet] Fix non-bundling of debug files for release builds. Fixes #14085. (#14103)
Fixes https://github.com/xamarin/xamarin-macios/issues/14085.
2022-02-09 16:46:04 +01:00
Rolf Bjarne Kvinge 352a0d818a
[dotnet] Include all files in the Resources subdirectory as bundle resources. Fixes #13808. (#14018)
Include all files in the project's Resources subdirectory as BundleResource
items (except .DS_Store files, which are pretty omnipresent on macOS).

Also, contrary to the other default includes, add a condition so files are
only included if we have a resource prefix (typically "Resources"), otherwise
the entire hard drive might be included, and that's not really what we want.

Fixes https://github.com/xamarin/xamarin-macios/issues/13808.
2022-02-07 18:55:31 +01:00
Rolf Bjarne Kvinge 42c87ab2f7
[runtime] Make Runtime.Arch a readonly field in .NET. Fixes #5518. (#14076)
* Make Runtime.Arch a readonly field.
* Tell the AOT compiler Runtime.Arch is a constant value.
* Tell the linker to stub out the method we use to fetch the current
  architecture from native code (it turned out a bit complicated to set the
  Arch field when it's readonly - the solution I came up with was to call a
  P/Invoke).

Test case (size of the main executable): link all (debug)

* Before:  33.522.704 bytes
* After:   33.506.112 bytes
* Difference: -16.592 bytes (-0.05 %)

There were no size differences in release mode, nor were there any size
differences in the "don't link" test, neither for debug nor release mode.

Fixes https://github.com/xamarin/xamarin-macios/issues/5518.
2022-02-07 08:05:41 +01:00
Rolf Bjarne Kvinge 9efcac2eb7
[dotnet] Update breaking changes docs. (#14044)
Make note about:

* Caveat with regards to IntPtr constructors having to be manually changed to
  be NativeHandle constructors.
* Moving NSFileProvider types.
2022-02-04 15:36:30 +01:00
Rolf Bjarne Kvinge 83e113f8f8
[CFNetwork] Remove the MessageHandler type from .NET. (#14056)
This type has been obsolete for over 3 years, it hasn't been updated in many
more years, and there are multiple newer and better alternatives available.

This meant we could remove a few more other (private/related) types as well.
2022-02-04 07:54:39 +01:00
Rolf Bjarne Kvinge 0bcb737d8a
[dotnet] Update docs about default inclusion in binding projects. (#14035)
Binding projects enable default compile items now, so the documentation saying
otherwise is outdated and must be rectified.

Ref: 499a69e772
2022-02-03 17:22:45 +01:00
imhameed adff9df98d
Link against the Compression framework. (#14034)
Mono will eventually use functions from the Compression framework to
decompress ICU data files during the runtime's initialization. Prepare
for this by linking against the compression framework.

Also see https://developer.apple.com/documentation/compression?language=objc.
2022-02-03 10:05:57 +01:00
Rolf Bjarne Kvinge 68aaef9ff7
[dotnet] Ask the linker to not mark copied assemblies if we're in a 'don't link' scenario. (#14011)
This speeds up builds significantly when the linker is disabled.

Test case: building tests/dotnet/MySimpleApp for macOS.

* Before: 37s
* After: 9s
* Difference: 26s (4x faster)

Test case: run the .NET tests

* Before: 2h55
* After: 1h43
* Difference: 1h12 (1.7x faster)

Contributes towards https://github.com/xamarin/xamarin-macios/issues/10251.
Ref: https://github.com/dotnet/linker/issues/2089
2022-02-02 08:36:17 +01:00
Rolf Bjarne Kvinge b1ce33ba51
[Foundation/ObjCRuntime] Use 'ObjCException' as the native exception type name for all platforms in .NET. Fixes #13855. (#13915)
* Use 'ObjCException' instead of 'MonoTouchException' as the managed exception
  type wrapping an NSException for all platforms in .NET (that was already the
  case for macOS, so no change there).
* Make the ObjCException class behave like the MonoTouchException class does.
* Move the ObjCException type to the ObjCRuntime namespace in .NET.

Fixes https://github.com/xamarin/xamarin-macios/issues/13855.

Co-authored-by: TJ Lambert <50846373+tj-devel709@users.noreply.github.com>
2022-02-01 17:24:57 +01:00
Rolf Bjarne Kvinge 4d2db6463b
[dotnet] Fix templates to use NativeHandle instead of IntPtr. Fixes #13979. (#14001)
Also make the (NativeHandle) constructor protected instead of public, to make
it clearer that it's not for public consumption.

And modify the template tests to execute the template if we can.

Fixes https://github.com/xamarin/xamarin-macios/issues/13979.
2022-02-01 17:22:53 +01:00
Rolf Bjarne Kvinge aaee4d9f27
[ModelIO] Adopt XAMCORE_4_0 changes in .NET. (#13941)
This turned out a bit complex, because numerous ModelIO APIs were initially bound
with wrong matrix types, and had to be rebound later (our matrix type was transposed
with regards to the native matrix type). The new versions often had to use worse
names, so that's being fixed now. This means that numerous tests had to be updated,
because the original API now returns non-transposed matrices.
2022-02-01 08:08:50 +01:00
Sebastien Pouliot 9e639d51d0
[net][objcruntime] Remove `UseAutoreleasePoolInThreadPool` in net profile (#13960)
and add it to the `BreakingChanges.md` document
2022-01-31 16:45:05 +01:00
Rolf Bjarne Kvinge a14712d6e3
[dotnet] Convert windows dir separators to mac dir separators for relative paths in the _StripAssemblyIL target. Fixes #13838. (#13919)
It seems that MSBuild doesn't always automatically convert directory
separators for relative paths, so we have to do it ourselves.

Thanks to @lauxjpn for diagnosing this and coming up with a fix.

Fixes https://github.com/xamarin/xamarin-macios/issues/13838.
2022-01-28 10:28:47 +01:00
Vlada Shubina 4a98896977
Ensure PackageType = Template for template packages (#13894)
## Problem

Template package does not appear on nuget.org correctly, as `packageType` in nupkg is set to `DotnetPlatform`.

## Solution

Disabled loading Microsoft.DotNet.SharedFramework.Sdk for template package build.
it doesn't seems to be needed and overwrites PackageType to DotnetPlatform, even though initially it is correctly set to 'PackageType'
2022-01-28 10:17:31 +01:00