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

1475 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge 21b220680f
[msbuild] Limit the number of concurrent AOT compilers to the number of processors. (#18793)
This might fix #17825, but even if it doesn't, it's a good thing to do
to not overload machines.

Ref: https://github.com/xamarin/xamarin-macios/issues/17825
2023-08-25 07:33:32 +02:00
Rolf Bjarne Kvinge 61493dd438
[msbuild] Store the command line to sign in the stamp file. Fixes #16124. (#18750)
When figuring out whether something needs to be (re)signed or not, we must
also take into account that the signing identity may have changed (for
instance a release build will often have a different signing identity than a
debug build).

Do this by storing the command line to sign for each item we need to sign in
the stamp file, and if the stored contents don't match the new command line
to sign, then we must resign the item.

This is rather obnoxious to write unit tests for (since we'd need to have two
different signing identities available on the bots), so I've only done local
testing.

Fixes https://github.com/xamarin/xamarin-macios/issues/16124.
2023-08-22 12:34:16 +02:00
Rolf Bjarne Kvinge 587f722283
[msbuild] Pass a stream to XDocument.Load instead of a path. (#18722)
XDocument.Load(string) takes a URI, not a file path. This usually works if
there are no special characters in the file path, but for instance with a path
with a colon (say 'a:b/some/file'), we'll get an exception about invalid uri
scheme.

So instead use the XDocument.Load(Stream) overload, and create the stream
using the file path instead, in which case there's no problem with special
characters.
2023-08-15 18:22:34 +02:00
Rolf Bjarne Kvinge 092e2ba28f
[msbuild] Don't try to run 'dotnet build' if 'dotnet restore' failed in the XamarinBuild task. (#18620)
This avoids throwing spurious exceptions when we blinding keep executing
stuff that doesn't make sense anymore.
2023-08-09 10:18:22 +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
Manuel de la Pena 6b1f9699ac
Localized file check-in by OneLocBuild Task: Build definition ID 17751: Build ID 8130882 (#18574)
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-07-28 16:31:58 -04:00
Mauro Agnoletti 403d01749f
[dotnet][xma] Ensure we don't use DOTNET_ROOT and DOTNET_HOST_PATH in… (#18567)
… the Build Agent and remote tasks

DOTNET_ROOT and DOTNET_HOST_PATH are being deprecated as a mechanism to
store the location of dotnet. PATH will be used instead, so we should
ensure that the existing code that makes usage of these variables is
adapted to the new guidelines. More information:


f454d6960e

https://github.com/dotnet/runtime/issues/88754#issuecomment-1632957579

Additionally, to avoid confusion, we are using a dedicate
DOTNET_CUSTOM_PATH variable with the path of the dotnet used by the XMA
Build Agent, so it can be used internally by the tasks without mixing it
with the existing dotnet variables

---------

Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
2023-07-26 20:01:42 -04:00
VS MobileTools Engineering Service 2 8d875fd3e9 Localized file check-in by OneLocBuild Task: Build definition ID 17751: Build ID 8130882 2023-07-23 05:05:23 -07:00
Emanuel Fernandez Dell'Oca e7b7d168ec
[msbuild] Fix null check when validating Hot Restart app identifier (#18546)
The detection of signing identities should fail if we could not build a
valid app id. This code originally checked for null (`AppId == null`)
and was replaced by `is not null` as part of
36af029204 (diff-ff4502eb16b65dc59bb7de2bf980024260e83d7b97fef727c9c033374f2b3533R106).
2023-07-10 18:36:37 -04:00
Manuel de la Pena 72865626fe
[Policheck] Fix all policheck issues that are not part of the apple APIs. (#18544) 2023-07-10 14:38:21 -04:00
Emanuel Fernandez Dell'Oca 0ccfc4b506
Bump Xamarin.Messaging to 1.11.2 (#18521) 2023-06-30 10:31:50 +02:00
Rolf Bjarne Kvinge c7fa7ab52e
[msbuild] Fix ILStripping of resource assemblies on Windows. (#18508)
Any assembly that's not already on the Mac must be copied there, so do that.
We detect if an assembly exist on the Mac by checking the file size of the
file on Windows: a 0-length file is an output file from an assembly that exist
on the Mac, otherwise it doesn't and must be copied.

Fixes https://github.com/xamarin/xamarin-macios/issues/17009.
Fixes https://github.com/xamarin/xamarin-macios/issues/14841.
Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1817898.
2023-06-29 11:04:42 +02:00
Rolf Bjarne Kvinge 7f910487f5
[msbuild/dotnet] Handle dylibs that don't start with 'lib' better. Fixes #15044. (#18496)
For a given dylib named '/path/to/libMyLibrary.dylib', we pass this to the native linker:

    -L/path/to -lMyLibrary

however, that doesn't work unless the dylib's name starts with 'lib'.

So detect this, and if the dylib doesn't start with 'lib' (say it's just
'MyLibrary.dylib'), then just pass the path to the dylib as-is to the native
linker:

	/path/to/MyLibrary.dylib

Fixes https://github.com/xamarin/xamarin-macios/issues/15044.
2023-06-27 07:55:04 +02:00
Rolf Bjarne Kvinge a8ba9c402c
[msbuild/generator] Compile api definitions in MSBuild logic instead of inside the generator. (#18398#pullrequestreview-1498787955)
This has a few advantages:

* A step towards simplifying the generator.
* A step towards being able to build binding projects on Windows, since it's easier
  to build C# code in MSBuild using the Csc task rather than figuring out how to
  call csc as an external program (which we've already done on macOS, but having
  a single solution that works on all platforms is preferrable).

Note that this is only implemented for .NET, doing this for legacy Xamarin required a lot more work.
2023-06-26 17:29:12 +02:00
Steve Hawley a36cd71174
[dotnet] Integrate class handle rewriting into static registrar process. (#18456)
Integrate class handle rewriting into static registrar.
2023-06-23 10:12:35 -04:00
Rolf Bjarne Kvinge aec6925d18
[msbuild] Print the binlog if the prebuilt app failed to build. (#18474)
This makes it easy to copy-paste the path to the binlog to open it in a
binlog viewer.
2023-06-22 08:16:12 +02:00
Rolf Bjarne Kvinge ce85073609
[msbuild] Remove some logic for watchOS on .NET. (#18473)
We don't support watchOS on .NET, so this is just useless code.
2023-06-22 08:15:56 +02:00
Rolf Bjarne Kvinge 4c51cfa8bb
[msbuild] Copy the zip file back to Windows from the Zip task for remote builds. Fixes #18402. (#18447)
The zip file might be used later directly on Windows (for instance it
might be embedded inside a binding assembly as an embedded resource), so make
sure to copy it back to Windows.

Fixes https://github.com/xamarin/xamarin-macios/issues/18402 part 2.
2023-06-15 16:32:34 +02:00
Rolf Bjarne Kvinge 707a2db3e1
[msbuild] Make sure to copy the manifest from a binding resource package back to Windows. Fixes #18402. (#18419)
This fixes a build problem on windows when a project has a project reference
to a binding project. The binding resource package from the binding project
would lack the manifest, and thus the main project wouldn't detect it as a
binding resource package, effectively not seeing any native resource from the
binding project.

Fixes https://github.com/xamarin/xamarin-macios/issues/18402.
2023-06-08 16:51:29 +02:00
Rolf Bjarne Kvinge 50c5ae57f2
[msbuild] Dispose a few streams when done with them in the unzip/decompress logic. (#18410)
Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1829715.
2023-06-08 16:51:10 +02:00
James Parsons 3feddf30eb
Update Messaging and System.Diagnostics.Tracer versions (#18416)
We need to update the `System.Diagnostics.Tracer` package to version
`2.1.0-alpha` due to an issue with the `ChecksumAlgorithm` property of
older versions.

Cherry-pick: https://github.com/xamarin/xamarin-macios/pull/18310
2023-06-07 12:55:27 +02:00
Rolf Bjarne Kvinge 9e2143032f
Use Enum.GetValues<T> instead of Enum.GetValues in numerous places for .NET. (#18382)
NativeAOT warns about Enum.GetValues and suggests using Enum.GetValues<T>
instead, so do just that.
2023-06-07 08:47:55 +02:00
Mauro Agnoletti 495ebc9ffd
[main] Hot Restart fixes (#18317)
- Update Hot Restart client to 1.0.119: bring latest isignsharp fix 71220d490a

- Added missing app markers back:
    - Added .stamp files to make incremental deployments work again and to avoid re-installing the application. We use .stamp files to know which files to copy on incremental deployments and also to avoid unnecessary app installations
    - Added .hotrestartapp file back to identify the main app entry point. We need this since the main entry point to dynamically load the app might change between Forms and MAUI (could be a .dll or an .exe), so we need a way to let the Hot Restart app to know which is the main assembly to load
    
- Fixed outputs in _CodesignHotRestartAppBundle target: the codesign was being executed always, causing the incremental builds to not work as expected.

- Ensure the _CodesignHotRestartAppBundle target is executed before the copy of the content files and not after: Hot Restart content files doesn't affect the code signing, so they don't need to be copied before the signing process. Copying the content files before the code sign was causing unwanted behaviors and errors since the code sign logic will try to clear the signing folder before the execution, to avoid mixing old and new content
2023-05-26 16:24:30 +02:00
Rolf Bjarne Kvinge eb9ab07404
[msbuild] Add a missing 'UsingTask' for the FindILLink task. (#18334) 2023-05-25 18:32:25 +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
Rolf Bjarne Kvinge 87bba7b3e6
[msbuild] Bump ILStrip and add a maestro dependency to keep it updated. (#18291) 2023-05-25 16:33:16 +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
Steve Hawley d57f205feb
[dotnet] Turn class-redirector into a Task (#18244)
Rework the class-redirector as an MSBuild Task.
2023-05-18 10:55:37 -04:00
Emanuel Fernandez Dell'Oca 73fefdb0c1
[dotnet] Fix linker path on Windows (#18285)
When building from Windows, we need to pass the path to the illink
assembly located on the Mac to the linker task. The educated guess we've
been using is a bit fragile and has been getting us problems almost on
each new .NET major release. On top of that, from .NET 8 the linker is
in a separate NuGet package, so the assembly is no longer located in the
SDK directory on the Mac.

The fix is to follow the same approach we use to find the AOT compiler
on the Mac by running a target that finds that information on the remote
Mac, and brings it back to Windows, where it is cached and use across
build.

Created a new XamarinBuildTask class to share most of the code needed
for this approach.

---------

Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2023-05-17 21:56:34 +02:00
Rolf Bjarne Kvinge 2906f0202d
[msbuild] Enable nullability in a few classes. (#18248) 2023-05-17 16:57:01 +02:00
VS MobileTools Engineering Service 2 9f60e3631d
Localized file check-in by OneLocBuild Task: Build definition ID 17751: Build ID 7769228 (#18275)
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.

---------

Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
Co-authored-by: tj-devel709 <tjlambert@microsoft.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2023-05-16 11:07:02 -05:00
Rolf Bjarne Kvinge 792a223c37
[autoformat] Fix running sed on Linux. (#18254)
The autoformat action doesn't necessarily run on macOS, and sed's syntax is
different between macOS and Linux - so make sure to cope with these
differences.

Also execute the nullability fixes in a separate subshell to not interfere
with the rest of the script.

This fixes an issue where autoformat would fail with:

    + sed -i '' -e 's/!= null/is not null/g' -e 's/== null/is null/g' builds/fix-maccatalyst-assembly/Program.cs
    sed: can't read : No such file or directory
2023-05-11 07:27:47 +02:00
VS MobileTools Engineering Service 2 e97707b224
Localized file check-in by OneLocBuild Task: Build definition ID 17751: Build ID 7737739 (#18238)
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.

---------

Co-authored-by: tj-devel709 <tjlambert@microsoft.com>
2023-05-09 11:03:52 -05:00
Rolf Bjarne Kvinge 62a43f4fa9
[msbuild] Merge the MTouch and MTouchTaskBase classes. (#18212)
We no longer need to have overridable logic for remote builds, so the
non-abstract task class and the abstract base class can be merged.

Also enable nullability and fix any issues.
2023-05-08 16:40:59 +02:00
Rolf Bjarne Kvinge eb7184831b
[msbuild] Merge the ILStrip and ILStripTaskBase classes. (#18211)
We no longer need to have overridable logic for remote builds, so the
non-abstract task class and the abstract base class can be merged.

Also enable nullability and fix any issues.
2023-05-08 11:03:00 +02:00
Rolf Bjarne Kvinge 32bf0b1996
[msbuild] Show a warning if asked to load an app manifest that doesn't exist. (#18222)
This makes it easier to diagnose problems loading/finding app manifests.

Specifying an app manifest that doesn't exist should probably be an
error, but that's very likely to break existing projects, so just make this a
warning for now.
2023-05-08 11:02:40 +02:00
Rolf Bjarne Kvinge 36af029204
Change all null checking expressions to use 'is' and 'is not'. (#18176)
Change all null checking expressions to use 'is null' and 'is not null'
instead of '== null' and '!= null'.

This was mostly done with sed, so code can probably be improved in many
other ways with manual inspection, but that will come over time.

Also add code to the autoformat script to automatically fix these issues in the future.
2023-05-05 17:52:19 +02:00
Rolf Bjarne Kvinge 21afe8a602
[msbuild] Simplify code by using updated API from Xamarin.MacDev. (#18090)
This also requires a Xamairn.MacDev bump.

New commits in xamarin/Xamarin.MacDev:

* xamarin/Xamarin.MacDev@bab25f5 [Xamarin.MacDev] Add a few convenience
overloads to IAppleSdk.
* xamarin/Xamarin.MacDev@920e87e Update UnitTests.csproj
* xamarin/Xamarin.MacDev@ccc9bd4 Update Xamarin.MacDev.csproj

Diff:
74c95ee1c3..bab25f535f
2023-05-04 22:48:37 +02:00
Rolf Bjarne Kvinge 101f800082
[msbuild] Merge the ILLink and ILLinkTaskBase classes. (#18086)
We no longer need two have overridable logic for remote builds, so the
non-abstract task class and the abstract base class can be merged.

Also enable nullability and fix any issues.
2023-05-04 07:40:09 +02:00
Rolf Bjarne Kvinge d12c04689f
Enable nullability in various places (#18082)
I started fixing nullability in one place, and then it snowballed a bit
and I had to fix nullability in a lot of places.

Most are trivial, except for the `generate-frameworks-constants`
project: I had to create a .NET version of the project in order to
compile a .NET version of the tool.
2023-05-04 07:39:56 +02: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
Rolf Bjarne Kvinge 312076a28c [msbuild] Check if a directory exists before trying to delete it. 2023-04-21 12:37:19 +02:00
Rolf Bjarne Kvinge 2899a7bf74 [msbuild] Use the right trailing slash for _AppContainerDir according to the current platform. 2023-04-20 18:21:18 +02:00
Rolf Bjarne Kvinge 2074b5e327 [msbuild] Change the logic about how the prebuilt app bundle is decompressed.
1. Compute the path of the zip in the .props file, and use it as Inputs for
   the PrepareAppBundle target. This way we only run PrepareAppBundle if the
   zip file has changed (and we actually run it if it has changed).
2. Delete any previous unzipped contents if we're unzipping (to make sure we
   don't have files leftover from an earlier version of the prebuilt zip).
3. Compute the 'HotRestartAppBundlePath' in a new and earlier task. This means
   we can also depend on this targe in the _CleanHotRestartBundle target to
   avoid having to compute the 'HotRestartAppBundlePath' property there as
   well.
4. Move the touching of the stamp file (the 'Extracted' file) to MSBuild. This
   way it shows up in logs.
5. Enable nullability in the PrepareAppBundle target and fix any issues.
2023-04-20 18:21:18 +02:00
Rolf Bjarne Kvinge 6c4dbf89a6 [msbuild] Change the Outputs of the _CompileHotRestartEntitlements target.
The output is the compiled Entitlements.plist file and
'archived-expanded-entitlements.xcent', not the Extracted sentinel file (which
is created when the prebuilt app bundle is unzipped).
2023-04-20 18:21:18 +02:00
Rolf Bjarne Kvinge b3478e81af [msbuild] Change the Outputs of the _CodesignHotRestartAppBundle target.
The output of codesigning is the _CodeSignature\CodeResources file, so use
that as the sentinel file to determine if the code signature is up-to-date or
not.

Using the individual files in the app bundle doesn't work, because they will
always have an up-to-date filestamp (since they were just copied to the app
bundle).
2023-04-20 18:21:18 +02:00
Rolf Bjarne Kvinge fd549e38c3 [msbuild] Rework HotRestart's DetectSigningIdentity task.
* Take the BundleIdentifier we computed in the CompileAppManifest as input.
* This means we don't need to read the app manifest anymore, which means all the
  corresponding code can be removed.
2023-04-20 18:21:18 +02:00
Rolf Bjarne Kvinge 43b47b4458 [msbuild] Use the general '[Compile|Read|Write]AppManifest' targets for hot restart.
And then adjust the resulting app manifest for hot restart in the
CompileHotRestartAppManifest target.

This makes sure we handle app manifests for hot restart builds just like we do
for normal builds.
2023-04-20 18:21:18 +02:00
Rolf Bjarne Kvinge 2431e3aeb7 [msbuild] Make the CompileAppManifest task work on Windows.
Make the CompileAppManifest task work on Windows by:

* Not requiring the default SDK version (impossible to calculate without Xcode)
  as an input property (we still require it when it's needed).
* Not requiring the SDK version (also impossible to calculate without Xcode).
* Using the minimum OS version we support as the as minimum OS version the app
  supports if building on Windows and an SDK version has not been provided.
* Not adding any of the app manifest values we get from Xcode.
2023-04-20 18:21:17 +02:00
Rolf Bjarne Kvinge 2d1d4b1ea1 [msbuild] Expand directories recursively into item groups.
This makes sure we find files in subdirectories too.
2023-04-20 18:21:17 +02:00