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

Error dotnet reactor code obfuscation #8908

Open
vkmohan1689 opened this issue Apr 26, 2024 · 1 comment
Open

Error dotnet reactor code obfuscation #8908

vkmohan1689 opened this issue Apr 26, 2024 · 1 comment
Assignees
Labels
Area: App+Library Build Issues when building Library projects or Application projects. Area: Linker Issues when linking assemblies. enhancement Proposed change to current functionality.

Comments

@vkmohan1689
Copy link

vkmohan1689 commented Apr 26, 2024

Steps to Reproduce

  1. obfuscate dll with dotreactor cmd line tool
  2. project should be added as reference in android project
  3. build release version

Expected Behavior

apk should be generated without any issue

Actual Behavior

when link behavior is set to "Don't link " no issue with build if link behavior is set either "link sdk assemblies " or "link all assemblies " throws below error

Environment

<Target Name="ReactorCall" AfterTargets="Compile">
      <Exec Command="./dotNET_Reactor -file $(ProjectDir)$(IntermediateOutputPath)$(TargetFileName) -obfuscation 1 -stringencryption 1 -targetfile $(ProjectDir)$(IntermediateOutputPath)$(TargetFileName)" />

Build Logs

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Legacy.targets(5,5): Error XALNK7000: Mono.Linker.MarkException: Error processing method: 'System.Void <Module>::m8DC66491E0B6E2E()' in assembly: 'Libary3.dll' ---> System.NullReferenceException: Object reference not set to an instance of an object
  at Mono.Linker.Steps.MarkStep.MarkMethod (Mono.Cecil.MethodReference reference) [0x00009] in <43053c0ed9b14666903c480c1357d840>:0 
  at Mono.Linker.Steps.MarkStep.MarkInstruction (Mono.Cecil.Cil.Instruction instruction) [0x00040] in <43053c0ed9b14666903c480c1357d840>:0 
  at Mono.Linker.Steps.MarkStep.MarkMethodBody (Mono.Cecil.Cil.MethodBody body) [0x000c2] in <43053c0ed9b14666903c480c1357d840>:0 
  at Mono.Linker.Steps.MarkStep.ProcessMethod (Mono.Cecil.MethodDefinition method) [0x001b1] in <43053c0ed9b14666903c480c1357d840>:0 
  at Mono.Linker.Steps.MarkStep.ProcessQueue () [0x0001b] in <43053c0ed9b14666903c480c1357d840>:0 
   --- End of inner exception stack trace ---
  at Mono.Linker.Steps.MarkStep.ProcessQueue () [0x00047] in <43053c0ed9b14666903c480c1357d840>:0 
  at Mono.Linker.Steps.MarkStep.ProcessPrimaryQueue () [0x0000a] in <43053c0ed9b14666903c480c1357d840>:0 
  at Mono.Linker.Steps.MarkStep.Process () [0x000f6] in <43053c0ed9b14666903c480c1357d840>:0 
  at Mono.Linker.Steps.MarkStep.Process (Mono.Linker.LinkContext context) [0x0000d] in <43053c0ed9b14666903c480c1357d840>:0 
  at MonoDroid.Tuner.MonoDroidMarkStep.Process (Mono.Linker.LinkContext context) [0x0000b] in <43053c0ed9b14666903c480c1357d840>:0 
  at Mono.Linker.Pipeline.ProcessStep (Mono.Linker.LinkContext context, Mono.Linker.Steps.IStep step) [0x0000d] in <43053c0ed9b14666903c480c1357d840>:0 
  at Mono.Linker.Pipeline.Process (Mono.Linker.LinkContext context) [0x0000f] in <43053c0ed9b14666903c480c1357d840>:0 
  at MonoDroid.Tuner.Linker.Run (Mono.Linker.Pipeline pipeline, Mono.Linker.LinkContext context) [0x00000] in <43053c0ed9b14666903c480c1357d840>:0 
  at MonoDroid.Tuner.Linker.Process (MonoDroid.Tuner.LinkerOptions options, Mono.Linker.ILogger logger, Mono.Linker.LinkContext& context) [0x00071] in <43053c0ed9b14666903c480c1357d840>:0 
  at Xamarin.Android.Tasks.LinkAssemblies.Execute (Java.Interop.Tools.Cecil.DirectoryAssemblyResolver res) [0x0018f] in <43053c0ed9b14666903c480c1357d840>:0 
  at Xamarin.Android.Tasks.LinkAssemblies.RunTask () [0x0001b] in <43053c0ed9b14666903c480c1357d840>:0 
  at Microsoft.Android.Build.Tasks.AndroidTask.Execute () [0x00000] in /Users/runner/work/1/s/xamarin-android/external/xamarin-android-tools/src/Microsoft.Android.Build.BaseTasks/AndroidTask.cs:17  (XALNK7000) (OfuscationExample.Android)
@rolfbjarne rolfbjarne transferred this issue from xamarin/xamarin-macios Apr 26, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issues that need to be assigned. label Apr 26, 2024
@jpobst jpobst added Area: App+Library Build Issues when building Library projects or Application projects. Area: Linker Issues when linking assemblies. labels Apr 27, 2024
@jonathanpeppers
Copy link
Member

@vkmohan1689 for this to work, you are going to need some general MSBuild knowledge and know the appropriate places to hook into the build process. This isn't going to work out of the box. We can offer suggestions, but the docs here are probably the place to start:

$(AfterGenerateAndroidManifest) is an example of a build-time extension point.

If ".NET Reactor" is a product, they could build this support for you. I imagine it would be a NuGet package that supports all .NET MAUI platforms.

@jonathanpeppers jonathanpeppers added enhancement Proposed change to current functionality. and removed needs-triage Issues that need to be assigned. labels Apr 29, 2024
@jonathanpeppers jonathanpeppers added this to the Under Consideration milestone Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: App+Library Build Issues when building Library projects or Application projects. Area: Linker Issues when linking assemblies. enhancement Proposed change to current functionality.
Projects
None yet
Development

No branches or pull requests

3 participants