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

61 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge 4b35372703 [dotnet] More 'net6.0' -> 'DOTNET_TFM' variable usage. 2022-03-25 14:16:02 +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 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 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 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 7774518079 [tests] Allow for more time to build tests/test-libraries now, since more work is being done there 2021-12-22 10:17:34 +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 f12d09f405
[msbuild] Share the CompileEntitlements task implementation between iOS and macOS. (#12946) 2021-10-07 08:17:50 +02: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 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 cd2867d44c
[msbuild] Share the Metal[Lib] task implementations between iOS and macOS. (#12851) 2021-09-29 07:55:55 +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
Rolf Bjarne Kvinge c4a67e585c
[msbuild/tools] Add a better error message for when we fail to convert between iOS and macOS versions for Mac Catalyst. (#12767)
New commits in xamarin/Xamarin.MacDev:

* xamarin/Xamarin.MacDev@9e6e29f [Xamarin.MacDev] Return valid iOS/macOS versions when converting betweeen iOS and macOS versions for Mac Catalyst.

Diff: 41d91e0de0..9e6e29f2a4
2021-09-21 16:19:04 +02:00
Rolf Bjarne Kvinge a96c28b979
[msbuild] Call the generator using a response file. (#12756)
Fixes this warning:

> Xamarin.Shared.targets(992,3): warning MSB6002: The command-line for the "BTouch" task is too long. Command-lines longer than 32000 characters are likely to fail. Try reducing the length of the command-line by breaking down the call to "BTouch" into multiple calls with fewer parameters per call.
2021-09-20 07:40:57 +02:00
Rolf Bjarne Kvinge 811384f7d2
[msbuild] Fix parsing extra bundler arguments where a space separates the name and value of the argument. (#12731)
Fix parsing extra bundler arguments where a space separates the name and the
value of the argument, like this: '--xml file.xml' (as opposed to
'--xml:file.xml' or '--xml=file.xml').

Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1385946.
2021-09-16 08:17:33 +02:00
Rolf Bjarne Kvinge aadd53249f
[msbuild] Improve E7082 error message. (#12689) 2021-09-10 22:02:30 +02:00
Rolf Bjarne Kvinge 24ea02759f
[dotnet] Support SupportedOSPlatformVersion. Fixes #12336. (#12638)
* Add support for the SupportedOSPlatformVersion MSBuild property, and write
  it to the Info.plist for the corresponding minimum OS version.
* If there are any minimum OS version in the Info.plist, we'll now show an
  error if it doesn't match SupportedOSPlatformVersion.

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

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

Fixes https://github.com/xamarin/xamarin-macios/issues/12336.
2021-09-08 09:20:05 +02:00
Rolf Bjarne Kvinge 6fdec1259d [tests] Add tests for CompileAppManifest and ReadAppManifest. 2021-08-24 14:41:20 +02:00
Rolf Bjarne Kvinge b3dff34ea5 [msbuild] Rework how the app manifest is created.
How we create the app manifest (Info.plist) has to be modified so that we can add
support for getting all the values from MSBuild properties (i.e. no Info.plist in
the project), as well as having multiple partial app manifests as well, that gets
merged into the final app manifest.

Here's the new process:

1. The user can specify values in multiple ways:

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

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

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

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

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

   The targets in question are:

	* _CompileImageAssets * _CompileCoreMLModels

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

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

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

* No Info.plist at all, all non-default values come from MSBuild properties.
* A single Info.plist, where everything is specified.
* An Info.plist with multiple partial app manifests as well.
2021-08-23 17:46:33 +02:00
Rolf Bjarne Kvinge 6f9a8ebbbd
[msbuild] Rename the GetMinimumOSVersion task to ReadAppManifest and make it read more properties from the app manifest. (#12485)
* Read CFBundleDisplayName and CFBundleVersion and use them in the
  _CompileITunesMetadata task.

* Read numerous other app manifest values and pass them to the ACTool and
  IBTool tasks.

This makes it possible to not parse the Info.plist in these tasks, which will
become more complicated in the future, when we might either not have an
Info.plist, or have many partial ones.

Also enable nullability.
2021-08-20 09:54:59 +02:00
Rolf Bjarne Kvinge 716a5a7bd1
[msbuild] Add a property that specifies the final path to the Info.plist in the app bundle (#12433)
* Add an '_AppBundleManifest' property that specifies the final path to the
  Info.plist in the app bundle.
* Remove the '_AppBundleManifestPath' property, it's not used anywhere.
* Adjust the CompileAppManifest task to take the final path to the Info.plist,
  instead of computing it and returning it. This way the CompileAppManifest
  task does not output anything back into MSBuild (which is important, because
  the CompileAppManifest task won't execute if the output file is up-to-date,
  and if it's not executed, any output properties won't be set either).
2021-08-17 15:29:42 +02:00
Rolf Bjarne Kvinge e3969482a8
[msbuild] Unify the iOS and macOS versions of the IBTool task. (#12424)
* Have a single implementation of AutoActivateCustomFonts.
* Share the GetTargetDevices implementations between ACTool and IBTool, after removing
  a condition for Xcode 6.0 (which we don't support anymore, so that check could
  be removed) the implementations were identical.
2021-08-16 10:54:28 +02:00
Rolf Bjarne Kvinge 2972e1b715
Fix some whitespace issues in various files. (#12399)
* Remove BOM
* Add EOL at end of file.
2021-08-11 10:06:46 +02:00
TJ Lambert f3758812ec
[Localization] Removing Test with Ignore File (#12258)
Co-authored-by: tj_devel709 <antlambe@microsoft.com>
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2021-08-02 20:43:30 -04:00
VS MobileTools Engineering Service 2 c5e60a1462
[Localization] Localized file check-in by OneLocBuild Task: Build definition ID 14411: Build ID 5018259 (#12220) 2021-07-28 09:57:35 -05:00
VS MobileTools Engineering Service 2 042cd714fe
Localized file check-in by OneLocBuild Task: Build definition ID 14411: Build ID 4945304 (#12079)
First group of translated resx files coming from OneLocBuild!
2021-07-21 17:34:51 -05:00
Rolf Bjarne Kvinge 8aff15a4f0 [tests] Don't run parallel make in tests/common/TestProjects/ComplexAssembly, it may cause make to deadlock. 2021-06-25 08:26:01 +02:00
Rolf Bjarne Kvinge 2f65937d27 [tests] Remove BOM in new file. 2021-06-24 14:23:23 +02:00
Rolf Bjarne Kvinge 82fc13efbc [tests] Fix assertions regarding errors after recent changes. 2021-06-24 14:16:14 +02:00
Rolf Bjarne Kvinge 5ecb7ae337 [msbuild] List all files causing errors. 2021-06-23 18:38:46 +02:00
Rolf Bjarne Kvinge 2f1667e593 [tests] Remove MSBuildSDKsPath from the environment before invoking make which may call 'dotnet build'. 2021-06-22 16:52:27 +02:00
Rolf Bjarne Kvinge f1cc00ce3a [tests] Update tests according to the actual error messages. 2021-06-21 11:45:50 +02:00
Rolf Bjarne Kvinge 718d9548a3 [tests] Improve error reporting when SetUp fails in MergeAppBundleTaskTest. 2021-06-21 11:45:21 +02:00
Rolf Bjarne Kvinge bc9e007343 [tests] Updated list of not-yet-localized error messages. 2021-06-21 11:36:45 +02:00
Rolf Bjarne Kvinge 4f8e9a872e [tests] Add new tests for merging app bundles 2021-06-18 10:34:35 +02:00
Sebastien Pouliot 7916e74b89
[windows][msbuild] Copy entire directory when the native reference is a framework (#11868)
The entire `.framework` directory needs to be copied back to Windows
when a native reference is a [xc]framework. Otherwise important files
will be missing and the app bundle will be unusable.

Fix https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1339824
2021-06-09 09:21:17 -04:00
TJ Lambert e06ee8e653
[Localization] Test to make sure the new resx files are compiled to Resources (Edited) (#11737)
* making sure new strings get added to designer and resources plus the test

* Next wave of changes to csproj to incorporate Rolf's changes

* fixing path

* Update tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/LocalizationStringTest.cs

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

* Update tests/mtouch/LocalizationTests.cs

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

* forgot the include

Co-authored-by: tj_devel709 <antlambe@microsoft.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2021-06-02 11:11:15 -05:00
TJ Lambert 4fb1707e11
initial changes to Change languageSet and Dependencies (#11512)
Co-authored-by: tj_devel709 <antlambe@microsoft.com>
2021-05-13 08:35:08 -05:00
tj_devel709 6d23054789 removing ignores from 2 msbuild localization tests as well as inserting forgotten test casess 2021-05-07 10:43:03 -05:00
TJ Lambert a154f30e03
[Localization] Localization changes for OneLocBuild (#11395)
Enabling MSBuild, Mtouch, and all their localization dependencies to use the new resx files provided from OneLocBuild.
2021-05-06 19:42:53 -05: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
Sebastien Pouliot 00a69e1654
[dotnet] Update `Min*` constants and fix builds for tests (#10835)
We're bumping the minimum OS versions for all supported platforms
https://github.com/dotnet/core/blob/master/release-notes/6.0/6.0-supported-os.md

Intro's `Introduced` test is ignored as it require (a lot of) changes. This
will be fixed in separate PRs and gradually re-enabled.

iOS
```
[FAIL] Introduced : 7573 API with unneeded or incorrect version information
```

tvOS
```
[FAIL] Introduced : 299 API with unneeded or incorrect version information
```

Tracking progress in https://github.com/xamarin/xamarin-macios/issues/10834
2021-03-13 10:38:46 -05:00
Rolf Bjarne Kvinge 7c6c8e02e3
[msbuild] Use the macOS SDK to build Mac Catalyst apps instead of the iOS SDK (#10644)
* Bump Xamarin.MacDev.

New commits in xamarin/Xamarin.MacDev:

* xamarin/Xamarin.MacDev@1e738e9 [Xamarin.MacDev] Extract the code to convert between Mac Catalyst versions to a separate file. (#89)
* xamarin/Xamarin.MacDev@a3bb12c [Xamarin.MacDev] Add methods to map between iOS and macOS versions for Mac Catalyst. (#88)

Diff: 02d6d05be3..1e738e9f7f

* [msbuild] Use the macOS SDK to build Mac Catalyst apps instead of the iOS SDK

From a native compilation perspective, compilating a Mac Catalyst is the macOS SDK
+ a dash of iOS, so use the native macOS SDK to compile, and then do the corresponding
adjustments elsewhere.

At the same time document which version we want for the sdk version and the deployment
target in mtouch, and adjust the code accordingly (sdk version: macOS version; deployment
target: iOS version).

* Update resource files

* Add new entry to canary test for string localization.
2021-02-17 17:25:36 +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 c3677a0b39
[msbuild] Bump Xamarin.MacDev and use AppleSdkVersion instead of MacOSXSdkVersion/IPhoneSdkVersion. (#10622)
This requires bumping Xamarin.MacDev.

New commits in xamarin/Xamarin.MacDev:

* xamarin/Xamarin.MacDev@02d6d05 [Xamarin.MacDev] Add an AppleSdkVersion struct which replaces IPhoneSdkVersion and MacOSXSdkVersion. (#87)
* xamarin/Xamarin.MacDev@e7ec7ef [Xamarin.MacDev] Fail gracefully if trying to grab a PList entry from a file that doesn't exist. (#86)

Diff: fae0237704..02d6d05be3
2021-02-12 07:34:41 +01:00
Rolf Bjarne Kvinge 9d4e1ae32a Merge remote-tracking branch 'origin/main' into dotnet-interpreter 2021-02-03 12:52:24 +01:00
Rolf Bjarne Kvinge 51648223be Add newly added localizable string to canary test of translated strings. 2021-02-01 17:14:42 +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 c48c62fed5
[msbuild] Unify how CFBundleName is calculated. (#10475)
* [msbuild] Unify how CFBundleName is calculated.

Previously, CFBundleName would default to:

* iOS: CFBundleDisplayName (if set), otherwise the app bundle name.
* all other platforms: the app bundle name.

Now unify the logic so that we have the same behavior on all platforms.

This is a breaking change under the following conditions:

* Building for iOS
* CFBundleName is not set in the Info.plist
* CFBundleDisplayName is set in the Info.plist
* CFBundleDisplayName from the Info.plist is different from AssemblyName in
  the csproj (which is the value used to calculate the app bundle name).

The fix would be to:

* Set CFBundleName in the Info.plist to the desired value.

This change works in previous versions of Xamarin.iOS as well.

* Update tests.
2021-01-21 14:29:19 +01:00
Sebastien Pouliot 4eda43b1c9
[msbuild] Fix semi-conflicting options to set codesign timestamp (#10428)
TL&DR:

This effectively change nothing - but prevents (warn) if both options
contradict themselves.

Long Story....

So we have two ways to control the codesign's `--timetamp` option but
they both ignore each other so we can end up with the option being
set more than once at build time.

`DisableTimestamp` was the original one. It was meant for iOS (and
derivative OS) and disable the option (which requires the network)
for simulator or debug builds. IOW we _wanted_ timestamps when doing
release builds for devices.

```
DisableTimestamp="$(_CodesignDisableTimestamp)"
```

```
<_CodesignDisableTimestamp>False</_CodesignDisableTimestamp>
<_CodesignDisableTimestamp Condition="'$(_SdkIsSimulator)' == 'true' Or '$(_BundlerDebug)' == 'true'">True</_CodesignDisableTimestamp>
```

Now disabling the timestamp did not mean it was enabled. We did not ask
for a timestamp, leaving it to the default which from `man codesign`
means:

> If this option is not given at all, a system-specific default behavior is invoked.
> This may result in some but not all code signatures being timestamped.

Then `UseSecureTimestamp` was added for macOS builds. If hardening is
enabled then a secure timestamp is required.

`msbuild/Xamarin.Mac.Tasks/Xamarin.Mac.Common.targets` `_CodesignAppBundle`

```
UseSecureTimestamp="$(UseHardenedRuntime)"
```

However it's also exposed for iOS (shared target) in
`msbuild/Xamarin.Shared/Xamarin.Shared.targets` `__CodesignNativeLibraries`
but it would always be `false` in that case.

Adding this option means there's now always a `--timestamp` option given,
either to enable it (no URL so it means using Apple's server) or to
disable it (`=none`) but since it's controlled by `UseHardenedRuntime`,
which is macOS only, then iOS device builds are never timestamped.

An alternative would be to have `UseSecureTimestamp` as a macOS-only
option - but that would change how we currently sign the iOS applications
and I'd rather not change things that are known to work.
2021-01-15 10:43:11 -05:00