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

152 Коммитов

Автор SHA1 Сообщение Дата
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 f4ac99efc0
[dotnet] Build & publish MacCatalyst packs. (#10624)
* [dotnet] Build & publish MacCatalyst packs.

* Add runtime support.
2021-02-12 07:38:43 +01:00
Rolf Bjarne Kvinge 1a0f250e05
[dotnet] Normalize the casing of the 'TargetPlatformIdentifier' value on Mac Catalyst. (#10617) 2021-02-11 20:19:36 +01:00
Rolf Bjarne Kvinge f127e614c9
[dotnet] Templateify some build logic. (#10618)
* [dotnet-linker] Templateify the install logic.

* [builds] Templateify the Versions.plist install logic.

* [dotnet] Create a per-platform Versions.props file with only the values applicable to that platform.

Also move the definition of the default TargetPlatformVersion to Make.versions, where we have other versions.

* [dotnet] Templateify some build code.
2021-02-11 20:17:12 +01:00
Eric Erhardt 3d932ebbb7
Default InvariantGlobalization in Xamarin IOS (#10598)
This allows for unnecessary code to be trimmed by default in an app. See https://github.com/dotnet/runtime/pull/47999.
2021-02-10 08:02:34 +01:00
Rolf Bjarne Kvinge f01fde5cd9
[dotnet] Don't use install-location in pkgs. (#10583)
Don't use install-location to specify where files should be installed, because
our notarization process replaces this value in the pkg manifest with the root
directory (without updating anything else), with the result that notarized
packages tries to install files in the wrong location.

Instead specify the full path for each individual file, so that the
install-location can be the root directory (and thus the notarization process
won't corrupt the package).
2021-02-08 07:35:32 +01:00
Rolf Bjarne Kvinge f5156f7ed7
[dotnet] Add support for the interpreter on device. Fixes #10292. (#10555)
* Pass and parse the MtouchInterpreter value to dotnet-linker.
* Move required logic from mtouch to shared code to take advantage of existing
  code to compute AOT arguments (which we need to compute the correct AOT
  arguments for System.Private.Corelib.dll, which is always AOT-compiled).
* Add a linker task to compute the AOT arguments for .NET.
* Add test projects.

This PR is probably best reviewed commit-by-commit.

Fixes https://github.com/xamarin/xamarin-macios/issues/10292.
2021-02-05 07:47:23 +01:00
Jonathan Peppers e30c5b3502
[.NET 6] make sure Run target depends on Build (#10581)
Fixes: https://github.com/xamarin/xamarin-macios/issues/10575

Running `dotnet build -t:Run` on a new project fails with:

    Xamarin.Shared.Sdk.targets(692,3): error MSB4018: The "GetMlaunchArguments" task failed unexpectedly.
    Xamarin.Shared.Sdk.targets(692,3): error MSB4018: System.IO.DirectoryNotFoundException: Could not find a part of the path '/Users/jopepper/src/net6-samples/HelloiOS/bin/Debug/net6.0-ios/ios-x64/HelloiOS.app\Info.plist'.
    Xamarin.Shared.Sdk.targets(692,3): error MSB4018:    at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
    Xamarin.Shared.Sdk.targets(692,3): error MSB4018:    at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
    Xamarin.Shared.Sdk.targets(692,3): error MSB4018:    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
    Xamarin.Shared.Sdk.targets(692,3): error MSB4018:    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
    Xamarin.Shared.Sdk.targets(692,3): error MSB4018:    at Xamarin.MacDev.PObject.FromFile(String fileName, Boolean& isBinary) in /Users/builder/azdo/_work/1/s/xamarin-macios/external/Xamarin.MacDev/Xamarin.MacDev/PListObject.cs:line 344
    Xamarin.Shared.Sdk.targets(692,3): error MSB4018:    at Xamarin.MacDev.PDictionary.FromFile(String fileName, Boolean& isBinary) in /Users/builder/azdo/_work/1/s/xamarin-macios/external/Xamarin.MacDev/Xamarin.MacDev/PListObject.cs:line 774
    Xamarin.Shared.Sdk.targets(692,3): error MSB4018:    at Xamarin.MacDev.PDictionary.FromFile(String fileName) in /Users/builder/azdo/_work/1/s/xamarin-macios/external/Xamarin.MacDev/Xamarin.MacDev/PListObject.cs:line 761
    Xamarin.Shared.Sdk.targets(692,3): error MSB4018:    at Xamarin.iOS.Tasks.GetMlaunchArgumentsTaskBase.get_DeviceType() in /Users/builder/azdo/_work/1/s/xamarin-macios/msbuild/Xamarin.iOS.Tasks.Core/Tasks/GetMlaunchArgumentsTaskBase.cs:line 53
    Xamarin.Shared.Sdk.targets(692,3): error MSB4018:    at Xamarin.iOS.Tasks.GetMlaunchArgumentsTaskBase.GetDeviceTypes() in /Users/builder/azdo/_work/1/s/xamarin-macios/msbuild/Xamarin.iOS.Tasks.Core/Tasks/GetMlaunchArgumentsTaskBase.cs:line 72
    Xamarin.Shared.Sdk.targets(692,3): error MSB4018:    at Xamarin.iOS.Tasks.GetMlaunchArgumentsTaskBase.GenerateCommandLineCommands() in /Users/builder/azdo/_work/1/s/xamarin-macios/msbuild/Xamarin.iOS.Tasks.Core/Tasks/GetMlaunchArgumentsTaskBase.cs:line 128
    Xamarin.Shared.Sdk.targets(692,3): error MSB4018:    at Xamarin.iOS.Tasks.GetMlaunchArgumentsTaskBase.Execute() in /Users/builder/azdo/_work/1/s/xamarin-macios/msbuild/Xamarin.iOS.Tasks.Core/Tasks/GetMlaunchArgumentsTaskBase.cs:line 199
    Xamarin.Shared.Sdk.targets(692,3): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
    Xamarin.Shared.Sdk.targets(692,3): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)

Unless you do `dotnet build` and `dotnet build -t:Run` in two steps.

It doesn't look like the built-in .NET 6 `Run` target depends on `Build`
at all:

91c1326f47/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets (L865-L867)

So let's reorganize things to fix this:

* `_PrepareRun` now runs on all platforms, it depends on `Build`.
* `_PrepareRunMobile` now has the condition so it will not run on macOS.
* `_PrepareRunMobile` doesn't need as many targets listed in
`DependsOnTargets` now, because `Build` has already run.
2021-02-05 07:42:39 +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 c5afca3888
Bump to .NET 6.0.100-preview.1.21081.5. (#10552)
* Bump to .NET 6.0.100-preview.1.21080.4.

* [dotnet] The linker automatically marks the build output as a root assembly.

* Bump to .NET 6.0.100-preview.1.21081.5.

* [dotnet] Turns out we do need mark the build output as a root assembly, but with we now have to use the full path.
2021-02-03 07:32:05 +01:00
Rolf Bjarne Kvinge 7f0e2449f7 [dotnet-linker] Add a new task that computes the arguments to the AOT compiler. 2021-02-01 14:37:31 +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 fa72e6c890 [dotnet] Add the AOT output directory and IntermediateLinkDir to the custom linker options 2021-01-28 08:09:59 +01:00
Rolf Bjarne Kvinge fa1ef254d6 [dotnet] Make the output directory for AOT-compiled code arch-specific 2021-01-28 08:09:59 +01:00
Rolf Bjarne Kvinge c80eed5d62 [tools] Pass and parse the MtouchInterpreter value. 2021-01-28 08:09:59 +01:00
Rolf Bjarne Kvinge 69c1a715c6
[dotnet] Add support for LinkDescription items. (#10467)
* [dotnet] Add support for LinkDescription items.

Also use the LinkDescription item group instead of a custom one
(_BundlerXmlDefinitions), since there's no need for the custom one.

* The world (aka mmp) isn't quite ready for this yet.

* Don't parse into LinkDescription, use a temporary variable instead.

And then only use the temporary variable for .NET.

The problem is that parsing mtouch extra args and adding any --xml arguments
to LinkDescription is that the xml file will be passed again to mtouch, and in
this case any ${ProjectDir} properties won't be evaluated.
2021-01-27 17:59:35 +01:00
Rolf Bjarne Kvinge aa671914f9
[dotnet] Remove workaround for mono/linker#1304, which has now been fixed. (#9862) 2021-01-18 08:21:31 +01:00
Rolf Bjarne Kvinge ef8cdfa64e
[dotnet] Add default exclusions for recursive patterns to not pick up files in the bin/obj directories. (#10422) 2021-01-15 08:25:42 +01:00
Rolf Bjarne Kvinge 471da9f51b
[dotnet] Don't AOT compile resource assemblies. (#10418)
Xamarin.iOS don't AOT compile resource assemblies, so we shouldn't do so in
.NET either (and in any case they end up causing native linking failures due
to duplicate native symbols).
2021-01-14 14:37:50 +01:00
Rolf Bjarne Kvinge 26803f791d
[dotnet] Set default runtime feature switches. (#10250)
Set all current feature switches, except for InvariantGlobalization, to
defaults which trim the features.

Ref: https://github.com/dotnet/runtime/blob/master/docs/workflow/trimming/feature-switches.md
Ref: https://github.com/xamarin/xamarin-android/pull/5337

This drops the hello world app size from 28.6 MB to 23.5 MB. Full report:
https://gist.github.com/rolfbjarne/71cc18b49446862f1d42aa29526b0ac6
2020-12-10 15:19:40 +01:00
Filip Navara 17722deab4
[dotnet] Prevent linking out code referenced by P/Invoke (#10182)
* [dotnet] Generate references.mm to prevent linking out code referenced by P/Invoke

* Address PR feedback: Namespaces.Foundation -> "Foundation."

* Address PR feedback: Simplify hasSymbols

* Reuse ListExportedSymbols step, respect App.SymbolMode

* Address PR feedback

* Workaround for tvOS
2020-12-03 14:04:11 +01:00
Rolf Bjarne Kvinge 945bd5c4b5
[dotnet] Don't link the main executable with any dylibs on macOS. (#10127)
Don't link the main executable with any dylib (except libcoreclr) on macOS,
because that may end up running library initializers in those dylibs, and they
may abort if something goes wrong.

This way we delay any failures until those dylibs are actually needed.

In particular, libSystem.Security.Cryptography.Native.OpenSsl.dylib will abort
in its library initializer if it can't find the native libssl.dylib it wants:
1d9e50cb47/src/libraries/Native/Unix/System.Security.Cryptography.Native/opensslshim.c (L122-L126)
and my system doesn't have any of the libssl.dylib versions that code wants.
2020-11-23 08:27:47 +01:00
Alex Soto 72c7b1ffcc
[main][watchOS] Add x86_64 simulator support (#10059)
* [watchOS] Add x86_64 simulator support

* Build runtime/registrar x86_64 slices
* Produce a 64 bit version of Xamarin.WatchOS.dll
* Allow building x86_64 for watch simulators in mtouch
* Let xharness know about x86_64

* [tests] Add x86_64 arch to test-libraries

* Make dotnet package aware of x64

* [ObjCRuntime] Fix computing if we're calling a stret function or not in a 64-bit watchOS simulator.

* [xharness] Re-enable some watchOS tests.

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2020-11-20 09:27:46 -05:00
Rolf Bjarne Kvinge d6756f4829 Merge remote-tracking branch 'origin/main' into dotnet-6.0.100-alpha.1.20559.4 2020-11-11 16:38:15 +01:00
Rolf Bjarne Kvinge 59cdbc6098 [dotnet] Disable a very eager linker optimization.
Fixes these monotouch-test tests:

   MonoTouchFixtures.CoreImage.CIKernelTests
      [FAIL] CIKernel_BasicTest :   CIKernel_BasicTest we disagree that it is a color kernel
         Expected: True
         But was:  False
            :    at MonoTouchFixtures.CoreImage.CIKernelTests.CIKernel_BasicTest()

   [FAIL] CIKernel_TestFromPrograms :   CIKernel_TestFromPrograms is neither type of kernel?
         Expected: True
         But was:  False
            :    at MonoTouchFixtures.CoreImage.CIKernelTests.CIKernel_TestFromPrograms()
2020-11-11 16:37:39 +01:00
Rolf Bjarne Kvinge 6a976dc454 [dotnet] Fix whitespace. 2020-11-10 17:17:15 +01:00
Rolf Bjarne Kvinge db23ca881a
[dotnet] Add _CreateDebugSettings, _CreateDebugConfiguration and _CreatePkgInfo to the targets we run on app creation. (#10061) 2020-11-10 13:44:26 +01:00
Rolf Bjarne Kvinge 8f0ca7508a [dotnet] Reorder imports to account for that our targets are imported earlier in the build process.
In the latest .NET 6, our Workloads.targets is imported earlier in the build. This
requires a few changes, because we still need to run most of our logic later in the
process, which we do by adding targets files we want imported later to the AfterMicrosoftNETSdkTargets
property.

What we're loading as soon as possible:

* Our version information (Xamarin.Shared.Sdk.Versions.targets)
* The supported OS versions (Microsoft.<platform>.Sdk.SupportedTargetPlatforms.targets)
* The default OS version (Xamarin.Shared.Sdk.TargetFrameworkInference.targets).

This is all information that the .NET build require early on.

Changes:

* Rename all files that are loaded early to *.props.
* Updated documentations to reflect these changes.
* Remove Microsoft.<platform>.TargetFrameworkInference.targets, these files aren't
  used and don't contain anything useful.
* Move the logic to calculate _ComputedTargetFrameworkMoniker has been delayed
  to later, because it needs TargetFrameworkMoniker set.
2020-11-10 11:41:30 +01:00
Rolf Bjarne Kvinge c640775699 [dotnet] Bump to .NET 6.0.100-alpha.1.20556.2. and net6.0
New commits in spouliot/Touch.Unit:

* spouliot/Touch.Unit@f8768d9 Advance into the world of net6.0

Diff: 9abe69e6f5..f8768d99ef
2020-11-10 11:41:06 +01:00
Rolf Bjarne Kvinge 8b76cf4735
[dotnet] Fix MSBuild syntax. (#10055)
For some reason .NET 6 does not like spaces in certain places:

    MSB4259: Unexpected space at position "32" of condition [...]

So just remove them.
2020-11-06 14:01:19 +01:00
Rolf Bjarne Kvinge 06cd5722cc
[msbuild] Add SceneKit assets to our items included by default. (#10053) 2020-11-06 08:11:25 +01:00
Rolf Bjarne Kvinge 0def89604d
[msbuild] Add Metal files to our items included by default. (#10049) 2020-11-05 15:36:36 +01:00
Rolf Bjarne Kvinge 8aa53ba943
[dotnet] Add app extension targets to our list of stuff to do during the build. (#10044)
That makes app extensions build in dotnet.

This required adding a RuntimeIdentifier property to all the extension test
projects.
2020-11-05 08:34:29 +01:00
Rolf Bjarne Kvinge e7dd367125
[msbuild] Add CoreML models to our items included by default. (#10038) 2020-11-04 16:01:43 +01:00
juliuszint 3a1a7d4e77
Generate default compilation includes for pdf image assets. (#10018)
iOS and macOS have support to generate image assets for various
resolutions from vector based PDF files. These files should be included by
default for SDK-Style projects.

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2020-11-04 09:00:06 +01:00
Rolf Bjarne Kvinge 781bc851a5
[dotnet] Add atlas textures to the our items included by default. (#9995) 2020-11-04 08:40:16 +01:00
Rolf Bjarne Kvinge acf4038386
[dotnet] Don't try to include any results from the AOT compiler unless we're on a Mac. (#9989)
Because the AOT compiler won't execute unless we're on a Mac.

Also add a test.
2020-10-30 07:48:34 +01:00
Rolf Bjarne Kvinge 8f2913b518
[dotnet] Add asset catalogs to the our items included by default. (#9841) 2020-10-29 09:18:20 +01:00
Rolf Bjarne Kvinge ef91c798dc
[dotnet] Package the workloads in a Windows installer (.msi) as well. (#9979) 2020-10-28 11:09:55 +01:00
Rolf Bjarne Kvinge a141da12b5
Ship a LICENSE file with the workload. (#9978) 2020-10-27 22:46:59 +01:00
Rolf Bjarne Kvinge 3db0a33b90
[dotnet] Implement AOT compilation for mobile platforms (#9962)
* Add an AOTCompile task that runs the AOT compiler for a given set of input assemblies.
  This task will eventually be deprecated by an equivalent task provided by Mono,
  but this works for now.

* Add an _AOTCompile target that takes care of running the AOT compiler and compile
  the result into object files.
2020-10-27 15:16:34 +01:00
Rolf Bjarne Kvinge dce4c37fc6
[dotnet] Only fix the id of mono libraries which are actually dylibs. (#9944) 2020-10-23 09:12:49 +02:00
Rolf Bjarne Kvinge 673a378cbb
[msbuild] Add a TargetArchitectures argument to the LinkNativeCode task. (#9945)
The native linker defaults to the execution architecture, which works fine for
64-bit iOS Simulator (because we target x86_64 and run on x86_64), but it
doesn't work for any other architecture, so make sure to pass the architecture
to the native linker.

Also make sure we only get one architecture, because the native linker doesn't support
building fat libraries (we'll have to add support for manually lipoing the result).
2020-10-23 09:12:34 +02:00
Rolf Bjarne Kvinge b67b85817f
[dotnet] Don't try to update the location of the dynamic libraries when we didn't fix them. (#9936)
We're already not running part of the _UpdateDynamicLibraryId task when in
offline mode, so exclude the rest as well.

Fixes these build errors in offline mode:

    C:\Program Files\dotnet\sdk\5.0.100-rc.2.20480.7\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(237,5): error MSB3030: Could not copy the file "obj\Debug\net5.0-ios\ios-x64\nativelibraries/libSystem.Net.Security.Native.dylib" because it was not found. [C:\code\net6-samples\HelloiOS\HelloiOS.csproj]
    C:\Program Files\dotnet\sdk\5.0.100-rc.2.20480.7\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(237,5): error MSB3030: Could not copy the file "obj\Debug\net5.0-ios\ios-x64\nativelibraries/libSystem.IO.Compression.Native.dylib" because it was not found. [C:\code\net6-samples\HelloiOS\HelloiOS.csproj]
    C:\Program Files\dotnet\sdk\5.0.100-rc.2.20480.7\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(237,5): error MSB3030: Could not copy the file "obj\Debug\net5.0-ios\ios-x64\nativelibraries/libSystem.Security.Cryptography.Native.Apple.dylib" because it was not found. [C:\code\net6-samples\HelloiOS\HelloiOS.csproj]
    C:\Program Files\dotnet\sdk\5.0.100-rc.2.20480.7\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(237,5): error MSB3030: Could not copy the file "obj\Debug\net5.0-ios\ios-x64\nativelibraries/libmonosgen-2.0.dylib" because it was not found. [C:\code\net6-samples\HelloiOS\HelloiOS.csproj]
    C:\Program Files\dotnet\sdk\5.0.100-rc.2.20480.7\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(237,5): error MSB3030: Could not copy the file "obj\Debug\net5.0-ios\ios-x64\nativelibraries/libSystem.Native.dylib" because it was not found. [C:\code\net6-samples\HelloiOS\HelloiOS.csproj]
2020-10-21 14:10:57 +02:00
Rolf Bjarne Kvinge c0c91ed89f
[dotnet] Don't run the linker nor install_name_tool when running in offline mode on Windows. (#9910)
* [dotnet] Don't run the linker nor install_name_tool when running in offline mode on Windows.

When running in offline mode on Windows, we only want to compile the C# code
(to make sure it compiles). We do this by adding an '$(IsMacEnabled)' == 'true'
checks to code that we don't want to run in offline mode.

The linker fails like this, and the easiest fix is to just disable it:

    > dotnet build .\HelloiOS\HelloiOS.csproj -p:IsMacEnabled=false
    Microsoft (R) Build Engine version 16.8.0-preview-20475-05+aed5e7ed0 for .NET
    Copyright (C) Microsoft Corporation. All rights reserved.
      Determining projects to restore...
      Restored C:\src\net5-samples\HelloiOS\HelloiOS.csproj (in 6.28 sec).
      You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
      HelloiOS -> C:\src\net5-samples\HelloiOS\bin\Debug\net5.0-ios\ios-x64\HelloiOS.dll
    ILLink : error IL1012: IL Linker has encountered an unexpected error. Please report the issue at https://github.com/mono/linker/issues [C:\src\net5-samples\HelloiOS\HelloiOS.csproj]
      Fatal error in IL Linker
      Unhandled exception. System.DllNotFoundException: Unable to load DLL '/usr/lib/libSystem.dylib' or one of its dependencies: The specified module could not be found. (0x8007007E)
         at Xamarin.Bundler.Target.realpath(String path, IntPtr zero)
         at Xamarin.Bundler.Target.GetRealPath(String path)
         at Cache.set_Location(String value)
         at Xamarin.Linker.LinkerConfiguration..ctor(String linker_file)
         at Xamarin.Linker.LinkerConfiguration.GetInstance(LinkContext context)
         at Xamarin.Linker.ConfigurationAwareStep.get_Configuration()
         at Xamarin.SetupStep.Process()
         at Mono.Linker.Steps.BaseStep.Process(LinkContext context)
         at Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step)
         at Mono.Linker.Pipeline.Process(LinkContext context)
         at Mono.Linker.Driver.Run(ILogger customLogger)
         at Mono.Linker.Driver.Main(String[] args)

And disables install_name_tool too:

    > dotnet build .\HelloiOS\HelloiOS.csproj -p:IsMacEnabled=false -p:PublishTrimmed=false
    Xamarin.Shared.Sdk.targets(391,3): error MSB3073: The command "xcrun install_name_tool -id @executable_path/libSystem.IO.Compression.Native.dylib obj\Debug\net5.0-ios\ios-x64\nativelibraries/libSystem.IO.Compression.Native.dylib" exited with code 9009.

* Set PublishTrimmed after importing our existing Xamarin.iOS/Xamarin.Mac targets.

Because setting PublishTrimmed depends on knowing the value of IsMacEnabled,
which is set in our existing Xamarin.iOS/Xamarin.Mac targets.

Also remove the comment about having to set PublishTrimmed before including
Microsoft.NET.Sdk, because that's not accurate anymore (see
2939a6fdbc).
2020-10-20 16:25:49 +02:00
Rolf Bjarne Kvinge 0336815528 Fix typos in comments. 2020-10-19 10:38:11 +02:00
Rolf Bjarne Kvinge c6c3aa28fb [dotnet] There's no need to ship template files. 2020-10-16 14:27:57 +02:00
Rolf Bjarne Kvinge e9c61f1053 [dotnet] Make default items file templated to make it platform-specific.
The template takes each platform as input, and adds a TargetPlatformIdentifier condition
to the item groups.

This also means removing Xamarin.Shared.Sdk.DefaultItems.props, and put all the generated
logic into Microsoft.<platform>.Sdk.DefaultItems.props.

We can't use an identical default items file for all four platforms, because the
file is loaded once for each platform, and if the file is identical it means it'll
get repeated four times (and everything included by default will be included four
times, ending up with build errors).
2020-10-16 14:27:57 +02:00
Rolf Bjarne Kvinge b4141ebf60 [dotnet] Move the default inclusion to Xamarin.Shared.Sdk.DefaultItems.props. 2020-10-16 14:27:57 +02:00
Rolf Bjarne Kvinge 5623eeb106 [dotnet] Rename Microsoft.<platform>.Sdk.SupportedTargetPlatforms.props to Microsoft.<platform>.Sdk.SupportedTargetPlatforms.targets. 2020-10-16 14:27:57 +02:00