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

1386 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge ab52bb2f45
[msbuild] Unify the DetectSdkLocations task logic between iOS and Mac. (#15256)
This was mostly a clean merge, with a few minor differences:

* We no longer compute whether we're running in the simulator or not when building for Mac Catalyst.
* The task now supports building remotely for macOS (due to code sharing).
  Will be useful if we ever support building macOS apps remotely.
* We now call AppleSdkSettings.Init () on macOS. No idea why we weren't
  before, but it seems logical for macOS to behave like our other platforms.

There shouldn't be any other functional differences.
2022-06-16 23:52:43 +02:00
Rolf Bjarne Kvinge 438e312503
[msbuild] Only pass -z to dsymutil when using Xcode 13.2 or earlier. (#15254)
Apple removed the -z / --minimize option in Xocde 13.3, so now if you use it
you get a warning: "ignoring unknown option: -z".

So just don't pass -z when using Xcode >= 13.3

Ref: https://github.com/dotnet/runtime/issues/66770
Ref: 5d07dc8977
2022-06-15 14:55:51 +02:00
Rolf Bjarne Kvinge 2b84ce2ccb Merge remote-tracking branch 'origin/main' into net7.0 2022-06-15 13:34:23 +02:00
Rolf Bjarne Kvinge ee2af3c896
[msbuild] Only sign the prebuilt hotrestart app in CI (#15236)
Only sign the prebuilt hotrestart app in CI, to avoid making it required for
developers to configure code signing.

Also fix DetectSigningIdentity to not require a code signing certificate for
device builds when RequireCodeSigning is false.

Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
2022-06-13 17:30:22 +02:00
Rolf Bjarne Kvinge c05e774612 [dotnet/tools] Disable compact unwind on Xcode 14 to fix linker warnings.
Ref: https://codereview.chromium.org/2784253003
Ref: https://github.com/grain-lang/binaryen.ml/pull/136
Ref: https://github.com/ocaml/ocaml/issues/9026
Ref: https://gitlab.haskell.org/ghc/ghc/-/issues/11829
2022-06-13 10:56:02 +02:00
Rolf Bjarne Kvinge be0f63615e Merge remote-tracking branch 'origin/main' into net7.0 2022-06-13 10:12:57 +02:00
Rolf Bjarne Kvinge b387776ee8
[msbuild] Update ILRepack location now that we're putting all our packages in a directory in our repo. (#15228) 2022-06-09 13:23:26 -04:00
Rolf Bjarne Kvinge efba4cd38f Merge remote-tracking branch 'origin/main' into net7.0 2022-06-09 14:08:52 +02:00
Rolf Bjarne Kvinge ed1448ae68
[msbuild] Unify the CompileSceneKitAsset task logic between iOS and Mac and improve it. (#15176)
* Unify the CompileSceneKitAsset task implementation between iOS and Mac.
  There were no real differences, so might as well use the same code
  everywhere.
* Use existing facilities for process launching.
* Parallelize compiling.
2022-06-07 16:23:44 +02:00
Rolf Bjarne Kvinge db91c70f41 Merge remote-tracking branch 'origin/main' into net7.0 2022-06-07 11:10:24 +02:00
Rolf Bjarne Kvinge 6c5a95b56e
[msbuild] Simplify code to remove metadata. (#15185) 2022-06-07 10:32:05 +02:00
Rolf Bjarne Kvinge a1d0b6eba9
Make our local .NET the default .NET for the build. (#15086)
Make our local .NET the default .NET (in the root's global.json), and then if
a directory wants to use the system .NET, then that directory would have to
opt-in (using its own global.json).

This way we don't have to copy global.json/NuGet.config files around to run
tests with the correct .NET setup.
2022-06-07 10:11:02 +02:00
Rolf Bjarne Kvinge dcecc4dbf9
[msbuild] Fix computing the output path for SceneKitAsset items with custom Link metadata. Fixes #15104. (#15186)
Co-authored-by: Chris Hamons <chris.hamons@xamarin.com>
2022-06-07 10:08:53 +02:00
Mauro Agnoletti ac97efd395
Allow overriding HOME variable in dotnet remote builds (#15171)
With remote builds, a dedicated dotnet location is being used so the right versioning can be used and managed from VS in Windows. This dedicated dotnet location requires a custom .home location so the donet and nuget caches doesn't conflict with the global installation.

We need to consider and use this custom .home location when running dotnet commands remotely so the right caches are used

This should fix Bug: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1543495
2022-06-03 18:19:27 +02:00
Rolf Bjarne Kvinge 8f18e295f7 Merge remote-tracking branch 'origin/main' into net7.0 2022-06-02 21:17:39 +02:00
Emanuel Fernandez Dell'Oca 7ad9f88939
[msbuild] Fixes Hot Restart compiled Entitlements output path (#15125)
The compiled entitlements should be placed in the intermediate Hot Restart app bundle so those can be picked up by the HotRestart Codesign task. Prior to this change, entitlements set in the project wouldn't be included in the app, making things like Keychain Access fail, even though it was configured.

Fixes https://developercommunity.visualstudio.com/t/Unable-to-use-MSAL-with-locally-connecte/1573064
2022-05-30 12:34:20 +02:00
Mauro Agnoletti f45c20505d
Updated Hot Restart Client version to 1.0.93 (#15137)
Bring changes in logging verbosity
2022-05-30 12:29:14 +02:00
Rolf Bjarne Kvinge 05006049fc Merge remote-tracking branch 'origin/main' into net7.0 2022-05-30 11:57:26 +02:00
Rolf Bjarne Kvinge cf7c6b5980
[msbuild] Improve logic to clean up app bundle for unwanted files. (#15080)
The current directory at launch is the root directory of the app bundle. This
means that any files written to the current directory when an app is executed,
will be placed there. This becomes a problem when the app is rebuilt (and
resigned), because a valid macOS app bundle doesn't have any files in the root
directory of the app bundle, so signing fails.

We have logic to automatically crash crash reports from the app bundle, but it
turns out this is a more common problem with other types of files (and
folders), so improve the logic a bit:

* Add support for setting a property to automatically clean up everything from
  an app bundle we don't think should be there (which is anything not in a
  Contents/ subdirectory).
* Use the same property to add support for disabling any cleaning (we already
  clean mono's crash reports by default).
* Improve detection of unwanted files to include directories inside the app
  bundle, not only files.

Ref: https://github.com/dotnet/maui/issues/7353
2022-05-30 11:34:45 +02:00
Rolf Bjarne Kvinge 6ecc102b5b
[msbuild] Use the full path to the symbols list file. Fixes #15046. (#15105)
Give the full path to the symbols list file in the extension project to the
main project, so that strip can find it.

When building a solution remotely from Windows, we can't compute a relative
path between projects, because they're laid out differently on disk. This
means that we have to use full paths when passing paths between projects (such
as the path to the symbol list file).

Fixes https://github.com/xamarin/xamarin-macios/issues/15046.
2022-05-30 11:33:11 +02:00
Rolf Bjarne Kvinge 13c4df21aa Merge remote-tracking branch 'origin/main' into net7.0 2022-05-26 09:44:47 +02:00
Mauro Agnoletti 42594a8296
Updated Messaging and Hot Restart versions (#15114) 2022-05-25 10:17:56 +02:00
Rolf Bjarne Kvinge f5dfe434bd Merge remote-tracking branch 'origin/main' into net7.0 2022-05-19 23:20:20 +02:00
VS MobileTools Engineering Service 2 61ef886513
Localized file check-in by OneLocBuild Task: Build definition ID 14411: Build ID 6156518 (#15034) 2022-05-16 15:01:18 -04:00
Mauro Agnoletti 31c54460d5
Avoid executing _VerifyXcodeVersion when there's no connection to a Mac (#15026)
This should fix an annoying warning where the user builds an iOS project offline and get a message about that target couldn't be executed
2022-05-16 12:30:49 +02:00
Rolf Bjarne Kvinge fe6a06dbca
[msbuild] Improve error reporting when an external tool fails to print some of stderr. (#14993)
Improve error reporting when an external tool fails to print some of stderr (up to 1024 characters).

Before:

    error : clang exited with code 1

After:

    error : clang exited with code 1:
    error : [...]/xamarin-macios/tests/dotnet/MyInterpretedApp/iOS/obj/Debug/net6.0-ios/iossimulator-x64/linker-cache/main.x86_64.mm:58:25: error: use of undeclared identifier 'MONO_AOT_MODE_INTERP_ONLY'; did you mean 'MONO_AOT_MODE_INTERP'?
    error :         mono_jit_set_aot_mode (MONO_AOT_MODE_INTERP_ONLY);
    error :                                ^~~~~~~~~~~~~~~~~~~~~~~~~
    error :                                MONO_AOT_MODE_INTERP
    error : [...]/xamarin-macios/builds/downloads/dotnet-sdk-6.0.301-rtm.22254.17-osx-x64/packs/Microsoft.iOS.Runtime.iossimulator-x64/15.4.16-ci.x64-interpreter-only/runtimes/iossimulator-x64/native/xamarin/mono-runtime.h:452:2: note: 'MONO_AOT_MODE_INTERP' declared here
    error :         MONO_AOT_MODE_INTERP,
    error :         ^
2022-05-13 09:14:10 +02:00
VS MobileTools Engineering Service 2 7d9dad24fc
Localized file check-in by OneLocBuild Task: Build definition ID 14411: Build ID 6124703 (#14931)
Co-authored-by: TJ Lambert <50846373+tj-devel709@users.noreply.github.com>
2022-05-12 12:25:41 -05:00
Rolf Bjarne Kvinge 92eda7f353
[dotnet] Add support for selecting whether to create P/Invoke wrappers or not. Fixes #4940. (#14961)
* This is a potential mitigation for slower transition to native code when
  exception marshalling is enabled (#14812).
* A minor modification was required in the linker, to make sure any modified
  assemblies are saved.

Fixes https://github.com/xamarin/xamarin-macios/issues/4940.
2022-05-11 16:42:01 +02:00
Manuel de la Pena f66fba9c8d
[Tools] Enable nullability in StringUtils.cs (#14944) 2022-05-11 07:08:57 -04:00
Rolf Bjarne Kvinge f2bcedd441
[msbuild/dotnet] Add support for passing --aot arguments to the AOT compiler. (#14936)
Pick up --aot arguments in MtouchExtraArgs and pass them to the AOT compiler
when building a .NET project. This makes it possible to work around #14887 by
manually increasing the number of trampolines.

Ref: https://github.com/xamarin/xamarin-macios/issues/14887
2022-05-10 16:25:19 +02:00
Mauro Agnoletti ff40b22180
Updated Xamarin.Messaging to 1.6.6 (#14915) 2022-05-09 18:16:52 +02:00
Rolf Bjarne Kvinge 525407b104 Merge remote-tracking branch 'origin/main' into net7.0 2022-05-09 15:50:41 +02:00
Emanuel Fernandez Dell'Oca e9333bae47
Bumps Xamarin.HotRestart.Application to 1.1.5 (#14925)
This new version contains a fix for incremental deployments when using Xamarin iOS Hot Restart.
2022-05-09 10:30:22 +02:00
Rolf Bjarne Kvinge 07b9d90fee
[msbuild] Enable nullability in the AOTCompileTask class. (#14924) 2022-05-09 10:10:57 +02:00
Rolf Bjarne Kvinge 86b14a77a2 Merge remote-tracking branch 'origin/main' into net7.0 2022-05-05 09:04:10 +02:00
Rolf Bjarne Kvinge ece70a6c6e
[msbuild] Copy binding resource files back to Windows. Fixes #13393. (#14702)
Fixes https://github.com/xamarin/xamarin-macios/issues/13393.
2022-04-27 08:31:42 +02:00
Rolf Bjarne Kvinge 6a43d470d9
[msbuild] Fix typo in warning message. (#14808) 2022-04-25 08:32:28 +02:00
Rolf Bjarne Kvinge a9a638553f
[msbuild/dotnet] Fix building binding projects on Windows in .NET (#14704)
When building a binding project, we need to execute bgen (and csc) on the mac. Figuring
out where these files are on the Mac is rather complicated from a remotely executed
task, so instead we execute a sub-build that computes these properties.

In legacy Xamarin this was accomplished by building the 'Xamarin.iOS.ObjCBinding.Common.props'
file using msbuild, and invoking a custom target that prints the property we're looking
for (the 'targetGetPropertyValue_*' targets).

For multiple reasons this approach doesn't work in .NET anymore (in particular it
seems that the 'Xamarin.iOS.ObjCBinding.Common.After.targets' file with the custom
'targetGetPropertyValue_*' targets is nowhere to be found, but logic has also moved
around in the .targets/.props files which makes just building the 'Xamarin.iOS.ObjCBinding.Common.props'
not work correctly since the properties we need wouldn't be set).

So I'm adding a new task that does a sub-build, using either msbuild or dotnet as
appropriate, to compute the properties we need. Instead of building the 'Xamarin.iOS.ObjCBinding.Common.props'
file, the task creates an actual binding project (an empty one), and executes the
new '_WriteRemoteGeneratorProperties' target in this binding project.

An additional advantage in this new task is that it will only execute one sub-build
where all the properties are computed (the previous approach executed one sub-msbuild
per property).

In order to keep code as similar as possible between legacy Xamarin and .NET, the
new task is being used for legacy Xamarin as well (and the old approach deleted).

This fixes building binding projects on Windows in .NET.
2022-04-22 16:17:03 +02:00
Rolf Bjarne Kvinge 2cffa7c74e
[msbuild] Just use the 'AppBundleDir' variable to find the app bundle in the CreateInstallerPackage task. Fixes #14751. (#14800)
The output directory might or might not be where the app bundle is: by default
it is, but if someone sets the PkgPackageDir variable to provide an alternate
directory for the pkg, then that won't be where we'll find the app bundle.

The good news is that we already have a property that tells us where the app
bundle is (the 'AppBundleDir' property), so just use that instead.

Also:

* Make sure that the output directory exists before we try to write to it.
* Only pass full paths to productbuild, which for some reason doesn't seem to
  like relative paths.

Fixes https://github.com/xamarin/xamarin-macios/issues/14751.
2022-04-22 07:59:27 +02:00
Mauro Agnoletti 4a61385d60
Updated Xamarin.Messaging to 1.6.3 (#14771)
Contains a fix to control build verbose logging of underlying Xamarin libraries
2022-04-20 08:18:48 +02:00
VS MobileTools Engineering Service 2 001920f754
Localized file check-in by OneLocBuild Task: Build definition ID 14411: Build ID 6035860 (#14756) 2022-04-18 18:10:04 -04:00
Mauro Agnoletti 8b8cf07182
Update Messaging to 1.6.2 (revert changes) (#14719)
It includes a change revert because of threading freeze issues.
An issue has been detected in Xamarin.Messaging 1.5.26 and 1.6.1 that makes the code unstable and sensitive to thread freeze issues, so we are reverting back the changes until we can stabilize it.
This delays the fix of a bug in MSBuild command line builds for iOS remote builds.
2022-04-12 09:42:55 -04:00
Mauro Agnoletti ceacd96def
Updated Xamarin.Messaging to 1.6.1 (#14707)
Changed from 1.5.* to 1.6.* to match the versioning used in XamarinVS main branch (1.5.* now remains only for 17.2 based branches)
2022-04-09 07:27:15 -04:00
Rolf Bjarne Kvinge 2324e266cd Merge remote-tracking branch 'origin/main' into net7.0 2022-04-07 09:55:03 +02:00
Rolf Bjarne Kvinge 0f5ad37b0e
[msbuild] Fix the build due to nullability changes from multiple PRs conspiring. (#14689) 2022-04-07 09:54:44 +02:00
Rolf Bjarne Kvinge a806c658c9 Merge remote-tracking branch 'origin/main' into net7.0 2022-04-07 09:36:50 +02:00
Rolf Bjarne Kvinge 1b37c48ac5
[dotnet] Add support for Mac Catalyst apps optimized interface for macOS. Fixes #14621. (#14663)
This also required bumping Xamarin.MacDev.

New commits in xamarin/Xamarin.MacDev:

* xamarin/Xamarin.MacDev@0717ac3 Add a new device type for Mac Catalyst.
* xamarin/Xamarin.MacDev@ed2a604 Remove net451 target framework from
Xamarin.MacDev.csproj

Diff: 9e6e29f2a4..0717ac3c24

Fixes https://github.com/xamarin/xamarin-macios/issues/14621.
2022-04-07 08:14:42 +02:00
Rolf Bjarne Kvinge 690f18385d
[msbuild] Enable nullability for the CompileAppManifest task. (#14670)
This also meant:

* Using 'latest' as the C# language version for all msbuild/ project files.
* Enabling warnaserror for nullability warnings.
* Fix any nullability warnings in the CompileAppManifest files.
* Fix a nullability warning in the Ditto task.
* Fix any '== null' or '!= null' to use 'is null' and 'is not null'.
2022-04-06 22:57:10 +02:00
Rolf Bjarne Kvinge caeb05ec27 Merge remote-tracking branch 'origin/main' into net7.0 2022-04-06 09:03:21 +02:00
Rolf Bjarne Kvinge 51a273f22b
[msbuild] Improve product name in .NET. (#14629)
Use 'Microsoft.<platform>' as the product name instead of 'Xamarin.[iOS|Mac]' for .NET builds. That makes error messages like this:

> [...]\Microsoft.iOS.Sdk\15.4.200-ci.windows2.62\tools\msbuild\iOS\Xamarin.Shared.targets(1676,3): Could not find Xamarin.iOS in /usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/15.4.200-ci.windows2.62/.

look a bit better in .NET:

> [...]\Microsoft.iOS.Sdk\15.4.200-ci.windows2.62\tools\msbuild\iOS\Xamarin.Shared.targets(1676,3): Could not find Microsoft.iOS in /usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/15.4.200-ci.windows2.62/.
2022-04-06 08:38:31 +02:00
Rolf Bjarne Kvinge 838b2ccd3b
[msbuild] Move logic to validate the UIDeviceFamily to shared code in the CompileAppManifest task. (#14661)
* Move logic to validate the UIDeviceFamily value to shared code.
* Remove logic related to watchOS 1 apps, it's been dead for a while.
* Change logic to not overwriting any existing UIDeviceFamily values in the customer's
  Info.plist.

This makes the code more platform-agnostic and easier to work with across all platforms
(such as adding new validations).
2022-04-06 08:22:25 +02:00
Rolf Bjarne Kvinge e4172ec7a9
[msbuild] Don't create output files for ditto'ed directories on Windows. (#14662)
Fixes this warning from the Codesign task:

    C:\Users\rolf\...\Microsoft.iOS.Sdk\15.4.200-...\tools\msbuild\iOS\Xamarin.Shared.targets(2045,3): Cannot create 'C:\Users\rolf\source\iOSApp4\bin\Debug\net6.0-ios\ios-arm64\device-builds\iphone14.2-15.3.1\iOSApp4.app\Frameworks\ArcGIS-arm64.framework' because a file or directory with the same name already exists.
    C:\Users\rolf\...\Microsoft.iOS.Sdk\15.4.200-...\tools\msbuild\iOS\Xamarin.Shared.targets(2045,3): Cannot create 'C:\Users\rolf\source\iOSApp4\bin\Debug\net6.0-ios\ios-arm64\device-builds\iphone14.2-15.3.1\iOSApp4.app\Frameworks\Runtimecore.framework' because a file or directory with the same name already exists.

which occurs when the Codesign task asks XVS to create output files for files from
inside ditto'ed directories, and if XVS created output files for those directories
in the Ditto task, then XVS would be trying to create files inside these output files
as if they were directories. That doesn't work (thus the warning).

I've fixed this by:

* Removing the 'ShouldCreateOutputFile' implementation. The ShouldCreateOutputFile
  method is called on Windows, and we can't determine from Windows whether the destination
  is a directory or a file.
* Remove the [Output] attribute for the Destination property, this way XVS doesn't
  automatically try to create an output file for whatever the destination is.
* Add another CopiedFiles output property, which contains all the copied files
  (and only files), so that XVS mirrors this with output files on Windows.

Fixes part of https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1505990/.
2022-04-06 08:19:00 +02:00
Mauro Agnoletti b413f84187
Updated Xamarin.Messaging version to 1.5.27 (#14645)
Includes an important fix for an MSBuild hang when the connection to the Mac can't be established
2022-04-05 17:11:24 +02:00
Rolf Bjarne Kvinge 35b6329796
[msbuild] Make codesigned output files relative, and don't list directories. (#14610)
When XVS creates output/stamp files on Windows, the paths must be relative,
because otherwise XVS will append the full macOS path to the current Windows
directory and get garbage.

XVS also expects only files as output, so don't return any directories.

Fixes part of https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1505990/.
2022-04-05 14:49:49 +02:00
Rolf Bjarne Kvinge 906b94cb00
[mmptest] Fix resolving paths to required test files. Fixes #xamarin/maccore@2560. (#14566)
* Fix resolving paths to required test files (test files can be found relative to the root path of the repository, not relative to where Xamarin.Mac is installed)
* Don't try to sign symlinks - we can end up trying to sign the target of the symlink twice simultaneously.
* Fix finding libxammac.dylib and Xamarin.Mac.dll when testing a system installation (when MAC_DESTDIR or TESTS_USE_SYSTEM are set).
* Remove a few .NET tests we don't need anymore.

Fixes https://github.com/xamarin/maccore/issues/2560.

Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2022-04-05 14:30:35 +02:00
Rolf Bjarne Kvinge 4f46162e2b Merge remote-tracking branch 'origin/main' into net7.0 2022-03-31 09:11:54 +02:00
Mauro Agnoletti cf971a68ea
Updated Xamarin.Messaging to 1.5.24 (#14569) 2022-03-31 08:39:14 +02:00
Rolf Bjarne Kvinge 31e9352a52 Merge remote-tracking branch 'origin/main' into darc-main-fc6e47e2-7b69-4464-b65f-8f67ca26b4e8 2022-03-29 09:05:12 +02:00
Rolf Bjarne Kvinge 50192c9f96
[msbuild] Deduplicate items in ComputeCodesignItems. Fixes #14522. (#14525)
We may end up trying to codesign the same item multiple times when codesigning
universal .NET apps. Avoid this by deduplicating items to codesign.

Fixes https://github.com/xamarin/xamarin-macios/issues/14522.
2022-03-29 07:37:57 +02:00
Rolf Bjarne Kvinge e652068e5e Merge remote-tracking branch 'origin/main' into darc-main-fc6e47e2-7b69-4464-b65f-8f67ca26b4e8 2022-03-25 14:32:42 +01: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 c4f0087c98 Merge remote-tracking branch 'origin/main' into darc-main-fc6e47e2-7b69-4464-b65f-8f67ca26b4e8 2022-03-25 09:46:57 +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 d9e3206125
Merge branch 'main' into dotnet-dsyms 2022-03-23 22:24:51 +01:00
Rolf Bjarne Kvinge 6e74f875d9
Apply suggestions from code review
Co-authored-by: Chris Hamons <chris.hamons@xamarin.com>
2022-03-23 22:24:35 +01:00
Rolf Bjarne Kvinge d0c4173b6f Merge remote-tracking branch 'origin/main' into darc-main-fc6e47e2-7b69-4464-b65f-8f67ca26b4e8 2022-03-23 19:11:40 +01:00
Rolf Bjarne Kvinge 18fa252f1d
[msbuild] Show a better error when a bundle identifier isn't provided. Fixes #14283. (#14402)
Fixes https://github.com/xamarin/xamarin-macios/issues/14283.
2022-03-23 16:49:06 +01:00
Mauro Agnoletti 0ddd7a6888
Updated Xamarin.Messaging version (#14472)
Updated to 1.5.8, including fixes for a hang in build cancellation during SayHello and also an improvement in the port forwarding logic when establishing the SSH connection
2022-03-23 09:12:50 +01:00
Rolf Bjarne Kvinge 7e6091f529 Merge remote-tracking branch 'origin/main' into darc-main-fc6e47e2-7b69-4464-b65f-8f67ca26b4e8 2022-03-22 17:56:07 +01:00
Rolf Bjarne Kvinge 5e8bc0e7ee [msbuild] Remove the CollectFrameworks task, it's no longer used. 2022-03-22 16:14:26 +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 3550aa4837 [msbuild] Move spotlight indexing out to its own task.
Also establish when we should do post processing: only in the outermost build. This
is a slight change from previous behavior, where we'd run strip/dsymutil separately
for app extensions and watch apps.
2022-03-22 16:14:26 +01:00
Rolf Bjarne Kvinge d0a45d1a75 [msbuild] Create a single target for post-processing (dsymutil/strip) an app bundle 2022-03-22 16:14:26 +01:00
Rolf Bjarne Kvinge 6c30c3ab22 [msbuild] Save/restore all the NativeReference metadata.
* Save all the NativeReference metadata in binding resource packages.
* Copy all the NativeReference metadata to new items when resolving native references.

This makes it possible to set custom metadata on NativeReferences, and have that
metadata show up when it's needed, which might not be in the same project (for instance
if the native reference is in a binding project, we might want the custom metadata
when we load the native references from the binding project's resource package -
another case is when app extensions have native references, we might want any custom
metadata in the main executable project to know how to handle certain types of native
references).

Also sort the metadata we write to binding resource packages, so that the output
is stable. This required updating the corresponding tests.
2022-03-22 16:14:07 +01:00
Rolf Bjarne Kvinge 6e6c82b40e [msbuild] Make the ReadItemsFromFileBase task able to take multiple files as input. 2022-03-22 16:14:07 +01:00
Rolf Bjarne Kvinge 7d500da2bf
[msbuild] Rework code signing. (#14387)
The main theme here is that code signing will be done in the outermost
executable project, not in any app extension projects or watch projects, nor
during the RID-specific build of a .NET universal app. This makes codesigning
easier to reason about and other affected logic (such as strip/dsymutil)
easier to handle, in particular for .NET universal apps. Another benefit is
that the differences between the iOS and macOS code bases have been
eliminated.

The first step is to collect all the information we need from the targets
files. Every app bundle (be it app extension, watch app or main app) will add
its own output app bundle (.app/.appex) to the _CodesignBundle item group.
Then every app bundle will load this informarion from referenced app bundles,
and finally store this information on disk (in the 'codesign-bundle.items'
file). This means that in the end the main app bundle will have a list of all
contained app bundles in the app (recursively), in the _CodesignBundle item
group.

Separately we keep a list of other items that need signing, in the
_CodesignItems item group, and we do the same store/load logic for every
contained/contained app bundle (in the 'codesign.items' file, so a the end the
main app bundle will have a list of all the _CodesignItems for all contained
app bundles (recursively).

The previous steps occur in the _CollectCodesigningData and
_StoreCodesigningData targets.

The next step is to use the new ComputeCodesignItems task to compute
everything we need to know for code signing. This task takes over the
responsibility for listing all the *.dylib and *.metallib files, and the
*.framework directories in the app bundles, that need signing (which was
previously done in the targets file). This logic is significantly easier to
write, debug and test in C# than MSBuild.

In addition the ComputeCodesignItems also figures out a stamp file path we use
to determine if something needs (re-)signing. Previously .framework
directories did not have a stamp location, so they'd always end up resigned in
a rebuild, while now we'll automatically skip signing *.framework directories
unless something changed in them.

I've also tried to comment everything thorougly, for the next poor soul having
to deal with any bugs.

Behavioral differences:

* We were always signing *.dylib files for macOS. We're now doing the same
  thing for all platforms.
* We're now always signing *.framework directories for all platforms (like we
  do for *.dylib files), since frameworks are pretty much like dylibs anyways.

I've verified that this works both by running the submission tests and running
and launching a sample project on device from Windows.
2022-03-22 12:53:58 +01:00
Rolf Bjarne Kvinge 24eff5d8ff Merge remote-tracking branch 'origin/main' into darc-main-fc6e47e2-7b69-4464-b65f-8f67ca26b4e8 2022-03-22 08:20:30 +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 5d36a7ed4a [msbuild] Make the ComputeCodesignItems task not copy anything between macOS and Windows.
The ComputeCodesignItems does not touch any files, and all the input files
should already exist on the mac, so there's no need to copy files back and
forth.
2022-03-17 16:19:00 +01:00
Rolf Bjarne Kvinge 31e883899f
[msbuild] Add support for 'EnableCodeSigning' for mobile projects. (#14379)
Mac Catalyst and macOS projects support an 'EnableCodeSigning' property to determine
whether an app is signed or not. In order to bring parity on mobile platforms, add
support for this property for iOS, tvOS and watchOS projects as well - if not set,
we'll still have the old behavior of signing device builds and not signing simulator builds.

Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2022-03-17 14:27:31 +01:00
Mauro Agnoletti 35ca49e0c9
Updated Messaging and Hot Restart versions (#14431)
This should fix a bug where Hot Restart doesn't work with net6 because of a strong naming exception on build time
2022-03-17 08:30:44 +01:00
Rolf Bjarne Kvinge 2057fa3041 [msbuild] Remove code that got duplicated in a rebase. 2022-03-17 07:57:55 +01:00
Rolf Bjarne Kvinge 71482a9754 [msbuild] Resolve the path to the entitlements to a full path.
This way the property works when exposed to containing projects as well.
2022-03-16 21:00:15 +01:00
Rolf Bjarne Kvinge 5ec43ff963 [msbuild] Execute _CompileEntitlements target on macOS under same conditions as for other platforms.
The CompileEntitlements task already handles each platform as it should.

This way we have fewer differences in the code between platforms.
2022-03-16 21:00:15 +01:00
Rolf Bjarne Kvinge 536402184d [msbuild] Resolve the CodesignEntitlements and CodesignResourceRules properties.
The CodesignEntitlements and CodesignResourceRules properties can be relative paths,
and they might be coming from a referenced project. This means that if they're relative
paths, we must resolve them to a full path using the project that defined them (which
is specified using the 'SourceProjectPath' metadata).
2022-03-16 21:00:15 +01:00
Rolf Bjarne Kvinge 3d05542677 [msbuild] Rework code signing.
The main theme here is that code signing will be done in the outermost executable
project, not in any app extension projects or watch projects, nor during the RID-specific
build of a .NET universal app. This makes codesigning easier to reason about and
other affected logic (such as strip/dsymutil) easier to handle, in particular for
.NET universal apps. Another benefit is that the differences between the iOS and
macOS code bases have been eliminated.

The first step is to collect all the information we need from the targets files.
Every app bundle (be it app extension, watch app or main app) will add its own output
app bundle (.app/.appex) to the _CodesignBundle item group. Then every app bundle
will load this informarion from referenced app bundles, and finally store this information
on disk (in the 'codesign-bundle.items' file). This means that in the end the main
app bundle will have a list of all contained app bundles in the app (recursively),
in the _CodesignBundle item group.

Separately we keep a list of other items that need signing, in the _CodesignItems
item group, and we do the same store/load logic for every contained/contained app
bundle (in the 'codesign.items' file, so a the end the main app bundle will have
a list of all the _CodesignItems for all contained app bundles (recursively).

The previous steps occur in the _CollectCodesigningData and _StoreCodesigningData
targets.

The next step is to use the new ComputeCodesignItems task to compute everything we
need to know for code signing. This task takes over the responsibility for listing
all the *.dylib and *.metallib files, and the *.framework directories in the app
bundles, that need signing (which was previously done in the targets file). This
logic is significantly easier to write, debug and test in C# than MSBuild.

In addition the ComputeCodesignItems also figures out a stamp file path we use to
determine if something needs (re-)signing. Previously .framework directories did
not have a stamp location, so they'd always end up resigned in a rebuild, while now
we'll automatically skip signing *.framework directories unless something changed
in them.

I've also tried to comment everything thorougly, for the next poor soul having to
deal with any bugs, as well has adding a comprehensive test for the new task.

Behavioral differences:

* We were always signing *.dylib files for macOS. We're now doing the same thing
  for all platforms.
* We're now always signing *.framework directories for all platforms (like we do
  for *.dylib files), since frameworks are pretty much like dylibs anyways.
2022-03-16 21:00:15 +01:00
Rolf Bjarne Kvinge 5934522ba8 [msbuild] Begone old code signing logic.
I'm removing the old logic first, because the new logic is so different that a diff
just complicates understanding what's happening (there's not much value in comparing
textually what's changed when it's pretty much a complete rewrite).
2022-03-16 21:00:15 +01:00
Rolf Bjarne Kvinge 1b1807479a [msbuild] Move ITaskItemExtensions to Xamarin.MacDev.Task.Core.
So that it's available for code in Xamarin.MacDev.Tasks.Core.
2022-03-16 21:00:15 +01:00
Israel Soto b859c6d8f3
[DittoTask] If Source is a folder, add all its content as ITaskItem (#14375)
* [DittoTask] If Source is a folder, add all its content as ITaskItem

* [DittoTask] Undoing undo...
* Accidentally hit Cmd+Z and removed an using statement

Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
Co-authored-by: Alex Soto <alex@alexsoto.me>
2022-03-14 16:18:53 -04:00
Rolf Bjarne Kvinge 76080a5e79 Merge remote-tracking branch 'origin/main' into darc-main-fc6e47e2-7b69-4464-b65f-8f67ca26b4e8 2022-03-14 20:35:15 +01:00
Rolf Bjarne Kvinge 1bcc85318a
[msbuild] Disable native strip + dsymutil for simulator builds by default. (#14380)
There's no reason to spend time running 'strip' or 'dsymutil' for simulator builds,
so default to not doing it.
2022-03-14 07:59:45 +01:00
Rolf Bjarne Kvinge bdb4d79994
[msbuild] Pass full paths to 'ditto'. (#14376)
For reasons I don't quite understand, ditto might fail when executed by XMA:

    Target Name=_CopyDirectoriesToBundle Project=C:\Users\rolf\source\iOSApp4\iOSApp4.csproj
        Building target "_CopyDirectoriesToBundle" completely.
        Output file "bin\Debug\net6.0-ios\iossimulator-x64\publish\..\device-builds\iphone11.6-14.8.1\iOSApp4.app\\Frameworks\\ArcGIS-arm64.framework/ArcGIS-arm64" does not exist.
        Output file "bin\Debug\net6.0-ios\iossimulator-x64\publish\..\device-builds\iphone11.6-14.8.1\iOSApp4.app\\Frameworks\\Runtimecore.framework/Runtimecore" does not exist.
        Ditto
            Assembly = C:\Users\rolf\source\maui\bin\dotnet\packs\Microsoft.iOS.Sdk\15.2.303-ci.ditto-windows.56\tools\msbuild\iOS\..\iOS\Xamarin.iOS.Tasks.dll
            Parameters
                Destination = bin\Debug\net6.0-ios\iossimulator-x64\publish\..\device-builds\iphone11.6-14.8.1\iOSApp4.app\\Frameworks\\ArcGIS-arm64.framework
                TouchDestinationFiles = True
                SessionId = <SessionId>
                Source = C:\Users\rolf\.nuget\packages\esri.arcgisruntime.runtimes.ios\100.13.0\framework\ios-arm64\native\ArcGIS-arm64.framework\
            Ditto: <timestamp> - Started
            Ditto: <timestamp> - Initializing
            [xma]: Trying to get a Build Connection for Session '<SessionId>': Xamarin.Messaging.Build.Client.BuildConnection.<SessionId>, Lifetime: Build
            Ditto: <timestamp> - Initialized
            Ditto: <timestamp> - There's no available inputs to copy to the Mac
            Ditto: <timestamp> - Serializing intputs
            Ditto: <timestamp> - Executing
            [xma]: Starting remote task execution for 'iOSApp4': Xamarin.MacDev.Tasks.Ditto
            [xma]: Sending Request Xamarin.Messaging.Build.Contracts.ExecuteTaskMessage to topic xvs/build/execute-task/iOSApp4/15f3833002fDitto
            [xma]: Received Response of Xamarin.Messaging.Build.Contracts.ExecuteTaskMessage to topic build<SessionId>4396rolf/+/xvs/build/execute-task/iOSApp4/15f3833002fDitto
            Ditto: <timestamp> - Logging messages
            /usr/bin/ditto C:/Users/rolf/.nuget/packages/esri.arcgisruntime.runtimes.ios/100.13.0/framework/ios-arm64/native/ArcGIS-arm64.framework/ bin/Debug/net6.0-ios/iossimulator-x64/publish/../device-builds/iphone11.6-14.8.1/iOSApp4.app//Frameworks//ArcGIS-arm64.framework
            ditto: bin/Debug/net6.0-ios/iossimulator-x64/publish/../device-builds/iphone11.6-14.8.1/iOSApp4.app//Frameworks//ArcGIS-arm64.framework: File exists
            Errors
                C:\Users\rolf\source\maui\bin\dotnet\packs\Microsoft.iOS.Sdk\15.2.303-ci.ditto-windows.56\targets\Xamarin.Shared.Sdk.targets(668,3): error MSB6006: "ditto" exited with code 1. [C:\Users\rolf\source\iOSApp4\iOSApp4.csproj]
            Ditto: <timestamp> - Finished

This doesn't happen when building on macOS, nor if I copy the offending ditto
command and execute it manually on macOS.

Since I don't know why the problem occurs in the first place, I don't know why
passing full paths to 'ditto' works either. It shouldn't cause problems
elsewhere though.

Ref: https://github.com/xamarin/xamarin-macios/issues/13665
2022-03-11 17:27:32 +01:00
Rolf Bjarne Kvinge 3f4cbb5e44 Merge remote-tracking branch 'origin/main' into darc-main-fc6e47e2-7b69-4464-b65f-8f67ca26b4e8 2022-03-11 14:34:02 +01:00
Rolf Bjarne Kvinge 7cff5adc95
[msbuild] Make sure to not use windows-style paths for resource rules and entitlements. (#14365)
Fixes this build failure:

    1>/Users/<user>/Library/Caches/Xamarin/mtbs/builds/MauiApp16/SessionId/obj\Debug\net6.0-ios\ios-arm64\device-builds\iphone14.5-15.2.1\Entitlements.xcent: cannot read entitlement data
    1>C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\15.2.302-preview.14.117\tools\msbuild\iOS\Xamarin.Shared.targets(2095,3): error : /usr/bin/codesign exited with code 1
    1>C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\15.2.302-preview.14.117\tools\msbuild\iOS\Xamarin.Shared.targets(2095,3): error :
    1>C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\15.2.302-preview.14.117\tools\msbuild\iOS\Xamarin.Shared.targets(2095,3): error : Failed to codesign '/Users/<user>/Library/Caches/Xamarin/mtbs/builds/MauiApp16/SessionId/bin/Debug/net6.0-ios/ios-arm64/device-builds/iphone14.5-15.2.1/MauiApp16.app': /Users/<user>/Library/Caches/Xamarin/mtbs/builds/MauiApp16/SessionId/obj\Debug\net6.0-ios\ios-arm64\device-builds\iphone14.5-15.2.1\Entitlements.xcent: cannot read entitlement data
    1>C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\15.2.302-preview.14.117\tools\msbuild\iOS\Xamarin.Shared.targets(2095,3): error :
    1>C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\15.2.302-preview.14.117\tools\msbuild\iOS\Xamarin.Shared.targets(2095,3): error :
    1>Done building project "MauiApp16.csproj" -- FAILED.
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    ========== Deploy: 0 succeeded, 0 failed, 0 skipped ==========

Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1496403.
2022-03-11 07:29:00 +01:00
Rolf Bjarne Kvinge 56829a2616
[msbuild] Improve the DSymUtil task. (#14344)
* Enable nullability and fix code accordingly.
* Augment it to be able to take multiple files to run dsymutil on at the same time.
* Execute using xcrun (ref: #3931)
* Pass the full path to the executable file to dsymutil, to make command lines
  easier to copy-paste.
2022-03-11 07:28:25 +01:00
Rolf Bjarne Kvinge 84b1a87bd6
[msbuild] Improve the Strip task. (#14342)
* Enable nullability and fix code accordingly.
* Augment it to be able to take multiple files to strip at the same time.
* Strip in parallel.
* Execute using xcrun (ref: #3931)
* Pass the full path to the executable file to strip, to make command lines
  easier to copy-paste.
* Remove test that is now outdated. We have other tests that run strip
  anyways, so this shouldn't be a problem.
2022-03-11 07:28:00 +01:00
Rolf Bjarne Kvinge 233a0c4505
[msbuild] Fix a few paths to have consistently macOS paths. (#14354)
This fixes an issue where we'd do logic with Windows-style paths on macOS, and that's
never the right thing to do.

For the LinkNativeCode task, this would manifest as this error when building from windows:

> ld: file too small (length=0) file 'obj/Debug/net6.0-ios/iossimulator-x64/nativelibraries/libSystem.Native.dylib' for architecture x86_64

because the 'ShouldCopyToBuildServer' method would return incorrect results.

For the Codesign task, it would manifest as an exception trying to create a
directory with an empty string (because the directory name of a windows-style
path is an empty string on macOS).

Since this exception was quite useless (just getting the exception message
didn't tell me much about what caused the exception, because it had no stack
trace information), I've also improved error reporting in both of these tasks.
2022-03-09 21:53:14 -05:00
Rolf Bjarne Kvinge 1a21e1ee5c
[msbuild] Make the CollectBundleResourcesDependsOn property public. Fixes #11984. (#14330)
Make the CollectBundleResourcesDependsOn property public, so that custom
targets can inject themselves into the build early enough to add additional
BundleResource or Content items (by adding their custom target's name to the
CollectBundleResourcesDependsOn property).

Fixes https://github.com/xamarin/xamarin-macios/issues/11984.
2022-03-09 18:19:48 +01:00
Rolf Bjarne Kvinge 22d7ccb8ee
[msbuild] Make the default value for NoDSymUtil the same for Mac Catalyst as it is for macOS. (#14337)
I think this is what makes most sense, since they're both desktop platforms.
2022-03-09 08:21:15 +01:00
Rolf Bjarne Kvinge 4c49d44a2a
[msbuild] Handle relative paths with wrong directory separator character for metadata passed to the InstallNameTool task. (#14302) 2022-03-04 16:48:21 +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 429dc7b15e
[msbuild] Remove the AppBundleDir and Architectures properties from the DSymUtil task. (#14246)
These properties aren't used.

This also allows us to remove the CompiledArchitectures output property from
the MTouch task, because it's not longer used anymore either.
2022-02-26 02:08:34 +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 15c17ddece
[msbuild] Implement proper MSBuild logging in FileCopier. (#14176)
Fixes https://github.com/xamarin/xamarin-macios/issues/12422.
Fixes https://github.com/xamarin/xamarin-macios/issues/13697.
Fixes https://github.com/xamarin/xamarin-macios/issues/14157.
2022-02-24 16:51:49 +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 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 78b17e1a24 More bumps. 2022-02-21 22:27:34 +01:00
Rolf Bjarne Kvinge f83857638d
[tests/msbuild] Use full path to binlogs and executables. (#14195)
This way it's easier to copy-paste the path to the these files from terminal output
and open/run it (with a relative/partial path you'll need to know the current directory,
which is just an annoying thing to figure out sometimes).
2022-02-21 08:02:23 +01:00
Rolf Bjarne Kvinge 639675dd7e
[msbuild] Don't report 'unable to open object file:' from dsymutil as warnings. (#14179)
Just log these messages as normal messages, because they're not very actionable.

Ref: #13652.
2022-02-18 16:35:51 +01: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 d61af8aa70
[msbuild] Generate Versions.*.g.cs before running msbuild to build the solution. (#14163)
Hopefully fixes random build failures like this:

> xamarin-macios/msbuild/Versions.ios.g.cs(3,1): error CS1022: Type or namespace definition, or end-of-file expected
2022-02-16 20:04:59 +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
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 d9a02066ce
[msbuild] Provide a stamp file when codesign on-demand resources. Fixes #14126. (#14127)
Fixes https://github.com/xamarin/xamarin-macios/issues/14126.
2022-02-11 15:33:24 -05:00
Mauro Agnoletti 4cee76e0e1
Improvements on Xamarin.iOS.Tasks.Windows (#13862)
* Changes covered by this PR:

   - Removed unused references
   - Removed Xamarin.PreBuilt.iOS.app.zip since it's now built and included automatically as part of the CI build
   - Added missing signing and versioning
   - Replaced DotNetZip with System.IO.Compression.ZipFile: now that .net provides its own zip implementation we no longer require DotNetZip reference for unzipping purposes
   - Fixes the Tasks missing CodePages reference: we no longer need to replace the CodePages reference assembly by its implementation, since this project already specifies the `win` RID. The replacement was failing because `RuntimeTargetsCopyLocalItems` is empty now that the RID is set, so we ended up removing the reference.

Co-authored-by: Emanuel Fernandez Dell'Oca <ema@xamarin.com>
2022-02-10 14:20:33 +01:00
Rolf Bjarne Kvinge 808a61a12b
[msbuild] Make sure to set 'ResolveAssemblyConflicts=true' before importing Microsoft.CSharp.targets. Fixes #11691. (#14109)
We must set `ResolveAssemblyConflicts=true` before loading
Microsoft.Common.targets (which is loaded by Microsoft.CSharp.targets),
because otherwise we won'd do any conflict resolution at all, since the
variable isn't 'true' when it needs to be.

Also add test.

Fixes https://github.com/xamarin/xamarin-macios/issues/11691.
2022-02-09 14:07:35 -05: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 b48958be8e
[msbuild] Rework code signing to sign everything at the end of the build. (#13956)
* Add support for specifying metadata on items that are to be codesigned to
  override any general codesign setting.

* Make the Codesign task able to sign files and directories that may depend on
  eachother.

  Implement support for ordering signing so that directories containing files
  that also must be signed are signed after those files.

  This is implemented by:

  1. Normalize all input (resolve symlinks, create full path, etc.)

  2. Sort by path length (longest to shortest paths). This way we're certain
     that if we find a directory, we'll know that we won't find any files
     later in the list from inside that directory.

  3. Group into an ordered list of buckets, where each bucket contains files
     and directories that don't depend on eachother (i.e. they can all be
     signed in parallel).

  This makes it possible to call Codesign once, listing both the app bundle
  itself, and all the individual files or directories inside that need
  signing, and the Codesign task will sign the items in an order that ensures
  parent directories are always signed after any files or directories inside.

* Finally rework code signing to sign everything with a single call to the
  Codesign task in the _CodesignAppBundle target for the executable project,
  instead of having multiple calls to the Codesign task from multiple targets
  (and projects). This makes it easier to reason about what's being signed,
  and it also makes it easier to add files to the signing process.

* Also make the Codesign task able to figure out if something needs to be
  signed, and change the _CodesignAppBundle target to not keep track of
  inputs/outputs, because it becomes quite complex (for directories, it needs
  to keep track of all the files inside that directory, and also if there's
  anything in the directory that's also being signed).
2022-02-08 10:41:51 +01:00
Rolf Bjarne Kvinge 0d27c71a48
[msbuild] Unify the _CodesignAppBundle targets between iOS and Mac. (#13870)
The targets were somewhat different, where the Mac version seemed much less
evolved than the iOS version, so this meant mostly update the iOS version to
be Mac-compatible as well (and use it for macOS).
2022-01-28 09:20:58 +01:00
Rolf Bjarne Kvinge 82207afc70
[msbuild] Share the logic to CalculateCodesignAppBundleInputs between iOS and Mac. (#13844) 2022-01-25 11:34:42 +01:00
VS MobileTools Engineering Service 2 d925c246b1
Localized file check-in by OneLocBuild Task: Build definition ID 14411: Build ID 5659994 (#13853) 2022-01-24 15:36:28 -06:00
Israel Soto fb65faf113
ResolveNativeReferences task pass the Xcframework NativeReference metadata to the _FrameworkNativeReference (#13846)
* This fixes issue #13843
2022-01-24 11:13:26 -05:00
Rolf Bjarne Kvinge b3a9b07244
[msbuild] Share the logic to sign app extensions between iOS and Mac. (#13807) 2022-01-21 21:12:47 +01:00
Rolf Bjarne Kvinge c965b56784
[msbuild] Copy all the files in a framework to the Mac for the FilterStaticFrameworks task. Fixes #13804. (#13805)
The FilterStaticFrameworks task takes a list of frameworks to process, but the
files actually needed by the task are inside those frameworks, which means we
have to tell XVS that those have to be copied to the Mac for the build as well.

Fixes https://github.com/xamarin/xamarin-macios/issues/13804.
2022-01-21 08:57:39 +01:00
Rolf Bjarne Kvinge bc1368cae0
[msbuild] Move the GetFiles task to shared msbuild code (Xamarin.MacDev.Tasks). (#13800) 2022-01-20 16:22:01 +01:00
Rolf Bjarne Kvinge c6ee74377a
[msbuild] Unify some of the codesign dependency properties. (#13725) 2022-01-19 18:54:08 +01:00
Rolf Bjarne Kvinge 1d9a02cbef
[dotnet] Figure out where to publish files in the app bundle. Fixes #12572. (#13591)
In .NET, all files that should be published (put into the final .app bundle) are put into the @(ResolvedFileToPublish) item group, and at the end of the build process, .NET will publish all the files in that item group. Which files are in this item group, and how they're put in there, is out of our control (it's just how the build process works in .NET), so we'll have to cope.

Additionally, publishing an app for Apple platforms is different than publishing other .NET apps, because we can't just put all the files in the a directory like .NET usually does, we have a fairly strict directory structure we need to follow, and it also differs between platforms (the structure is different between macOS and iOS for instance).

This means that for every file in the `ResolvedFileToPublish` item group, we have to figure out:

* Should it be put into the app bundle in the first place?
* If so, in which subdirectory (if any)?

This PR implements these changes. The exact details are explained in a document in the PR, but the general logic is:

* We make an educated guess for some types of files we know about (assemblies, unmanaged libraries, images, etc).
* We provide a way to set metadata on each item specifying which type of item it is (assembly, unmanaged library, image, etc), and we'll treat the item as such. This method can also be used to override the guess we made (for files that shouldn't be published for instance).
* We warn if we run into files we're not educated enough to be able to guess about, and for which there's no custom metadata set.

Fixes https://github.com/xamarin/xamarin-macios/issues/12572.
2022-01-17 09:50:06 +01:00
Rolf Bjarne Kvinge 2992e3be1b
[msbuild] Touch all files when copying an app extension into the app. (#13721)
Touch all files when copying an app extension into the app.

This fixes an issue where we'd in some cases run into this scenario:

* Build once (successfully), and sign the app (and app extension), including all dylibs.
* We build again, copy the (unsigned) app extension into the app again, but
  not sign dylibs because the timestamp went back into the past.
2022-01-17 09:05:08 +01: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 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 0a6f7e7fd8 [msbuild] Touch up-to-date symlinks when merging app bundles.
The symlink might point to a file that has been updated, and if that file
needs more processing and the logic checks the symlink to check if the file is
up-to-date, then we need to reflect that in the symlink (for instance if a
framework binary is updated (which is a symlink on some platforms), it needs
to be resigned, even if the symlink itself didn't change).
2022-01-13 22:04:45 +01:00
Rolf Bjarne Kvinge 70851a0e9a
[msbuild] Add helpful comment about unused property (#13676)
This way I don't keep having to figure out why the property must not be
removed, even though it's not (visibly) used.
2022-01-12 20:49:10 +01:00
Rolf Bjarne Kvinge 38cf423936
[msbuild] Share the _CleanAppBundleRootDirectory target between iOS and Mac logic. (#13680) 2022-01-12 19:21:45 +01:00
Rolf Bjarne Kvinge 0bbe4423ac [msbuild] Simplify code a bit according to review. 2022-01-11 18:31:12 +01:00
Rolf Bjarne Kvinge 214064d430 Merge remote-tracking branch 'origin/main' into dotnet-resolvedfiletopublish 2022-01-11 17:32:26 +01:00
VS MobileTools Engineering Service 2 be4d23a63f
Localized file check-in by OneLocBuild Task: Build definition ID 14411: Build ID 5607500 (#13663) 2022-01-10 08:35:06 -06:00
Mauro Agnoletti 165924f83a
Ensure we remotely copy all project pdbs and not only the main app one (#13650) 2022-01-06 08:00:15 -05:00
Mauro Agnoletti 9e4eaf1f1c
[hotrestart] Fixed MSBuild outputs when using $(AppBundleManifest) (#13629)
We only want the file name of the app manifest path to define the outputs because the app manifest will be always located at the app bundle root level.
For MAUI, the app manifest source file could be located on a sub-folder (like \Platforms\iOS\Info.plist) so if we take the full value of the property we will end up looking the manifest in the wrong place inside the app bundle, causing the inputs/outputs checks to fail and forcing many tasks to always run (like code sign), also causing unwanted behaviors like breaking incremental builds and incremental deployments

Co-authored-by: Alex Soto <alex@alexsoto.me>
2022-01-04 07:10:40 -05:00
Rolf Bjarne Kvinge 3fe85ef24c
[msbuild] Make sure to update global.json/NuGet.config for the Xamarin.HotRestart.PreBuilt build whenever needed. (#13625)
This fixes an issue where rebuilding in an already build working copy after a
.NET bump would fail.
2021-12-22 21:54:18 +01:00
Rolf Bjarne Kvinge 394c8fa4c7 [msbuild] The CollectBundleResources and DetectAppManifest targets need to know the target framework moniker. 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 19dc9ce0aa [msbuild] Add a ComputeBundleLocation task 2021-12-22 10:17:35 +01:00
Rolf Bjarne Kvinge 5551e2fff7 [msbuild] Fix the ResolveNativeReferences task to return the path to the framework binary instead of the framework directory.
That's what the _FrameworkNativeReference item group contains: framework binaries
instead of the framework directory itself. This makes us process frameworks in binding
packages correctly.
2021-12-22 10:17:34 +01:00
Rolf Bjarne Kvinge a269eec46a [msbuild] Add support for computing linker arguments for native references that are dynamic libraries.
Dynamic libraries are perfectly valid native references for macOS and Mac Catalyst.
2021-12-22 10:17:34 +01:00
Rolf Bjarne Kvinge ea0b64acc6 [msbuild] Add support for processing binding resource packages directly to the ResolveNativeReferences task. 2021-12-22 10:17:33 +01:00
Rolf Bjarne Kvinge 41711e7c66 [msbuild] Refactor out the logic to process the sidecar into its own function.
Best viewed by ignoring whitespace, since this is mostly whitespace changes.
2021-12-22 10:17:33 +01:00
Rolf Bjarne Kvinge 09fc600d0d [msbuild] Augment the ResolveNativeReferences task to accept and understand *.xcframework paths.
Previously we'd only support passing in a fake reference to a file inside the *.xcframework.

This makes some other code simpler later on.

Best viewed by ignoring whitespace, since this is mostly whitespace changes.
2021-12-22 10:17:33 +01:00
Rolf Bjarne Kvinge c9610cfb6b [msbuild] Augment the Ditto task to take an AdditionalArguments property to pass to 'ditto'. 2021-12-22 10:17:33 +01:00
VS MobileTools Engineering Service 2 a7eacd2eb5
Localized file check-in by OneLocBuild Task: Build definition ID 14411: Build ID 5561912 (#13604) 2021-12-21 10:48:59 -06:00
Mauro Agnoletti d117b0a01e
Updated Xamarin.Messaging reference (#13615) 2021-12-21 09:24:42 +01:00
TJ Lambert c4e3ab85c2
[Dotnet] Fix building twice in a row issue (#13573) 2021-12-16 09:07:47 -06: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
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 d0f33c7931
[msbuild] Fix merging of apps with symlinks to directories. (#13546)
Symlinks to directories are treated the same as other symlinks (as files), not
as directories. This way we don't end up re-creating a directory hierarchy
when we only have to create a symlink.
2021-12-14 08:10:23 +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
Rolf Bjarne Kvinge b3c6218c5f
[msbuild] Improve logic to clean up the app bundle for macOS and Mac Catalyst apps before signing. (#13479)
There can't be any files in the root directory of the app bundle for macOS and
Mac Catalyst, otherwise code signing will fail. The problem is that Mono will
create a crash report in the current directory if the process crashes, and the
current directory is the root directory of the app bundle, which means that if
running an app crashes, the next build will likely fail because of the crash
report.

We had logic to detect this and remove any crash reports, but our crash report
detection pattern wasn't good enough and let some files through. This PR
updates that pattern, and also improves the code to report warnings for any
other files in the app bundle's root directory.
2021-12-07 21:33:22 +01:00
Rolf Bjarne Kvinge 6db2ef0d90
[msbuild] Enable nullable code for the Ditto task (#13493) 2021-12-07 21:33:13 +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 7dc5851520
[msbuild] Hardcode values for the nuget short folder name for legacy builds. Fixes #13469. (#13478)
The GetNuGetShortFolderName task only exists in .NET builds, which means we
have to find another way to compute the path to resources in nugets for legacy
builds. Do it the simple way by hardcoding the possible values.

Fixes https://github.com/xamarin/xamarin-macios/issues/13469.
2021-12-02 07:43:23 +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 78f52e2fc2
[msbuild/tests] Add support for xcframeworks with static libraries in them. (#13459)
* [tests] Create a libtest.xcframework and libtest2.xcframework

* [tests] Make bindings-test and bindings-test2 use an xcframework instead of plain static library

* [msbuild] Add support for xcframeworks with static libraries in them.

* List the frameworks libtest needs.

* [tests] Update .NET unit tests according to test project changes.

* [tests] Add new test to verify that packing an old-style binding project doesn't work.
2021-11-30 18:19:22 +01:00
Rolf Bjarne Kvinge e2cacb8931
[msbuild] Don't use custom logic to handle facades in .NET. (#13461)
It's not needed, and may in some cases do the wrong thing: for instance, this
logic will automatically reference any *.dll files in the project directory,
which breaks the build if those *.dll files aren't actually assemblies.
2021-11-29 07:54:47 +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 fd126c8261
[msbuild] Use the correct logic to determine the PlugIns directory for all platforms. Fixes #13415. (#13418)
The '_AppExtensionRoot' contains the correct parent directory of the 'PlugIns'
directory for all platforms, so use that instead of appending 'PlugIns' to
'_AppBundlePath' - which is incorrect on macOS and Mac Catalyst, because the
'PlugIns' parent directory is '$(_AppBundlePath)/Contents' on those platforms.

Fixes https://github.com/xamarin/xamarin-macios/issues/13415.
2021-11-23 18:34:11 +01:00
Mauro Agnoletti 61e43f8486
Updated Hot Restart pre-built app and launch icons (#13399) 2021-11-19 09:27:03 +01:00
Rolf Bjarne Kvinge 17e7f65b2c
[msbuild] Don't execute the entire _CreateBindingResourcePackage if 'NoBindingEmbedding!=true'. (#13374)
This fixes an issue where we'd create the stamp file even if 'NoBindingEmbedding' wasn't set.

Also remove SkipBindingResourcePackage property, it doesn't show up anywhere
else in our code base, nor in the history, nor anywhere relevant in Google.
2021-11-19 08:53:01 +01:00
Mauro Agnoletti 6e532b401e
Updated Messaging and Hot Restart versions (#13367)
* Updated Xamarin.Messaging version

* Updated Xamarin.iOS.HotRestart.Application version
2021-11-18 09:17:58 +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
VS MobileTools Engineering Service 2 9daff111e6
Localized file check-in by OneLocBuild Task: Build definition ID 14411: Build ID 5419189 (#13301) 2021-11-08 14:22:09 -05:00
Rolf Bjarne Kvinge 669dd22742
[msbuild] Create the directory for the .stamp file for the _CreateBindingResourcePackage target before trying to create the .stamp file. (#13179) 2021-10-29 18:34:01 +02:00
Chris Hamons 2d278e4712
[msbuild] Fix dSYM generation of iOS binding projects (#13112)
- Fixes https://github.com/xamarin/xamarin-macios/issues/13096
- This was broken in https://github.com/xamarin/xamarin-macios/pull/10304
2021-10-29 10:20:44 -05:00
Mauro Agnoletti a88ca0d29d
Updated Xamarin.Messaging version (#13145)
* Updated Xamarin.Messaging version

* Adapt BuildAgent to new Messaging changes
2021-10-28 17:00:14 +02:00
Rolf Bjarne Kvinge b70e6f4674
Submodule MonoTouch.Dialog. (#13058)
* Submodule MonoTouch.Dialog.

Submodule MonoTouch.Dialog, so that we can easily build it using .NET. This
submodule will become redundant when/if we publish a .NET version of
MonoTouch.Dialog, but until that happens we need it at least for our own test
suites.

This also means we have to copy our NuGet.config and global.json files to the
MonoTouch.Dialog project directory so that we point msbuild to use our local
build.

New commits in spouliot/Touch.Unit:

* spouliot/Touch.Unit@cbda703 [Touch.Client] Use MonoTouch.Dialog from a submodule. (#109)

Diff: 3345db2f4e..cbda703583

* Use relative path for submodule.

And fix indentation and set the branch name.

* Don't use 'RootTestsDirectory' when it might not be defined yet.

* [tests] Our test projects don't need to reference MonoTouch.Dialog directly.

The projects get the MonoTouch.Dialog reference indirectly through the
Touch.Client project reference.

* [tests] Only validate unique errors in the .NET unit tests.

* [tests] No need to reference System.Json anymore, that's handled directly in the MonoTouch.Dialog project.

* [tests] Reference nunit.framework.targets so we get a workaround for an NUnit issue everywhere.

* [msbuild] Only try to create a package if we're able to create an app bundle.

This fixes an issue where a library project would try (and fail) to create a
package when 'CreatePackage=true' (which could be set for the executable
project, but inherited by the library project since the executable project
depends on it).

* [tests] Adjust PackTest.BindingXcFrameworksProject to not set the AssemblyName property.

MSBuild ends up being very confused when the project we're trying to build
depends on other projects, because AssemblyName is set for all the projects
being build, and MSBuild complains about ambiguous projects:

> error: Ambiguous project name 'bindings-xcframework-test'
2021-10-26 08:18:34 +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
Mauro Agnoletti b2678a413c
Updated Hot Restart client package (#13029) 2021-10-20 07:45:34 +02:00
VS MobileTools Engineering Service 2 b1b4285109
Localized file check-in by OneLocBuild Task: Build definition ID 14411: Build ID 5313177 (#12967) 2021-10-11 10:26:55 -05:00
Rolf Bjarne Kvinge 79b4c9234d
[msbuild] Rename ResolveFrameworksBase.cs to ResolveNativeReferencesBase.cs (#12943)
This way the filename matches the class within.
2021-10-07 08:18:16 +02:00
Rolf Bjarne Kvinge f12d09f405
[msbuild] Share the CompileEntitlements task implementation between iOS and macOS. (#12946) 2021-10-07 08:17:50 +02:00
Rolf Bjarne Kvinge 2bc66b0cbe
[msbuild] Share the CodesignVerify task implementation between iOS and macOS. (#12918) 2021-10-06 15:51:42 +02:00
VS MobileTools Engineering Service 2 c0032bee1a
Localized file check-in by OneLocBuild Task: Build definition ID 14411: Build ID 5286115 (#12916) 2021-10-06 08:31:25 -05: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 b772397b63
[msbuild] Share the BTouch task implementation between iOS and macOS. (#12873) 2021-10-04 08:18:47 +02:00
Rolf Bjarne Kvinge 62bdd683cf
[dotnet] Add support for 'dotnet pack'. Fixes #12631. (#12900)
Add support for 'dotnet pack', by:

1. Add a workaround for the fact that as soon as a project has a
   'NativeReference' item, .NET's MSBuild logic wants to include a
   'Native.$(AssemblyName).manifest' file in the NuGet. This obviously breaks,
   because we don't create such a file, so we work around it by removing the
   file in question from the corresponding item groups.

2. Add any binding resource packages to the NuGet.

3. Add tests.

Fixes https://github.com/xamarin/xamarin-macios/issues/12631.
2021-10-04 07:43:55 +02:00
Rolf Bjarne Kvinge 82e5fc4192
[msbuild] Ignore CS8002 for the Xamarin.iOS.Tasks and Xamarin.Mac.Tasks projects. (#12867)
Fixes these warnings, which we don't care about:

    CSC : warning CS8002: Referenced assembly 'Xamarin.MacDev.Tasks.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have a strong name. [(...)/xamarin-macios/msbuild/Xamarin.iOS.Tasks/Xamarin.iOS.Tasks.csproj]
    CSC : warning CS8002: Referenced assembly 'Xamarin.iOS.Tasks.Core, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' does not have a strong name. [(...)/xamarin-macios/msbuild/Xamarin.iOS.Tasks/Xamarin.iOS.Tasks.csproj]
    CSC : warning CS8002: Referenced assembly 'Xamarin.MacDev.Tasks, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have a strong name. [(...)/xamarin-macios/msbuild/Xamarin.iOS.Tasks/Xamarin.iOS.Tasks.csproj]
    CSC : warning CS8002: Referenced assembly 'Xamarin.Localization.MSBuild, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have a strong name. [(...)/xamarin-macios/msbuild/Xamarin.iOS.Tasks/Xamarin.iOS.Tasks.csproj]
    CSC : warning CS8002: Referenced assembly 'Xamarin.MacDev.Tasks.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have a strong name. [(...)/xamarin-macios/msbuild/Xamarin.Mac.Tasks/Xamarin.Mac.Tasks.csproj]
    CSC : warning CS8002: Referenced assembly 'Xamarin.Mac.Tasks.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have a strong name. [(...)/xamarin-macios/msbuild/Xamarin.Mac.Tasks/Xamarin.Mac.Tasks.csproj]
2021-10-01 08:40:19 +02:00
Rolf Bjarne Kvinge 43d894da15
[msbuild/tools] Augment the CreateBindingResourcePackage to support creating a zipped binding resource package. (#12868)
Augment the CreateBindingResourcePackage to support creating a zipped binding
resource package (which is just a zipped version of the binding resource
package). This can either be manually chosen by the new 'Compressed' property,
or automatically detected (create a zipped version when there's a symlink in
the binding resource package).

The default is to not create a zipped version in legacy Xamarin, and
automatically detect for .NET.

The problem this is trying to solve is when creating a NuGet package - NuGet
doesn't handle symlinks correctly and it's not possible to create a NuGet with
symlinks. Instead we need to create a zipfile with all the binding resources.
The default has been chosen so that we automatically create a zip file when
it's required for .NET, while still maintaining old behavior with legacy
Xamarin.
2021-10-01 08:40:01 +02: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 7a090e9dc8
[msbuild] Sign the localization assembly as well. (#12869)
Fixes this problem:

    error MSB4018: The "FindItemWithLogicalName" task failed unexpectedly.
    error MSB4018: System.IO.FileLoadException: Could not load file or assembly 'Xamarin.Localization.MSBuild, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)
    error MSB4018: File name: 'Xamarin.Localization.MSBuild, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
    error MSB4018: at Xamarin.MacDev.Tasks.FindItemWithLogicalNameTaskBase.Execute()
    error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
    error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
2021-09-30 07:32:06 +02:00
Rolf Bjarne Kvinge cd2867d44c
[msbuild] Share the Metal[Lib] task implementations between iOS and macOS. (#12851) 2021-09-29 07:55:55 +02:00
Rolf Bjarne Kvinge 09905e8021
[msbuild] Share the ALToolUpload and ALToolValidate task implementations between iOS and macOS. (#12852) 2021-09-28 17:38:51 +02:00
Rolf Bjarne Kvinge 8b2288fe59
[msbuild] Share the ScnTool task implementation between iOS and macOS. (#12850) 2021-09-28 17:31:53 +02:00
Rolf Bjarne Kvinge 7dc2d9af61
[msbuild] Sign Xamarin.iOS.Tasks.dll and Xamarin.Mac.Tasks.dll. Fixes #9835. (#12831)
We need to strongname our MSBuild assemblies, so that different versions
can be loaded side-by-side (one example being having both a legacy and a
.NET project in the same solution).

This required setting a version for Xamarin.iOS.Tasks.dll and
Xamarin.Mac.Tasks.dll, otherwise strong-naming won't work properly (all
versions of an assembly would have the same identity).

Also sign the corresponding test assemblies, since they poke into the
internals of the task assemblies.

Fixes https://github.com/xamarin/xamarin-macios/issues/9835.
2021-09-28 17:31:35 +02:00
Rolf Bjarne Kvinge 5cd7c96dcf
[msbuild] Share the TextureAtlas task implementation between iOS and macOS. (#12826) 2021-09-27 20:27:24 +02:00
VS MobileTools Engineering Service 2 0ef3a43a08
Localized file check-in by OneLocBuild Task (#12836) 2021-09-27 08:10:31 -04:00
Rolf Bjarne Kvinge 9a299aeded
[msbuild] Share the OptimizeImage and OptimizePropertyList tasks and targets between iOS and macOS. (#12819)
This brings .png and .plist optimization to macOS (but no behavior is changed,
because it's already disabled by default).
2021-09-24 16:26:28 +02:00
Rolf Bjarne Kvinge 4464cc7cc7
[msbuild] Share the *CompileTextureAtlas targets between Xamarin.iOS and Xamarin.Mac. (#12818)
The iOS version is more advanced (has additional fixes for incremental
builds), so that's the one that got chosen.
2021-09-24 07:46:50 +02:00
Rolf Bjarne Kvinge 5318a2b9fa
[msbuild] Make the CompileAppManifestTaskBase.AppManifest property an ITaskItem. (#12804)
So that any input app manifest is copied to Windows when doing remote builds.
2021-09-23 18:46:37 +02:00