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

128 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge 38acfafd38 [msbuild] Move/document a few properties related to signing and packaging. 2021-07-27 13:52:46 +02:00
Rolf Bjarne Kvinge a6b10696aa [msbuild] Accept both 'CodeSigningKey' and 'CodesignKey' as synonyms.
This makes it easier to use the same csproj for multiple platforms for customers.
2021-07-27 13:52:46 +02:00
Rolf Bjarne Kvinge b62b6213e2 [msbuild] Move the EnablePackageSigning variable to shared code.
So that it's set for both macOS and Mac Catalyst.
2021-07-27 13:52:46 +02:00
Rolf Bjarne Kvinge ea61948502 [msbuild] Merge the EnableSGenConc properties.
We use two different properties for the same thing: MtouchEnableSGenConc and
EnableSGenConc. Going forward, we're sticking with just EnableSGenConc, but
we'll keep accepting MtouchEnableSGenConc if it's set.
2021-07-27 13:52:46 +02:00
Rolf Bjarne Kvinge a2a2221c5e [msbuild] Unify the IsAppExtension property 2021-07-27 13:52:46 +02:00
Rolf Bjarne Kvinge 1e8698ae9b [msbuild] Unify the ArchiveOnBuild property 2021-07-27 13:52:46 +02:00
Rolf Bjarne Kvinge 3accf61ffd [msbuild] Unify the _CanOutputAppBundle property. 2021-07-27 13:52:46 +02:00
Rolf Bjarne Kvinge 1e496ba458 [msbuild] Move the logic to create .pkg files from Mac-specific target files to shared target files.
Because we need it for Mac Catalyst as well.
2021-07-27 13:52:46 +02:00
Rolf Bjarne Kvinge 0549af9736
[dotnet] Add support for the interpreter + AOT when needed. Fixes #11421 and #11724. (#12211)
* Add support for the interpreter everywhere.
* Add support for the AOT compiler everywhere we didn't support it before,
  because the interpreter needs it (at least System.Private.CoreLib.dll must
  be AOT-compiled when using the interpreter).
* Do FullAOT compilation on Mac Catalyst/ARM64 if we're not using the
  interpreter, since we can't use the JIT.
* Fix monotouch-test to be green on Mac Catalyst/ARM64.

Fixes https://github.com/xamarin/xamarin-macios/issues/11724.
Fixes https://github.com/xamarin/xamarin-macios/issues/11421.
2021-07-27 07:39:43 +02:00
Rolf Bjarne Kvinge 170ab44c7c
[msbuild] Unify the Archive task between iOS and Mac. (#12200)
The iOS version and the Mac version were slightly different in that they were
adding different things to the archive, but both seemed to be resilient to
those files not existing, so I just merged both implementations to try to add
everything to the archive.
2021-07-26 09:19:01 +02:00
Rolf Bjarne Kvinge 5d07e8de59
[msbuild] Make sure DeviceSpecificOutputPath always has a trailing slash. Fixes #12158. (#12162)
Fixes https://github.com/xamarin/xamarin-macios/issues/12158.
2021-07-26 08:58:13 +02:00
Rolf Bjarne Kvinge adc63843cd
[msbuild] Share the _CodesignVerify target between iOS and Mac. (#12142)
This brings the iOS logic to verify the signature in app extensions to Mac.
2021-07-22 15:48:19 +02:00
Rolf Bjarne Kvinge d26bdf97bf [dotnet] Parse --dlsym and pass it to the dotnet-linker tasks. 2021-07-22 10:36:21 +02:00
Rolf Bjarne Kvinge 7f505c35d5 [dotnet] Rework how we compute the TargetArchitectures property.
Add a _MapRuntimeIdentifierToTargetArchitecture target that computes the
TargetArchitectures property from either the RuntimeIdentifier or
the RuntimeIdentifiers properties.

Also make sure this target is executed before _ComputeTargetArchitectures.

This is required so that we have a correct TargetArchitectures value for
multi-rid builds when compiling the app manifest (Info.plist).
2021-06-23 18:38:46 +02:00
Rolf Bjarne Kvinge f9d0159e07
[msbuild] Share several cleaning targets between Xamarin.iOS and Xamarin.Mac. (#11898)
The iOS version of the cleaning tasks were much more comprehensive, so those
won out when there were any differences.

This also required moving the GetDirectoriesTask to shared code.
2021-06-11 16:39:44 +02:00
Sebastien Pouliot cd9a87cac6
[windows][msbuild] Fix the use of a windows path inside `_PrepareDebugSymbolGeneration` (#11870)
Revert a small part of #10409 so the path evaluation always happens on
the mac computer (even if the build is done from Windows)

Also dded a comment to avoid repeating that mistake again

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

Move task so it also work for Xamarin.Mac (since this is now shared code)
2021-06-09 09:19:42 -04:00
Emanuel Fernandez Dell'Oca d5f1671184
[dotnet] Fix _DetectSdkLocations from Windows (#11451)
This task ends up setting as env variable the Xamarin Sdk root directory on the Mac, but when building from Windows it was setting the Windows path, so instead we need to override it with the proper value on macOS.

This should not change the original behavior when building from macOS.
2021-05-06 07:42:43 +02:00
Rolf Bjarne Kvinge 6225cac669
[msbuild/dotnet] Fix build logic when using .NET to not try to use nor require any version of installed Xamarin.iOS/Xamarin.Mac. Fixes #10827. (#11433)
* [dotnet] Ship the buildinfo file.

* [msbuild/dotnet] Fix build logic when using .NET to not try to use nor require any version of installed Xamarin.iOS/Xamarin.Mac. Fixes #10827.

We do this by setting the _XamarinSdkRoot variable in our .NET logic, which
our existing shared build logic reads, passes to the DetectSdkLocations task,
and then sets our override environment variable
(MD_MTOUCH_SDK_ROOT/XAMMAC_FRAMEWORK_PATH) to the install location, so that
existing code (which honors the override variable) continues to work as-is.

Fixes https://github.com/xamarin/xamarin-macios/issues/10827.
2021-05-04 21:36:48 -04:00
Peter Collins 7a5c28f6cc
[msbuild] Rename $(_UsingXamarinSdk) to $(UsingAppleNETSdk) (#11270)
The `$(_UsingXamarinSdk)` property has been renamed to help improve
external usability.  This change increases parity with the Android SDK,
which currently defines `$(UsingAndroidNETSdk)` for internal and
external use.
2021-04-21 21:32:33 -04:00
Rolf Bjarne Kvinge 76666ccbef
[msbuild] Accept 'UseInterpreter' as an alternative for 'MtouchInterpreter'. Fixes #11138. (#11252)
Accept 'UseInterpreter' as an alternative for 'MtouchInterpreter', so that we
support the same variable name between iOS and Android.

Fixes https://github.com/xamarin/xamarin-macios/issues/11138.
2021-04-21 15:37:16 +02:00
Sebastien Pouliot 4560862966
[msbuild] Fix copy/paste error from #11196 (#11206)
Not sure how I could mess up a copy/paste between file - but I succeeded
to create a subtle bug (would have expected it more crash happy)

Fix issue #11151
2021-04-14 09:39:39 -04:00
Rolf Bjarne Kvinge 1d9c9baf25
[msbuild] Fix ItemName vs PropertyName confusion in task output. (#10936)
There doesn't seem to have been any ill effects from the confusion, but it's
better done the right way.
2021-03-25 15:51:37 +01:00
Rolf Bjarne Kvinge 1da2d452dd
[msbuild/dotnet] Add support for parsing --setenv from bundler arguments. (#10896)
Add support for parsing --setenv from bundler arguments and passing them to
dotnet-linker so that the environment variables can be baked into the app at
launch (like they would be for mtouch/mmp).
2021-03-18 15:15:02 +01:00
mathieubourgeois a921ee2fb1
Xamarin.Mac native Apple Silicon targetting support (#10115)
* Add support for Xamarin.Mac arm64

* Add compile product definition task

Xamarin.Mac can be provided with a ProductDefinition file for the generated pkg. Normally, providing a product definition was optional. However, with Apple Silicon, we have an extra issue : `productbuild` needs to know what architectures your package target. If not provided with them, it will guess to the best of its abilities. However, on Catalina and lower, the guess is x86_64, even if you have an arm64 slice. To fix this, we add a new task to compile the product definition and use this file to create the pkg. If you provide your own Product Definition, we can check and warn if the architectures don't match what we expect. If the file doesn't exist or there is no architecture, we set it ourselves based on our target architectures.

* Don't reference dynamic objC_send on arm64

When building in debug, we currently try to link dynamic objC_send symbols when targeting a 64-bit architecture. However, this is actually only defined on Intel architectures, not on arm64, so we end up failing because we're referring symbols that don't exist. Rework the `GetRequiredSymbols` to take an abi, and tag those symbols to only be valid on i386/x86_64, so they don't get referred at all when building on arm64, but still get referred in x86_64.

* Fix improper delete/move with already existing directories

* Fix stret requirement for Xamarin.Mac in arm64.

The generator supposes that we're running in x64 mode, refactor to take into account the possibility of running in arm64.

* Implement OS version generation in Product.plist, based on MinimumSystemVersion of the app

* Re-generalize some mmp registrar rules

`Microsoft.macOS.registrar` was missed by the current rule set

* Fix mmp tests

* Set E7072 as not translated

Tests were failing otherwise

* Rename Xamarin.Mac lib/x86_64 folder to 64bits (currently all targeted archs are the same)

* Fix style issues

* Fix `ToLower` usage for invariant usage

* Fix xtro-sharpie test
2021-03-17 21:48:02 -04:00
Rolf Bjarne Kvinge 3a96cb02f5
[msbuild] Unify the iOS and macOS version of ACToolTaskBase. (#10810)
* [msbuild] Unify the iOS and macOS version of ACToolTaskBase.

* The ACTool task now needs the target framework moniker.
2021-03-09 17:45:49 +01:00
Rolf Bjarne Kvinge 7bf40f96c0
[msbuild] Unify the CompileImageAssets targets between Xamarin.iOS and Xamarin.Mac. (#10809) 2021-03-09 11:24:38 +01:00
Rolf Bjarne Kvinge 23bdf61230
[tests] Add unit tests for building Mac Catalyst for ARM64. (#10768)
* [dotnet] Use the expected case for ARM64.

We use case-sensitive comparisons somewhere else, so make sure to use the same casing
for the architecture as other platforms do.

* [tests] Add tests to verify that Mac Catalyst builds successfully for ARM64.

* [msbuild] Fix platform name in condition.

* [msbuild] Pass -isysroot when building Mac Catalyst apps as well.

Ohterwise clang will use the SDK from the command line tools, which may have
nothing to do with the SDK we want to build with.
2021-03-04 17:44:55 +01:00
Rolf Bjarne Kvinge 100e2ec832
[msbuild] Don't compute the platform for Mac Catalyst. (#10754)
This way we don't end up forcing Mac Catalyst apps to be signed (because if
the computed platform is 'iPhone', we enforce signing).
2021-03-03 07:44:26 +01:00
Emanuel Fernandez Dell'Oca ecccb8954e
[dotnet] Revert changes that separate Messaging from Xamarin.iOS.Tasks to fix dotnet build (#10738)
This reverts commit 9a27951a99.

The purpose of the original commit was to take out 4 tasks that were only executed from Windows to the Windows specific pack (and enabling more tasks that need to be executed remotely on that pack).

To execute tasks remotely the build will initially run `SayHello` which connects to the Mac and shares the connection with all the tasks through IBuildEngine4[1]. When that connection object is retrieved on the tasks we need to cast it as a Messaging connection type, and this works from Visual Studio and msbuild because there's just one messaging assembly loaded.

But it doesn't work on dotnet/msbuild, because there's a feature called ALC (AssemblyLoadContext) which will load each assembly task into it's own context[2], loading all its dependencies in that context. In this scenario sharing custom objects between tasks won't work because the original object type could be from a different context than the one retrieving it. This is described here: https://github.com/dotnet/msbuild/issues/5084.

[1] https://docs.microsoft.com/en-us/dotnet/api/microsoft.build.framework.ibuildengine4?view=msbuild-16-netcore
[2] https://github.com/dotnet/msbuild/blob/master/documentation/specs/task-isolation-and-dependencies.md
2021-03-01 08:05:01 +01:00
Emanuel Fernandez Dell'Oca 9a27951a99
[dotnet] Moves tasks to the Windows project (#10675)
* [dotnet] Stops merging Messaging into Xamarin.iOS.Tasks

- Creates a separate Xamarin.Messaging project that will produce a single assembly after merging all the Xamarin Messaging dependencies.
- Stops merging Messaging into Xamarin.iOS.Tasks to be able to reference it from the Windows specific pack.
- Refactors the ILMerge.targets to reuse common code from ILMerge.Messaging.targets.

* [dotnet] Moves Windows specific tasks to the Windows tasks project

* [dotnet] Adds Xamarin.Messaging.dll to the different packages

* [msbuild] Add logic to build & install Xamarin.Messaging.dll.

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2021-02-23 18:55:10 +01:00
Rolf Bjarne Kvinge 9f18c53e28
[msbuild] Use '_PlatformName' == 'MacCatalyst' instead of '_IsMacCatalyst'. (#10636)
In .NET Mac Catalyst will be a platform on the same level as iOS or tvOS, so
reflect this in the build logic by setting _PlatformName to 'MacCatalyst'.
This makes the build logic a lot simpler for .NET.
2021-02-12 21:49:49 +01:00
Rolf Bjarne Kvinge 4b6246616c
[msbuild] Unify the _GenerateBundleName targets between Xamarin.iOS and Xamarin.Mac (#10621) 2021-02-12 11:23:47 +01:00
Emanuel Fernandez Dell'Oca d337f0deac
[dotnet] Initial support for .NET6 from Windows (#10590)
These changes add support for executing iOS and MacDev tasks remotely (on a Mac) when running a build from Windows, and creates a specific .NET6 pack for Windows that's only included in the MSI.

For now this only enables builds for the iOS Simulator, physical devices are not yet supported.

- Each task decides if it should run locally or remotely depending on the SessionId property, which will only have a value on Windows.
- The XMA Build agent is now part of this repo and will be included in the iOS .NET6 Windows pack.
- On this first version we're including some Windows specific tasks and references into the Xamarin.iOS.Tasks project for simplicity, but those will be moved to the Windows specific project.

------------

* [msbuild] Adds support for executing Xamarin.iOS tasks from Windows

* [msbuild] Adds support for executing Xamarin.MacDev tasks from Windows

* Added XMA Build Agent to Xamarin.MacDev.Tasks.sln

* Fixes some MSBuild versioning problems

* Makes the XMA Build agent load Xamarin.iOS tasks

We need to load a type from the iOS tasks assembly so we can run the tasks requested by MSBuild from Windows. We only need to load Xamarin.iOS.Tasks.dll since MacDev.tasks is already embedded in that one.

There's a little trick on the csproj, we can't directly use the Xamarin.iOS.Tasks project ref assemblies because that includes both Xamarin.iOS.Tasks.dll and Xamarin.MacDev.Tasks.dll, so the MacDev tasks will collide. We use the project ref only for build dependency purposes but we add an assembly reference to Xamarin.iOS.Tasks.dll.

* Added Xamarin.iOS.Tasks.Windows project

* Removed unnecessary references on Xamarin.iOS.Tasks.Windows.csproj

* Adds Messaging assemblies when ILRepacking Xamarin Tasks

The Xamarin Task assemblies now depend on Messaging, so we need the Messaging assemblies to be packed into Xamarin.Mac.Tasks and Xamarin.iOS.Tasks. Also had to remove the direct Messaging dependencies from the build agent since those are already contained in Xamarin.iOS.Tasks

* Adds a reference to Messaging.Core targets to the Agent's project

* [msbuild] Adds Xamarin iOS Windows targets

* [msbuild] Adds missing dependencies to Xamarin.iOS.Tasks

This should fix build errors because of missing dependencies. Had to move System.Net.Mqtt.Server from the Build agent project to the tasks one to avoid conflicts with System.Diagnostics.Tracer.

* [dotnet] Creates iOS Windows pack

Creates a new pack for Windows specific (targets, build agent, etc.) files that shouldn't be installed on the Mac. We have a separate package for this to avoid increasing the core pack size with things that are not needed when using it from macOS.

* Fixes type in dotnet makefile

* [dotnet] Fixes the iOS Windows pack generation

- The windows pack should not include the Sdk and Targets folders
- For now we'll just create an iOS pack
- Fixes the path to the files to include on the Windows Sdk pack

* Added reference to the Windows iOS SDK from the Xamarin.iOS.Common.targets

Added a property to navigate to the Windows iOS SDK folder, based on a naming convention that assumes that both packs will always have the same version

* Added reference to the core iOS SDK from the Windows iOS SDK

Added a property to navigate to the core iOS SDK folder, based on a naming convention that assumes that both packs will always have the same version

* Updated Messaging version

* Override MessagingBuildClientAssemblyFile property and correctly imported props from targets

* [dotnet] Make Windows pack using target files from the output dir

We need to take the target files from the output dir to include targets that are part of nuget packages, otherwise we will only include targets from our source

* [dotnet] Adds the Windows Sdk pack to the workload manifest

* [msbuild] Fixes the Windows Sdk pack name

* [dotnet] Merge Mqtt instead of Mqtt.Server

We only need System.Net.Mqtt to be merged into Xamarin.iOS.Tasks

* Updated Messaging version

* [dotnet] Several fixes for the Windows Sdk

- Adds missing task CollectMonotouchReferences
- Merges more dependencies into Xamarin.iOS.Tasks.dll needed by XMA
- Updates the msbuild/Makefile to include files from both the output dir and the source dir
- Overrides the agents directory to look for them on the Windows pack

* [dotnet] Fixes the XMA Build agent

- The build agent is an app so it cannot target ns2.0
- The MSBuild dependencies should be copied into the agent zip file
- Avoids copying all the Xamarin iOS SDK core targets into the build agent, since those are not needed
- Ensures the broker zip file is copied into the Xamarin.iOS.Windows.Tasks output dir so its included in the Windows pack

* Bumps Xamarin.Messaging to 1.2.102

* Adds net6-win branch to trigger builds

* Adds Messaging.Client missing dependency to Xamarin.Mac.Tasks

* Added Xamarin.Messaging.Apple.Tasks project and VerifyXcodeVersion Task

* Fix unloaded Xamarin.Messaging.Build project

* Added Build contracts project and unified Xamarin.Messaigng.Apple.Tasks in Xamarin.iOS.Tasks.Windows

Also added missing tasks and changes .After.targets

* Updated Xamarin.Messaging version

* Build agent - reference MSBuild assemblies from the framework

Since the assemblies will be included in the build agent we need those to be the ones that come from the framework to be compatible with macOS

* [msbuild] Fixes _UpdateDynamicLibraryId target

The tasks con this target need to be executed remotely (when building from Windows).

* Updates resources

* Bump Xamarin.Messaging

Fixes problems when executing Exec task remotely

* [dotnet] Overrides Publish targets to execute them remotely from Windows

The `_CopyResolvedFilesToPublishPreserveNewest` and `_CopyResolvedFilesToPublishAlways` targets essentially copy files into the app bundle. Since those are part of the .NET SDK we need to override those so we can pass to the Copy task the SessionId parameter and then it will be executed remotely when building from Windows.

This is done in a Windows.After.targets file so it won't affect builds on macOS.

* Added ILMerge to Xamarin.iOS.Tasks.Windows

Also modified ILMerge.targets to not include System assemblies because we don't need them on the Windows package

* Bumps Messaging

This new version of messaging fixes a problem when copying task inputs from Windows to the Mac

* [dotnet] Fixes copying files to the Mac when building from Windows

When building from Windows there are .NET SDK targets that copy dynamic libraries from the SDK to the intermediate output directory or other files to the publish directory, since we can't control those we can't run them remotely so we need to copy those files to the Mac to ensure other targets will find those.

* [dotnet] Fixes how files are copied to the output dir

- Before executing `_CopyResolvedFilesToPublishPreserveNewest` and `_CopyResolvedFilesToPublishAlways` we copy the input files for those targets to the Mac
- Then we override the original targets to execute the same copy task as the original ones but on the Mac, so the output files are placed in the right location for the following targets to pick them up.

* Fixes typo on Xamarin.iOS.Common.After.targets

* Bumps Xamarin.Messaging

* [msbuild] Fixes VerifyXcodeVersion and ResolveUTIs tasks

Both tasks were not being able to connect to the Mac mostly because of ILRepack, there were kind of 2 versions of Xamarin.Messaging, one merged into Xamarin.iOS.Tasks and another one merged into Xamarin.iOS.Windows.Tasks. Because of this the build connection object registered on the task could not be casted to the build connection type.

This essentially moves both tasks into the Xamarin.iOS.Tasks assembly to avoid this issue, and as part of that also includes the Messaging contracts into that same project.

* [msbuild] Fixes warnings when building from Windows

* [dotnet] Adds missing assemblies to merge into Xamarin.iOS.Tasks

Those 2 new assemblies will only be used from Windows and we need their implementation instead of the ref assemblies. In the future we will need to find a way of doing this on the Windows only pack insted of doing it on the core Xamarin.iOS.Tasks assembly.

* [dotnet] Compute PublishTrimmed on a target

We need to do this so the property is evaluated after VS on Windows connects to the Mac, otherwise by default IsMacEnabled is false from Windows.

* Bumps Messaging to 1.2.111

* [dotnet] Execute ILLink remotely when building from Windows

- Overrides the ILLink task and _RunILLink target to add the hability to execute it remotely, adding input and output properties so files are copied to the server and output files are created on Windows.
- This "custom" ILLink task will only be executed from the Windows targets so when building from a Mac it will execute the core SDK task.

* [dotnet] Fixes intput/output files creation for linker tasks

- Custom Linker options file should be created on the Mac so we need to execute WriteLinesToFile remotely
- All the *.items files from the linker are created on the Mac so we need to execute ReadItemsFromFile remotely
- CompileNativeCode: fixes the OutputFile metadata path, otherwise the execution fails; also copies all the files in the declared "IncludeDirectories" to the Mac
- Avoids copying input files from Windows to the Mac when running LinkNativeCode since the real input files already exist on the Mac, and Windows contains only empty files just to make MSBuild inputs/outputs check work. If we copy those empty files to the Mac we brake the build.

* [msbuild] Minor fixes after merging from main

* [dotnet] Adds missing output files to the Xamarin.iOS.Tasks.Windows project

The output of this project was missing Messaging build targets and the build agent zip file that are needed to create the dotnet Windows specific pack

* [dotnet] Fixes dotnet Windows specific pack generation

Ensures the Windows projects are built and the files are copied to the dotnet pack directory before creating the package.

It also adds a variable to enable building this pack.

* [dotnet] Adds iOS Windows specific pack to iOS only MSI

There's only a Windows specific pack for iOS available for now, so we should only add it to the iOS SDK MSI

* [dotnet] Create a separate bundle for the iOS Windows MSI

We need to do this to avoid including the Windows specific pack in the pkg. Also for now we'll only create an MSI for iOS since it's the only supported platform from Windows.

* Fixes spacing issues in Xamarin.iOS.Tasks.csproj

* Bumps Touch.Unit back to 05db76

* Fixes formatting problems

* [msbuild] Replaces error E0176 by E0186

Because there's a warning W0176 that will overlap with the error

* [msbuild] Fixes CompileEntitlements task

There were 2 problems:
1- The if statement on the DefaultEntitlementsPath was wrong, because we should return the base value if there's no SessionId (which means the task is running on a Mac)
2- We should copy to the Mac the default entitlements file if no custom file was specified

* Several fixes to cleanup the code to support iOS from Windows

* Apply suggestions from code review

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

* Formatting fixes in Xamarin.Messaging.Build

* Reverted formatting changes in CompileEntitlements.cs

* More formatting fixes

* Update msbuild/Messaging/Xamarin.Messaging.Build/Handlers/ExecuteTaskMessageHandler.cs

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

* Fixes order of MSBuild errors in the resource file

* Add newly added localizable strings to canary test of translated strings.

* Delete tests that ensure theres code only on the abstract tasks

These were needed to ensure all the code was in the base tasks so we could have tasks implementations on Windows to remote those. Now that code is part of this repo (and that is why these tests are failing now) so we do not need them anymore.

* [dotnet] Don't build the Windows SDK pack if not configured to do so.

Co-authored-by: mag <mauro.agnoletti@gmail.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2021-02-12 07:43:17 +01:00
Rolf Bjarne Kvinge f7d0a03d93
[msbuild] Unify the AppBundleExtension property definition (#10614) 2021-02-11 15:37:39 +01:00
Rolf Bjarne Kvinge 7cd0dab9d9
[msbuild] Fix computing the frameworks directory for Mac Catalyst. (#10557)
This is part 2 of making framework-test build on Mac Catalyst.

Contributes to https://github.com/xamarin/xamarin-macios/issues/10440.
2021-02-02 08:46:38 +01:00
Rolf Bjarne Kvinge a9c21ef791
[dotnet] Add support for some of the single-project MSBuild properties. (#10545)
* [tests] Add test case for single-project properties in .NET.

* [msbuild] Add support for the single-project ApplicationId MSBuild property.

* [msbuild] Add support for the single-project ApplicationTitle, ApplicationVersion and AppleShortVersion MSBuild properties.

* [dotnet] Enable the single-project MSBuild properties by default.

* [dotnet] Add a short doc about single project properties.

* [tests] Fix the GeneratePlistTaskTests.BundleIdentifier test according to bundle identifier changes.

This test asserts that the CFBundleIdentifier value in the Info.plist isn't
overwritten, and does so by calling the CompileAppManifest task, giving it a
different value for the bundle identifier than what's in the Info.plist.

The behavior change is that now we do things in the following manner:

DetectSigningIdentityTask will read the Info.plist, compute a bundle
identifier (which will be the value from the Info.plist if it's there), and
returns it to the MSBuild code. Eventually that value will be passed to the
CompileAppManifestTask, which will write it to the Info.plist.

However, this test doesn't run the DetectSigningIdentityTask, which means that
the initial value for the bundle identifier doesn't come from the Info.plist.
2021-01-29 17:37:37 +01:00
Rolf Bjarne Kvinge bad792983e
[msbuild] Add a BundleIdentifier property to the XcodeCompilerToolTask. (#10480)
* [msbuild] Add a BundleIdentifier property to the XcodeCompilerToolTask.

This way we don't have to read the Info.plist to get the bundle identifier,
which will be a problem in the future, because the Info.plist might not have
the actual bundle identifier we end up using. Instead rely on the
_BundleIdentifier MSBuild property, which will contain the final bundle
identifier.

* [msbuild] Make sure we have a bundle identifier when calling ACTool.

* [msbuild] Make sure we have a bundle identifier when calling IBTool if one is needed.

At the same time make the BundleIdentifier not required, because IBTool may
run for library projects, which doesn't have a bundle identifier.

* [msbuild] _DetectSigningIdentity needs to know the bundle name.

* [msbuild] It shouldn't be necessary to detect the signing identity to compute the bundle name.
2021-01-28 07:54:06 +01:00
Rolf Bjarne Kvinge 4a32d37c5d
[msbuild] Remove unused property from DetectSigningIdentityTask. (#10478) 2021-01-20 21:23:51 +01:00
Sebastien Pouliot 05e28c3713
[macos] Add correct support for producing/archiving `dSYM` (#10409)
TL&DR: This PR

1. Removes the creation of the `.dSYM` based on `Debug Information` [1]

2. Adds dSYM support to XM msbuild (now shared with XI implementation)

3. Archive the `.dSYM` directories (plural) properly, e.g.

```
msbuild -p:Configuration=Release -p:ArchiveOnBuild=true
```

Why ? The long story...

Historically `.dSYM` for Xamarin.Mac have not been very useful, largely
because (most of) the code is JITed so not much is known before runtime.
So they were simply not generated during the builds...

However AOT options were added to Xamarin.Mac, making them potentially
more useful. Also symbols from `libmono` and other native libraries /
frameworks can prove useful when diagnosing application crashes.

Unsurprisingly developers looking to get symbols eventually found _a way_
[1] to get a `.dSYM` for their applications - but it was not quite
correct because:

* setting the debug information option meant that `mmp` would be supplied with `-debug`. This disables several optimizations that are, by default, enabled for release builds. IOW generating symbols should have no effect on the executing code (but it had);

* it was produced when compiling the native launcher, so the symbols coverage was incomplete. How much depends if mono was statically or dynamically linked. However this would not cover any AOTed code nor bundled libraries or user frameworks.

* the .dSYM was produced inside the `x.app/Contents/MacOS/`, side-by-side with the native executable, which makes it part of the **signed** `.app` and also part of the created (and signed) `.pkg`. This had a large impact on the application's, disk and download, size(s). Manually (re)moving the `.dSYM` means re-signing the app and re-creating (and signing) the `.pkg` is not a good solution.

[1] https://forums.xamarin.com/discussion/139705/how-to-symbolicate-a-xam-mac-crash-log

Additional fixes

* Use `Directory.Move` instead of running the `mv` command

While the result is identical there is a cost to spawn several `mv`
processes. Doing it in parallel (might have) helped but that setup
also comes at a cost.

`Directory.Move` the four `.dylib.dSYM` of an app takes 1 ms, while
the existing code took 17 ms to do the same.

* Fix building mmptest since the DeleteDebugSymbolCommand constant is not present (nor used) anymore
2021-01-14 08:42:24 -05:00
Rolf Bjarne Kvinge 4730ef30b8
[msbuild] Unify the EmbedProvisionProfile and EmbedMobileProvision tasks between iOS and macOS. (#10322)
These two tasks did essentially the same thing, so we can just merge them. I
kept the "EmbedProvisionProfile" name, because that sounded like the most
applicable to all platforms.
2021-01-11 14:34:19 +01:00
Sebastien Pouliot db77ed51a1
[msbuild] Fix xcframework support when used directly as native references (#10219)
instead _indirectly_ thru a binding project.

It got broken when I fixed the msbuild tests (to avoid re-building
needlessly the project).

Test case: https://github.com/spouliot/xcframework

Also don't resolve when building binding projects - since it's not useful (as we already package the whole .xcframework)
2020-12-10 12:45:58 -05:00
Rolf Bjarne Kvinge daa7e123e2
Add very early support for Mac Catalyst. (#10199)
* Install the Mac Catalyst versions of the mono libraries and BCL.
   * The BCL is the same as the one for Xamarin.iOS, which means it has to be post-processed a bit to work with a Xamarin.MacCatalyst.dll
* Build our runtime for Mac Catalyst.
* Build a Xamarin.MacCatalyst.dll with the Mac Catalyst API (it compiles, but I haven't looked at the API surface at all). This PR assumes we're going to have a new TargetFrameworkIdentifier for Mac Catalyst, but a final decision has not been made (see https://github.com/dotnet/runtime/issues/44882), so this may change.
* Build a Xamarin.iOS.dll that contains type forwarders to Mac Catalyst for all the types that exist in both Mac Catalyst and Xamarin.iOS.
* Add support to xharness for running introspection on Mac Catalyst (there are a lot of failures because the API surface is wrong)
* Add support to our msbuild tasks and mtouch for building Mac Catalyst apps. This basically comes down to adding a new case in numerous places to either do things the iOS way or the macOS way, depending on each case.
* Add a __MACCATALYST__ define (which is in addition to the __IOS__ define).
2020-12-04 18:27:37 +01:00
Rolf Bjarne Kvinge 5f453afe28
[msbuild] Treat 'ResolvedCompileFileDefinitions' as a list of reference assemblies as well. (#10197)
The build logic will put reference assemblies in
'ResolvedCompileFileDefinitions' instead of '_ReferencesFromNuGetPackages'
when using the new-style packageref format, so we need to handle
'ResolvedCompileFileDefinitions' the same way we handle
'_ReferencesFromNuGetPackages'.

I was unfortunately not able to create a unit test for this scenario, because
xibuild sets MSBUILD_EXE_PATH to make msbuild look in our local build files,
and then the restore fails with:

> Issue9266.csproj : error MSB4236: The SDK 'Msbuild.Sdk.Extras/2.1.2' specified could not be found.

If I don't use "Msbuild.Sdk.Extras" in the test, then it doesn't hit the
broken path this PR is fixing. If I change xibuild to not set
MSBUILD_EXE_PATH, we're not testing our local bits anymore, but the system
Xamarin.Mac.

Fixes https://github.com/xamarin/xamarin-macios/issues/9266.
2020-12-03 15:35:55 +01:00
Rolf Bjarne Kvinge 24599c5945 [msbuild] Define __MACCATALYST__ for Mac Catalyst apps.
Mac Catalyst is a different target environment for iOS, which means that
__IOS__ will also be defined.
2020-12-03 10:43:19 +01:00
Rolf Bjarne Kvinge 699d842c5c [msbuild] Put the PkgInfo file in the Contents directory for catalyst apps 2020-12-03 10:43:19 +01:00
Rolf Bjarne Kvinge a2af2a1925 [msbuild] Put Info.plist in the Contents/ subdirectory in the app for catalyst apps. 2020-12-03 10:43:18 +01:00
Rolf Bjarne Kvinge e9f0b1f8e6 [msbuild] Implement support for Mac Catalyst 2020-12-03 10:42:26 +01:00
Rolf Bjarne Kvinge 78ff0ee892 Add a Xamarin.MacCatalyst target framework identifier. 2020-12-03 10:42:26 +01:00
Rolf Bjarne Kvinge 14e3282781
[msbuild] Unify the _GetCompileToNativeInputs target between iOS and Mac. (#10189)
* Add a stamp file to the Mac version of _CompileToNative. This is used to
  force a rebuild of the container app when an app extension changes (and was
  already implemented for iOS: 8b376efa4b)
* Rename the iOS stamp file to 'bundler.stamp' instead of 'mtouch.stamp' to
  ease code sharing.
* Rename the 'MmpReferencePath' and 'MTouchReferencePath' properties to
  '_BundlerReferencePath' to ease code sharing.
* Merge the _GetCompileToNativeInputs targets. The only difference between iOS
  and Mac (after the above changes) is that the Mac version now includes
  '@(ReferencePath)' in '_CompileToNativeInput'. This should be fine as far as
  I know.
2020-12-03 08:12:18 +01:00
Sebastien Pouliot 3bd14c3eef
[msbuild] Add support for `.xcframework` (#10046)
This is done early so we can resolve the inner framework, inside the
xcframework, and let the existing framework support do most of the
work.

The resolving code has unit tests. Custom projects for "NoEmbedding"
exists for all supported platforms and executed by xharness.

A sample `xcframework` with tests projects is also available 
[here](https://github.com/spouliot/xcframework).

The xcframework test case is based on Rolf's earlier/partial implementation.
https://github.com/rolfbjarne/xamarin-macios/commit/xcframework

Things to note:

Do not rename a framework (like XTest) to use it in an xcframework
(like XCTest). That will fail at codesign but won't give anything
useful. You might think signing the framework (instead of the inner
binary) would solve it. It does, as it codesign, but then the app
crash at startup. At some point you realize some symbols are still
using XTest (not XCTest) and then you can delete several other weird
workarounds (like for `ld`) because all of it was cause by this
never identified rename.

dSYM support (and tests) to be done in a separate PR.
2020-11-30 13:44:03 -05:00