Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Xamarin.Android.Build.Tasks] Remove ILRepack #9226

Merged
merged 2 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions Documentation/guides/MSBuildBestPractices.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,7 @@ Waiting for debugger to attach (dotnet PID 13001). Press enter to continue...

You can then use VS or VSCode to attach to this process and debug you tasks.

In the case of .NET for Android we need to do a couple of thing first though. Firstly
we need to disable the use of `ILRepacker` on the `Xamarin.Android.Build.Tasks`
assembly. This is because `ILRepacker` does NOT handle debug symbols very well.
Assemblies it generates seem to be JIT optimized so the debugger will not load
the symbols. A new MSBuild property has been introduced to disable this feature
while debugging. `_ILRepackEnabled` can be set as an environment variable which
MSBuild will pickup. You will also need to build the `Debug` Configuration.

```dotnetcli
export CONFIGURATION=Debug
make prepare && _ILRepackEnabled=false make jenkins
```

This will disable the `ILRepacker` for the build.

You can then start your test app with the `dotnet-local` script (so it uses your build)
You can start your test app with the `dotnet-local` script (so it uses your build).

### [MacOS](#tab/macos)

Expand Down
2 changes: 2 additions & 0 deletions build-tools/create-packs/SignList.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<ItemGroup>
<!-- Do not sign files that already have a signature -->
<Skip Include="libZipSharp*" />
<Skip Include="NuGet*" />
</ItemGroup>

<ItemGroup>
Expand All @@ -10,6 +11,7 @@
<ThirdParty Include="Irony.dll" />
<ThirdParty Include="K4os.Compression.LZ4.dll" />
<ThirdParty Include="ELFSharp.dll" />
<ThirdParty Include="Newtonsoft.Json.dll" />
<ThirdParty Include="protobuf-net.dll" />
<ThirdParty Include="SgmlReaderDll.dll" />
<ThirdParty Include="aapt2.exe" />
Expand Down
2 changes: 2 additions & 0 deletions build-tools/installers/create-installers.targets
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)Mono.Options.dll" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)Mono.Options.pdb" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)MULTIDEX_JAR_LICENSE" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)Newtonsoft.Json.dll" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will some SignCheck step fail in VS, if we are missing Newtonsoft.Json.pdb? Do we have another pipeline to fetch symbols now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I set up https://devdiv.visualstudio.com/DevDiv/_git/VS/pullrequest/573022 to test a bit in VS, and to get some sign/symbol check validation as I also updated the sign list to skip signing of NuGet assemblies that should already be signed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like symbol and sign check are green there, so they must have access to the symbols from the package version we're using

<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)NuGet.Common.dll" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)NuGet.Configuration.dll" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)NuGet.DependencyResolver.Core.dll" />
Expand All @@ -142,6 +143,7 @@
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)System.Collections.Immutable.dll" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)System.Buffers.dll" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)System.IO.Hashing.dll" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)System.Reflection.Metadata.dll" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)Xamarin.Android.Aapt2.targets" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)Xamarin.Android.Analysis.targets" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)Xamarin.Android.Application.targets" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

<ItemGroup>
<PackageReference Include="Mono.Cecil" Version="$(MonoCecilVersion)" GeneratePathProperty="true" />
<PackageReference Include="ILRepack" Version="2.0.28" />
<PackageReference Include="Irony" />
<PackageReference Include="NuGet.ProjectModel" Version="6.11.0" />
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
<_MultiDexAarInAndroidSdk>extras\android\m2repository\com\android\support\multidex\1.0.1\multidex-1.0.1.aar</_MultiDexAarInAndroidSdk>
<_SupportLicense Condition="Exists('$(_AndroidSdkLocation)\extras\android\m2repository\NOTICE.txt')">$(_AndroidSdkLocation)\extras\android\m2repository\NOTICE.txt</_SupportLicense>
<_SupportLicense Condition="Exists('$(_AndroidSdkLocation)\extras\android\m2repository\m2repository\NOTICE.txt')">$(_AndroidSdkLocation)\extras\android\m2repository\m2repository\NOTICE.txt</_SupportLicense>
<_ILRepackEnabled Condition=" '$(_ILRepackEnabled)' == '' ">true</_ILRepackEnabled>
</PropertyGroup>
<ItemGroup>
<None
Expand Down Expand Up @@ -290,42 +289,6 @@
<Exec Command="chmod +x @(_MonoScriptDestination->'%(Identity)', ' ')" />
</Target>

<ItemGroup>
<InputAssemblies Include="$(OutputPath)Newtonsoft.Json.dll" />
<InputAssemblies Include="$(OutputPath)System.Collections.Immutable.dll" />
<InputAssemblies Include="$(OutputPath)System.Reflection.Metadata.dll" />
</ItemGroup>

<Target Name="ILRepacker"
Condition=" '$(_ILRepackEnabled)' == 'true' "
BeforeTargets="CopyFilesToOutputDirectory"
Inputs="$(MSBuildAllProjects);@(IntermediateAssembly);@(InputAssemblies)"
Outputs="$(IntermediateOutputPath)ILRepacker.stamp" >
<ItemGroup>
<_InputAssembliesThatExist Include="@(InputAssemblies)" Condition="Exists('%(Identity)')" />
<_NetstandardPath Include="@(ReferencePath->'%(RootDir)%(Directory)')" Condition="'%(FileName)%(Extension)' == 'netstandard.dll'" />
</ItemGroup>
<PropertyGroup>
<_NetstandardDir>@(_NetstandardPath)</_NetstandardDir>
<_ILRepackArgs>/out:&quot;$(MSBuildThisFileDirectory)$(IntermediateOutputPath)$(AssemblyName).dll&quot; /internalize</_ILRepackArgs>
<_ILRepackArgs>$(_ILRepackArgs) /keyfile:&quot;$(XamarinAndroidSourcePath)product.snk&quot;</_ILRepackArgs>
<_ILRepackArgs>$(_ILRepackArgs) &quot;$(MSBuildThisFileDirectory)$(IntermediateOutputPath)$(AssemblyName).dll&quot;</_ILRepackArgs>
<_ILRepackArgs>$(_ILRepackArgs) @(_InputAssembliesThatExist->'&quot;%(Identity)&quot;', ' ')</_ILRepackArgs>
<_ILRepackArgs>$(_ILRepackArgs) /lib:&quot;$(_NetstandardDir.TrimEnd('\'))&quot;</_ILRepackArgs> <!-- Path to netstandard.dll -->
</PropertyGroup>
<Exec
Command="$(ManagedRuntime) $(ManagedRuntimeArgs) &quot;$(ILRepack)&quot; $(_ILRepackArgs)"
WorkingDirectory="$(OutputPath)"
/>
<Touch
Files="$(IntermediateOutputPath)ILRepacker.stamp"
AlwaysCreate="True"
/>
<ItemGroup>
<FileWrites Include="$(IntermediateOutputPath)ILRepacker.stamp" />
</ItemGroup>
</Target>

<ItemGroup>
<_ExtraPackageSource Include="$(PkgXamarin_LibZipSharp)\lib\$(TargetFrameworkNETStandard)\libZipSharp.pdb" />
<_ExtraPackageTarget Include="$(OutputPath)\libZipSharp.pdb" />
Expand Down