pamidur / aspect-injector

AOP framework for .NET (c#, vb, etc)
Apache License 2.0
742 stars 111 forks source link

Lack of M1 support when rosetta isn't installed #210

Open omer-za opened 1 year ago

omer-za commented 1 year ago

Environment

Describe the bug Build fails on M1 without Rosetta

/Users/user/.nuget/packages/aspectinjector/2.8.1/buildTransitive/netstandard2.0/../../build/_bin/osx-x64/AspectInjector: Bad CPU type in executable
AspectInjector : error AI_FAIL: Aspect Injector processing has failed. See other errors. 
 Build FAILED.
0 Warning(s)
 1 Error(s)

To Reproduce Just try to build a project with aspectinjector as a package reference on a M1 machine without Rosetta

omer-za commented 1 year ago

@pamidur @kondr1 please let me know what can I do to make it resolved ASAP 🙏

pamidur commented 1 year ago

As a quick test you can set AspectInjector_Location in your csproj file to (folder_where_aspctInjector_files_are_located)/build/_bin/osx-arm64/AspectInjector e.g. /Users/user/.nuget/packages/aspectinjector/2.8.1/build/_bin/osx-arm64/AspectInjector

pamidur commented 1 year ago

We produce osx-arm64 binary but I don't see any code that would detect running on M1 https://github.com/pamidur/aspect-injector/blob/fbd25b9dcf8104d1a87b31cb8179c73d66e8db59/nuget/AspectInjector.Package.csproj#L35

I need to figure a reliable way to tell M1

pamidur commented 1 year ago

Please try https://www.nuget.org/packages/AspectInjector/2.8.2-pre1 once it is available

omer-za commented 1 year ago

With 2.8.2-pre1 I get a different error now. it's now choosing osx-arm64 but seems like it crashes :(

/var/folders/0n/s94fzz_95vs9pf6g24m6s8ph0000gn/T/tmpc2d2ee754f1944c1b86c2cd7eb08d38a.exec.cmd: line 2:
2910 Killed: 9               "/Users/user/.nuget/packages/aspectinjector/2.8.2-pre1/buildTransitive/netstandard2.0/../../build/_bin/osx-arm64/AspectInjector" -rf 
"/Users/user/work/jenkins/workspace/automation-browser-ci-mac/ZA.Automation.Allure/obj/Debug/net6.0/ZA.Automation.Allure.dll._asi_refs" 
AspectInjector : error AI_FAIL: Aspect Injector processing has failed. See other errors.
omer-za commented 1 year ago

Issue looks similar to here https://github.com/dotnet/runtime/issues/49091

omer-za commented 1 year ago

From further look seems that Apple Silicon binaries should be signed in order to be executed https://github.com/dotnet/runtime/issues/48387

omer-za commented 1 year ago

Confirmed, I executed codesign -s - /Users/user/.nuget/packages/aspectinjector/2.8.2-pre1/buildTransitive/netstandard2.0/../../user/_bin/osx-arm64/AspectInjector and now it works. It should be done as part of publishing using enableMacOSCodeSign

See https://github.com/dotnet/runtime/pull/53913/files#diff-6c584433992a50f29902c96eace64f3fea5b04445aa3cb800d1e993c8b2f884cR41

pamidur commented 1 year ago

Did you use just selfsigned certificate?

omer-za commented 1 year ago

yes, no special certificate provided

pamidur commented 1 year ago

Hi @omer-za , I'm sorry it took quite some time. Could you please see if 2.8.2-pre2 fixes the issue? Thank you!

osherdp commented 3 months ago

@pamidur issue still persists, even with 2.8.2-pre2

pamidur commented 3 months ago

Hi, I have figured the fix already, but wasn't able to implement it yet. Plus I'll need someone willing to test as I don't have a Mac.

On Sun, 12 May 2024, 21:34 Osher De Paz, @.***> wrote:

@pamidur https://github.com/pamidur issue still persists, even with 2.8.2-pre2

— Reply to this email directly, view it on GitHub https://github.com/pamidur/aspect-injector/issues/210#issuecomment-2106184634, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA7HZUCF4OBMOIWZGRVOVRTZB4ZR3AVCNFSM6AAAAAAUNX5VTGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBWGE4DINRTGQ . You are receiving this because you were mentioned.Message ID: @.***>

osherdp commented 3 months ago

Hi, I have figured the fix already, but wasn't able to implement it yet. Plus I'll need someone willing to test as I don't have a Mac. On Sun, 12 May 2024, 21:34 Osher De Paz, @.> wrote: @pamidur https://github.com/pamidur issue still persists, even with 2.8.2-pre2 — Reply to this email directly, view it on GitHub <#210 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA7HZUCF4OBMOIWZGRVOVRTZB4ZR3AVCNFSM6AAAAAAUNX5VTGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBWGE4DINRTGQ . You are receiving this because you were mentioned.Message ID: @.>

I can help testing it, should be easy enough