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

710 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge ea8ad15db0
[dotnet] Copy the pdb for our platform assemblies to the app bundle. Fixes #11879. (#18970)
Copy the pdb for our platform assembly to the app bundle if we're in
Debug mode.

Fixes https://github.com/xamarin/xamarin-macios/issues/11879.
2023-09-11 18:36:59 +02:00
Rolf Bjarne Kvinge de762d67cc
[dotnet] Point app extensions to any frameworks in the root app bundle. Fixes #17876. (#18913)
Put any frameworks in app extensions in the Frameworks directory in the
containing app bundle. This saves a lot of space if the same framework is used
in both an app extension and the containing project (or multiple app
extensions).

Fixes https://github.com/xamarin/xamarin-macios/issues/17876.
Fixes https://github.com/xamarin/xamarin-macios/issues/17679.
2023-09-11 09:52:54 +02:00
Rolf Bjarne Kvinge b44b57e59d
[dotnet] Make bundling the 'createdump' utility opt-in. Fixes #16189. (#18960)
Make bundling the 'createdump' utility opt-in by setting BundleCreateDump=true.

Fixes: https://github.com/xamarin/xamarin-macios/issues/16189
2023-09-11 09:52:14 +02:00
Rolf Bjarne Kvinge 45225dc88d
[dotnet] Parameterize the pack names. (#18732)
We're going to change the pack names to support multi-targeting, so ahead
of the pack name change I'm changing the existing logic to use a variable
for the pack name in most places (this will make the rename much easier and
simpler).

These changes should have no effect by themselves.
2023-08-29 10:06:46 +02:00
Rolf Bjarne Kvinge ed4d4ff028
[dotnet] Always pass -lobjc to the native linker. (#18845)
In some cases ld will crash otherwise:

    0  0x102a1871c  __assert_rtn + 140
    1  0x102a21688  ld::tool::SymbolTableAtom<arm64>::classicOrdinalForProxy(ld::Atom const*) (.cold.3) + 0
    2  0x10291daf8  ld::tool::SymbolTableAtom<arm64>::classicOrdinalForProxy(ld::Atom const*) + 248
    3  0x10291d15c  ld::tool::SymbolTableAtom<arm64>::addImport(ld::Atom const*, ld::tool::StringPoolAtom*) + 204
    4  0x10291c824  ld::tool::SymbolTableAtom<arm64>::encode() + 416
    5  0x102907b6c  ___ZN2ld4tool10OutputFile20buildLINKEDITContentERNS_8InternalE_block_invoke.387 + 36
    6  0x185df2874  _dispatch_call_block_and_release + 32
    7  0x185df4400  _dispatch_client_callout + 20
    8  0x185e060c8  _dispatch_root_queue_drain + 956
    9  0x185e066c0  _dispatch_worker_thread2 + 164
    10  0x185fa0038  _pthread_wqthread + 228
    A linker snapshot was created at:
    	/tmp/tesrt-2023-08-28-143541.ld-snapshot
    ld: Assertion failed: (it != _dylibToOrdinal.end()), function dylibToOrdinal, file OutputFile.cpp, line 5133.
2023-08-29 07:28:47 +02:00
dustin-wojciechowski 1b016fa072
[MacCatalyst] Added Default Entitlements for MacCatalyst projects (#18669)
Added default entitlements for MacCatalyst templates.
For Debug, the com.apple.security.get-task-allow entitlement that allows for using developer tools when developing MAUI Blazor apps.
For release, com.apple.security.app-sandbox is required to publish MacCatalyst apps to the Mac App Store.

Also added unit test to check for entitlements when project is created.

Fixes #18344

---------

Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2023-08-28 09:14:25 -07:00
Rolf Bjarne Kvinge 067e32a289
[dotnet] Update the Mac Catalyst VB template to match the C# template. (#18754) 2023-08-18 16:49:18 +02:00
Rolf Bjarne Kvinge d64f3d5e30
[dotnet] Fix typo when loading support for App Extensions on Mac Catalyst. (#18755)
Ref: https://github.com/xamarin/xamarin-macios/issues/17408
2023-08-18 16:48:51 +02:00
Rolf Bjarne Kvinge aa8d2a962e
[dotnet] Fix assembly stripping of resource assemblies. Fixes #17262. (#18749)
* Don't strip resource assemblies, there's no code in them to strip anyways.
* Use the relative path inside the app bundle when computing the intermediate
  location for stripped assemblies, so that if we were to find two identically
  named assemblies in different directories, they're handled correctly (by
  putting them in different intermediate locations, instead of overwriting
  eachother).

Fixes https://github.com/xamarin/xamarin-macios/issues/17262.
2023-08-17 07:34:14 +02:00
Mauro Agnoletti b313a59fbe
[remote] Explicitly import .mobile.props file (#18718)
The .mobile.props file is a file created and written by the mobile VS
extension to store property values that needs to be read early enough in
the build chain, as in design time builds, and that can't be set by CPS
because of a limitation in the project system. See more information
here: https://github.com/xamarin/XamarinVS/pull/13606

Initially it was named .user.env file and then was renamed in another PR
as part of a feedback from the project system team. See more information
here: https://github.com/xamarin/XamarinVS/pull/13628

Because this file was saved in the intermediate output path, it was
meant to be imported automatically by MSBuild, however we recently
detected that this was not happening reliably. Because of this, some
things like C# Hot Reload for iOS stopped working because Roslyn was
reading incorrect values from the Design Time Builds.

For that reason and to avoid relying on the project system, I'm
importing this file explicitly (and removing old .user.env import), so
the values in the file are always available and the dependent properties
are calculated correctly and available for all the consumers (including
Roslyn).

This should fix the following bugs:

https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1822041
https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1851677
2023-08-15 08:33:53 +02:00
Rolf Bjarne Kvinge 24895406b2
[dotnet] Link Mono and Xamarin statically in Mac Catalyst by default. Fixes #14686. (#18619)
It's possible to create a provisioning profile for Mac Catalyst that
doesn't allow dylibs in the app. It seems a significant number of people run
into this problem when publishing their apps, so avoid it by linking Mono and
Xamarin statically by default instead.

The downside is that build time might increase a little bit.

An upside however is that the app size might decrease somewhat.

Fixes https://github.com/xamarin/xamarin-macios/issues/14686.
2023-08-11 15:08:27 +02:00
Rolf Bjarne Kvinge b17626ff1c
[msbuild] Re-aot referencing assemblies. Fixes #17708. (#18509)
If an assembly changes, then we must AOT compile that assembly again (which we already
did), in addition to any assembly that references the modified assembly (which we
didn't do).

So rework the AOTCompile target: remove the Inputs and Outputs (because the dependency
tracking is too complicated for MSBuild to resolve), and instead move the logic to
detect if an assembly must be AOT-compiled again into the AOTCompile task.

Note that this PR has a custom port to .NET 8: #18518.

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

---------

Co-authored-by: Alex Soto <alex@alexsoto.me>
2023-08-07 20:19:30 +02:00
Meri Khamoyan 3f6d43c756
[iOS] HybridGlobalization set flag in SDK (#18498)
Add HybridGlobalization flag in SDK and load icudt_hybrid.dat file when
HybridGlobalization is on.

Contributes to https://github.com/dotnet/runtime/issues/80689
2023-06-28 10:25:24 +02:00
Rolf Bjarne Kvinge 2761123a6b
[dotnet] Add a property to opt-out of the _CopyLocalBindingResources logic easily. (#18443)
It seems this target has more problems than at first I thought, so make
it easier to opt-out of it by just setting a property in the csproj.

More investigation is needed, but I'm keeping the target on by default
for now, since it solves a real-world problem as well.

Ref: https://github.com/xamarin/xamarin-macios/issues/18445
2023-06-15 09:54:22 +02:00
Rolf Bjarne Kvinge 7df3eb1520
[dotnet] Add targets to compute mlaunch arguments for installing and launching mobile apps. Fixes #18359. (#18446)
Add public targets to compute the mlaunch command lines for installing
and launching mobile apps.

These new targets are:

* ComputeMlaunchInstallArguments
* ComputeMlaunchRunArguments

As part of this change, also create a few new public properties:

* MlaunchPath
* MlaunchRunArguments
* MlaunchInstallArguments
* MlaunchRunScript
* MlaunchInstallScript

If the *Script variables are set, the corresponding target will create a
script file with the path to mlaunch + the corresponding arguments.

Otherwise, it's also possible to get the arguments directly from the
build log.

Fixes https://github.com/xamarin/xamarin-macios/issues/18359.
2023-06-15 07:21:09 +02:00
Ivan Povazan e3088879a6
Reduce the size of `__LINKEDIT Export Info` section in stripped binaries (#18408)
# Description

This PR reduces the application's SOD (size on disk) by making
`__LINKEDIT Export Info` section smaller in the stripped Mach-O
binaries.

The feature is controlled by `_ExportSymbolsExplicitly` MSBuild property
and can be disabled by specifying: `-p:_ExportSymbolsExplicitly=true`

Fixes #18332 

# Initial problem

It has been noticed that during stripping, the strip tool does not
resize the export info section after it removes the symbols. Instead it
only zeroes out the entries (achieved by calling `prune_trie` function):

- https://github.com/apple-oss-distributions/cctools/blob/cctools-986/misc/strip.c
- https://github.com/apple-oss-distributions/ld64/blob/ld64-711/src/other/PruneTrie.cpp

Thanks @lambdageek for helping to track this down.

# Approach

As Xamarin build process already collects all the [required symbols][1] needed
for the application to run and preserves them during the strip phase, we can
use the same file to instruct clang toolchain to export only those symbols via
the command line options: `-exported_symbols_list <file>` ([source][2]).

This will make the export info section only include what is necessary for the
runtime - and at the same time eliminate the problem of the `strip` tool which
does not resize stripped symbols.

# Investigation setup

The issue is observable by building and inspecting the test application:
https://github.com/xamarin/xamarin-macios/blob/main/tests/dotnet/MySingleView/MySingleView.csproj
and targeting iOS platform in Release mode.

## Results:

| Measure      | MySingleView - main | MySingleView - this PR | Diff (%) | 
| :---         |                ---: |                   ---: |     ---: |
| SOD (bytes)  |            13668940 |               13458476 |    -1.5% |
| .ipa (bytes) |             4829368 |                4827928 |   -0.03% |

Even though zeroes are compressed well, the SOD is still affected and
unused section takes around 1.5% of the most simplistic app size.
Much bigger impact has been noted when trying out a MAUI iOS template
app with NativeAOT where the `__LINKEDIT Export Info` zeroes take up to
20MB of the SOD, but also with the regular macOS applications:
https://github.com/dotnet/runtime/issues/86707

### Repro current state of MySingleView.app with stripped binary

1. Build the app (you can ignore the need to run the sample, I just did it to
   make sure the changes do not break anything)

```bash
make run-device
``` 

2. Print the load commands - [load_cmds_strip.list][3]

```bash
otool -l bin/Release/net7.0-ios/ios-arm64/MySingleView.app/MySingleView > load_cmds_strip.list
```

- We are interested in the export info section:

```
cmd LC_DYLD_INFO_ONLY
...
export_off 5942960
export_size 207712
```

3. Create a hex dump of the export info section - [hex_dump_strip.list][4]

``` bash
xxd -s 5942960 -l 207712 bin/Release/net7.0-ios/ios-arm64/MySingleView.app/MySingleView > hex_dump_strip.list
```

- NOTE: Notice around ~200kb of zeroes from ~0x005ab490 to ~0x005dda00
    
4. Verify exported symbols are correct - [dyld_info_strip.list][5]

``` bash
dyld_info -exports bin/Release/net7.0-ios/ios-arm64/MySingleView.app/MySingleView > dyld_info_strip.list
```

### Repro current state of MySingleView.app with unstripped binary

1. Build the app (the make target preserves the symbols)

```bash
make run-device-no-strip
``` 

2. Print the load commands - [load_cmds_nostrip.list][6]

```bash
otool -l bin/Release/net7.0-ios/ios-arm64/MySingleView.app/MySingleView > load_cmds_nostrip.list
```

- We are interested in the export info section:

```
cmd LC_DYLD_INFO_ONLY
...
export_off 5942960
export_size 207712
```

3. Create a hex dump of the export info section - [hex_dump_nostrip.list][7]

``` bash
xxd -s 5942960 -l 207712 bin/Release/net7.0-ios/ios-arm64/MySingleView.app/MySingleView > hex_dump_nostrip.list
```

- Notice that the range: ~ 0x005ab490 to ~ 0x005dda00 now includes exported symbol entries
    
4. Verify exported symbols are correct - [dyld_info_nostrip.list][8]

``` bash
dyld_info -exports bin/Release/net7.0-ios/ios-arm64/MySingleView.app/MySingleView > dyld_info_nostrip.list
```

### Repro the new approach 

1. Build the app (the make target uses the new approach)

```bash
make run-device-export-syms
``` 

2. Print the load commands - [load_cmds_export.list][9]

```bash
otool -l bin/Release/net7.0-ios/ios-arm64/MySingleView.app/MySingleView > load_cmds_export.list
```

- We are interested in the export info section ***notice the reduced size of the section***:

```
cmd LC_DYLD_INFO_ONLY
...
export_off 5942432
export_size 1048
```

3. Create a hex dump of the export info section - [hex_dump_export.list][10]

``` bash
xxd -s 5942432 -l 1048 bin/Release/net7.0-ios/ios-arm64/MySingleView.app/MySingleView > hex_dump_export.list
```
    
4. Verify exported symbols are correct - [dyld_info_export.list][11]

``` bash
dyld_info -exports bin/Release/net7.0-ios/ios-arm64/MySingleView.app/MySingleView > dyld_info_export.list
```

---

## Additional benefits

With this approach we could also switch the way strip tool is invoked to
always strip all debug and local symbols via `strip -S -x` instead of passing
the file with symbols to preserve. This would remove the warning that we are
currently getting (which is being ignored):

```
/Applications/Xcode_14.3.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip: warning: removing global symbols from a final linked no longer supported.  Use -exported_symbols_list at link time when building...
```

## Other references:

- https://github.com/qyang-nj/llios/blob/main/exported_symbol/README.md

[1]: 11e7883da0/tools/dotnet-linker/Steps/GenerateReferencesStep.cs (L38-L44)
[2]: https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html
[3]: https://gist.github.com/ivanpovazan/d53f8d10be5e4ea9f39a41ea540aa7fa
[4]: https://gist.github.com/ivanpovazan/60637422f3ff8cb5f437ddd06a21d9c1
[5]: https://gist.github.com/ivanpovazan/352595ad15c2ac02f38dcb3bd4130642
[6]: https://gist.github.com/ivanpovazan/bf700161f2f3691d1d7381c98d4fa0be
[7]: https://gist.github.com/ivanpovazan/44269e4fff5ebd58a4d181451e5c106f
[8]: https://gist.github.com/ivanpovazan/38c5afe076502d514a77420af0e10b01
[9]: https://gist.github.com/ivanpovazan/3f663c3c630005f5a578605d48ba807e
[10]: https://gist.github.com/ivanpovazan/0bb84f64281d05ab20438aeaed64f13c
[11]: https://gist.github.com/ivanpovazan/78b3ba2288f53a2316b9bc46964e7e4f

---------

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2023-06-12 13:45:38 +02:00
VS MobileTools Engineering Service 2 1527450920
[dotnet] Set _RequiresILLinkPack=true so that we always restore the ILLink package. (#18412)
This property will be required when building for a net7.0-* target framework
using .NET 8 (preview 6 - preview 5 does not need this fix)

Backport of #18411
2023-06-07 08:48:42 +02:00
Haritha Mohan 4bbd7df8f5
[dotnet] Enable runtime identifiers to be overriden at build time (#18396)
Fixes #17707
The error target for when there is a conflict of interest in defining
both the runtime identifier and runtime identifiers is called during the
multi-rid builds, but not sure if the placement is the most ideal..

---------

Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Co-authored-by: Alex Soto <alex@alexsoto.me>
2023-06-06 13:49:29 -07:00
Rolf Bjarne Kvinge 3e13f66948
[dotnet] Add support for asking more of 'open' when launching desktop apps. (#18366)
* Add support for forwarding our debugging msbuild properties to their
  corresponding environment variables (the XamarinDebug* properties).
* Add support for passing --stdout/--stderr/--stdin to open to redirect
  to/from a file. This is particularly useful for debugging debugging.
* Add support for passing -a (to always create a new instance of the app).
  This is useful when debugging (when the developer would always want a new
  instance, instead of opening an existing instance).
* Also add support for any other argument using the 'OpenArguments' property.

Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1825427.
2023-05-30 17:55:31 +02:00
Rolf Bjarne Kvinge 95f6c356d0
[msbuild] Make the GetFileSystemEntries task capable of copying files to the Mac. (#18324)
Make the GetFileSystemEntries task capable of copying files to the Mac, and
enable this new behavior when inspecting references for binding resources.

Otherwise the task might not find anything, if the files aren't copied to the
Mac (this happens if the files originate from NuGets instead of referenced
projects).

Ref:

* https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1808448 (third attempt)
* https://github.com/xamarin/xamarin-macios/issues/18308
* https://github.com/dotnet/maui/issues/15042
2023-05-25 16:34:04 +02:00
VS MobileTools Engineering Service 2 a054c52d54
Localized file check-in by OneLocBuild Task: Build definition ID 17751: Build ID 7800490 (#18306)
This is the pull request automatically created by the OneLocBuild task
in the build process to check-in localized files generated based upon
translation source files (.lcl files) handed-back from the downstream
localization pipeline. If there are issues in translations, visit
https://aka.ms/icxLocBug and log bugs for fixes. The OneLocBuild wiki is
https://aka.ms/onelocbuild and the localization process in general is
documented at https://aka.ms/AllAboutLoc.
2023-05-23 08:26:52 +02:00
Rolf Bjarne Kvinge 0bc12c8def
Add a managed static registrar. Fixes #17324. (#18268)
Add a new version of the static registrar (called the managed static
registrar), which most notably doesn't use metadata tokens (because NativeAOT
doesn't support metadata tokens). In addition, the new registrar also takes
advantage of new features in both C# and the runtime, in order to be more
performant.

I won't go into detail about everything here, because it would be rather long,
but I've added documentation for the new registrar (the first commit, so start
reviewing there).

Fixes https://github.com/xamarin/xamarin-macios/issues/17324.
2023-05-19 07:30:33 +02:00
Rolf Bjarne Kvinge edd0bc48f2
[msbuild] Fix calling the GetFileSystemEntries task on Windows when not connected to a Mac. (#18287)
Given the following truths:

* A task will (try to) connect to a Mac if its SessionId property isn't empty.
* The BuildSessionId property is always set on Windows when building from an IDE (even if not connected to a remote Mac).

It stands to reason that we can't use BuildSessionId to distinguish between
connected/not conected status on Windows. Instead introduce a new property,
BuildSessionIdIfConnected, which is only set if connected to a Mac (i.e. if
'IsMacEnabled=true').

Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1808448 (second attempt).
2023-05-18 18:21:21 +02:00
Rolf Bjarne Kvinge 65590ba8c0 Merge remote-tracking branch 'origin/main' into msr 2023-05-18 15:19:39 +02:00
Emanuel Fernandez Dell'Oca aec2af30ce
[dotnet] Stop looking for the AOT compiler if cached (#18286)
The AOT compiler does not exist on Windows, so this check was making the
cache never work there. We don't really need to check if the compiler
does still exist, since the cache can be deleted by rebuilding the
project if anything fails.
2023-05-17 14:06:10 +02:00
Rolf Bjarne Kvinge bf639a99d7 [dotnet-linker] Add the scaffolding for a ManagedRegistrarStep and a ManagedRegistrarLookupTablesStep. 2023-05-11 12:21:53 +02:00
Rolf Bjarne Kvinge 34264cd98f [dotnet] Add an 'IsManagedStaticRegistrar' feature to the linker.
This way we can ask the linker to inline the Runtime.IsManagedStaticRegistrar property, and remove any dead code paths.
2023-05-11 12:21:53 +02:00
TJ Lambert a54fefd836
[Localization] Revert change to non-breaking space (#18216)
This change didn't really get rid of the non-breaking space and caused
extra changes after we built xamarin-macios.

Co-authored-by: tj-devel709 <tjlambert@microsoft.com>
2023-05-04 21:59:37 -05:00
VS MobileTools Engineering Service 2 9b7b3360da
Localized file check-in by OneLocBuild Task: Build definition ID 17751: Build ID 7704520 (#18191)
This is the pull request automatically created by the OneLocBuild task
in the build process to check-in localized files generated based upon
translation source files (.lcl files) handed-back from the downstream
localization pipeline. If there are issues in translations, visit
https://aka.ms/icxLocBug and log bugs for fixes. The OneLocBuild wiki is
https://aka.ms/onelocbuild and the localization process in general is
documented at https://aka.ms/AllAboutLoc.
2023-05-03 12:32:16 -05:00
Filip Navara abd9883af6
Fix the name of the item function. (#18199)
The name is `HasMetadata`, not `HasMetadataValue`
(https://learn.microsoft.com/en-us/visualstudio/msbuild/item-functions?view=vs-2022).
2023-05-03 16:48:36 +02:00
Rolf Bjarne Kvinge 6e7128b619
[msbuild/tests/dotnet] Add support for xcframeworks for Hot Restart and add tests. Fixes #16571. (#18103)
Rework Hot Restart builds to use as much as possible of the normal build
logic, because this is the easiest way to make sure the Hot Restart build is
as close as possible to normal builds (and we don't end up missing features).

This is done by executing selected parts of a normal build, and at the end we
have a new task that computes where each file goes in the various output
directories Hot Restart uses (HotRestartAppBundlePath, HotRestartContentDir,
HotRestartAppContentDir, etc.)

This PR also:

* Adds a test that runs on Windows and verifies that everything consumed in a
  build is placed in the correct location for a Hot Restart build (this is a
  variation of the BundleStructure test we already have).
* Removes tasks that aren't used anymore.
* Misc fixes to make sure existing code works on Windows.

---

This PR is best reviewed commit-by-commit.

Ref: https://github.com/xamarin/xamarin-macios/issues/13924

* Fixes https://github.com/xamarin/xamarin-macios/issues/16571
* Fixes https://github.com/xamarin/xamarin-macios/issues/16001
* Fixes https://github.com/xamarin/xamarin-macios/issues/10784
* Fixes https://github.com/xamarin/xamarin-macios/issues/17579
* Contributes towards https://github.com/xamarin/xamarin-macios/issues/13924.
2023-05-03 14:09:31 +02:00
Rolf Bjarne Kvinge 4a05d47f2e
[dotnet] Add a missing IsMacEnabled check before executing a task in the _ComputeLinkerArguments target. (#18145)
This fixes an issue where the build would fail on Windows if the Windows
machine wasn't connected to a remote Mac.

Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1808448.
2023-04-26 15:23:29 +02:00
Rolf Bjarne Kvinge fcbbd2992e [msbuild] Set/fix the PublishFolderType and RelativePath metadata in several places.
Set/fix the PublishFolderType and RelativePath metata for returned items in the ComputeBundleLocation
and ResolveNativeReferences task, so that the new ComputeHotRestartBundleContents
task has enough (and the correct) information to do the right thing with items that
are to be copied to the app bundle.
2023-04-20 18:21:17 +02:00
Rolf Bjarne Kvinge f17bc64d1b [msbuild/dotnet] Rework Hot Restart builds.
Rework Hot Restart builds to use as much as possible of the normal build logic, because
this is the easiest way to make sure the Hot Restart build is as close as possible
to normal builds (and we don't end up missing features).

This is done by executing selected parts of a normal build, and a the end we have
a new task that computes where each file goes in the various output directories Hot
Restart uses (HotRestartAppBundlePath, HotRestartContentDir, HotRestartAppContentDir,
etc.)
2023-04-20 18:21:17 +02:00
Rolf Bjarne Kvinge 9615de3334
[dotnet] Include the parsed runtimeconfig.bin into ResolvedFileToPublish. Contributes towards #17579. (#18087)
This makes it unnecessary to special-case this file for it to copied
correctly when building on Windows (once we've fixed the Windows build to use
ResolvedFileToPublish as the source of truth, like we do on macOS).

This is the first part of a fix for
https://github.com/xamarin/xamarin-macios/issues/17579.
2023-04-19 07:32:13 +02:00
Rolf Bjarne Kvinge 4dbd98b78f
[linker/trimmer] Add opt-in support for not marking NSObjects in user assemblies. Fixes #15723. (#17949)
We mark all types that derive from NSObject when we find them in user
assemblies, so that these types may be used in storyboards (where the linker
can't see them), without having to go through hoops to make sure the linker
doesn't remove these types (which would make the storyboard fail to load,
because it would reference types that were linked away).

However, not everybody uses storyboards, so in some cases it may make sense to
link away as much as possible, so make it opt-in to skip this custom marking.

This is an experimental feature, and will break at least some apps. It may
break most apps, but if someone wants to try it out, they're welcome!

It can be turned on by passing `--skip-marking-nsobjects-in-user-assemblies=true` to mtouch/mmp:

```xml
<PropertyGroup>
    <MtouchExtraArgs>--skip-marking-nsobjects-in-user-assemblies=true</MtouchExtraArgs>
</PropertyGroup>
```

Fixes #15723.
2023-04-13 16:38:04 +02:00
Rolf Bjarne Kvinge a09d0dc38a
[msbuild] Use our own Unzip task instead of Ditto when extracting compressed plugins. (#18015)
This way we can make the extraction work on Windows for Hot Restart, since ditto
doesn't exist on Windows.

This requires a few other changes:

* Move the Unzip task from the HotRestart tasks to be available everywhere.
* Change the Unzip task to use our existing decompression logic, which calls 'unzip'
  on non-Windows platforms in order to correctly support symlinks.
2023-04-13 16:36:24 +02:00
Rolf Bjarne Kvinge efc7551e3f
[runtime] Add support for passing on a connect timeout to sdb. (#18037)
The timeout can be given:

* By setting the __XAMARIN_DEBUG_CONNECT_TIMEOUT__ environment variable for the app when launching it.
* By passing the XamarinDebugConnectTimeout MSBuild property to 'dotnet run' or 'dotnet build /t:Run'.
* By setting the IOSDebugConnectTimeout MSBuild property at build time.

Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1778177.
2023-04-13 16:34:52 +02:00
Rolf Bjarne Kvinge 7973dcef1b
[localization] Fix BOMs. (#18027) 2023-04-12 14:01:18 +02:00
VS MobileTools Engineering Service 2 ada4d2cb31
Localized file check-in by OneLocBuild Task: Build definition ID 17751: Build ID 7603393 (#18005)
This is the pull request automatically created by the OneLocBuild task
in the build process to check-in localized files generated based upon
translation source files (.lcl files) handed-back from the downstream
localization pipeline. If there are issues in translations, visit
https://aka.ms/ceLocBug and log bugs for fixes. The OneLocBuild wiki is
https://aka.ms/onelocbuild and the localization process in general is
documented at https://aka.ms/AllAboutLoc.
2023-04-10 08:23:00 -05:00
Rolf Bjarne Kvinge 8c9ee8289f
[msbuild/dotnet] Rework how we collect and process native references. (#17554)
Previously, we'd do this:

* Collect all possible native references.
* Extract any compressed native references (*.framework.zip, *.xcframework.zip,
  *.resources.zip) to disk.
* Resolve the resulting native references.

This doesn't work very well on Windows (in non-connected/Hot Restart mode),
because some compressed files may contain symlinks (in particular compressed
xcframeworks). If those symlinks are for any other platform than the one we're
building for, they shouldn't matter, but if we extract the entire compressed
xcframework before figuring out what we need from it, we'd run into symlinks
and not knowing whether they should be ignored or not.

So rework the process to:

* Collect all possible native references.
* Resolve the resulting native references, peeking into zip files if need be.
* Extract any compressed native references, but only the parts of the zip we need.

This way we won't run into any symlinks unless we really need them, and it
should also improve build performance slightly, even on macOS, since we're not
extracting files we won't need (which can be significant for xcframeworks).

Additionally:

* Add support for unzipping on Windows by using System.IO.Compression.
* Show an error if attempting to extract a symlink in the last step in the
  reworked process on Windows.
* Some tests had to be updated (since they poked into internals of the
  ResolveNativeReferences task, and those internals have changed).
2023-04-10 11:27:41 +02:00
Emanuel Fernandez Dell'Oca b7a486a887
[msbuild] Get RecursiveDir directory name only if it isn't empty (#17988)
If the `RecursiveDir` metadata is empty, the GetDirectoryName method
throws an error because it isn't a valid path. This can happen on VS
design time builds.
2023-04-06 17:21:26 -04:00
Rolf Bjarne Kvinge 335f8c9d90
[dotnet/msbuild] Don't bundle *.xml files that match any assemblies. Fixes #14939 and fixes #15897. (#17908)
This fixes a warning when documentation is enabled for a project:

> The file '~/.nuget/packages/fsharp.core/6.0.0/contentFiles/any/netstandard2.1/FSharp.Core.xml' does not specify a 'PublishFolderType' metadata, and a default value could not be calculated. The file will not be copied to the app bundle.

This doesn't change any behavior (as the warning says, the file wasn't copied
to the app bundle before either), but it makes the behavior explicitly
documented and silences the warning.

Fixes https://github.com/xamarin/xamarin-macios/issues/14939.
Fixes https://github.com/xamarin/xamarin-macios/issues/15897.
2023-03-30 07:24:00 +02:00
dustin-wojciechowski 60b0724b4d
[Templates] Add comments to help developers publish MacCatalyst apps on App Store (#17830)
Added some information to the MacCatalyst templates based on comments from the community
on how to publish MacCatalyst apps on the App Store.

Fixes #17591
2023-03-23 20:21:08 -07:00
Haritha Mohan 3dff232920
[dotnet] Enable generation of runtime configuration file (#17840)
Set the GenerateRuntimeConfigurationFiles (GRCF) property to true 
to avoid warnings at build time + add test for change.

Diving deeper into the fix...
- This warning only occurs with .NET apps which is why GRCF
is only updated in the dotnet directory and not msbuild (legacy)
- After examining the binlog (see issue), it was found that the GRCF 
was contingent upon the HasRuntimeOutput property, which is only 
defined for executable projects. And in this case, the user's project
output type is library thus both the RuntimeOutput and consequently 
GRCF properties were not enabled.
- By setting the GRCF to true we can address the original warning of 
concern while ensuring the rest of the projects's behavior is not
altered
in mysterious ways (i.e. by touching the RuntimeOutput property or the 
project output type instead, these changes could have extraneous
effects).

Fixes #17543

---------

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2023-03-23 08:10:04 -07:00
Peter Collins 432d27b171
[vs-workload] Update VS Component versions (#17883)
Context: https://github.com/xamarin/sdk-insertions/issues/56

Updates the VS component version for all workloads to use the NuGet
versions commit distance as the third version part.
2023-03-23 08:22:42 +01:00
Rolf Bjarne Kvinge 8ac36f126e
[dotnet] Add support for setting an MSBuild property to pass additional mlaunch arguments. (#17866)
This is helpful when doing a command-line -t:Run build, because it's not
possible to set an item group from the command line.
2023-03-22 16:19:49 +01:00
Rolf Bjarne Kvinge 7ea0044224
[dotnet/msbuild] Copy binding resource packages to output directories together with CopyLocal assemblies. Fixes #13910. (#17806)
With a project structure like this:

* Executable project references a library project.
* The library project references a binding project (or assembly).

The binding project's assembly will be copied to the library project's
output directory during the build. Unless we also make sure any binding
resource packages are copied as well, the executable project won't find those,
and the final app won't contain any native bits from the binding project.

The solution is to add any binding resource packages to the list of
files to be copied to the library's output directory.

Fixes https://github.com/xamarin/xamarin-macios/issues/13910.
2023-03-22 10:49:26 +01:00
Peter Collins 289ded90fe
[vs-workload] Remove @(MultiTargetPackNames) (#17838)
Context: https://github.com/xamarin/yaml-templates/pull/251

The VS manifest files generated during MSI conversion will now be split
up using the workload pack type rather than a substring match.
2023-03-20 15:36:44 -04:00
Rolf Bjarne Kvinge 256ef1ccd9
[dotnet] Change _IntermediateDecompressionDir to always have a trailing directory separator. (#17728)
Also don't hardcode the trailing directory separator as a forward slash,
because we might be executing on Windows (which is the real purpose behind
this change).
2023-03-07 18:58:25 +01:00