wakatime / visualstudio-wakatime

Visual Studio plugin for automatic time tracking and metrics generated from your programming activity.
https://wakatime.com/visual-studio
BSD 3-Clause "New" or "Revised" License
331 stars 64 forks source link

Support for M1 ARM #131

Open AerosTurbo opened 2 years ago

AerosTurbo commented 2 years ago

Hi,

I just upgraded to Visual Studio 2022 on MacBook Pro M1 Max (ARM) using Parallels.

Unfortunately, WakaTime extension throws an error every time I open Visual Studio. Here are the details:

Create Instance failed for package [WakaTimePackage] Source: 'mscorlib' Description: Could not load file or assembly 'file:///c:\users\test\appdata\local\microsoft\visualstudio\17.0_45d60efe\extensions\44g3sfld.gyw\WakaTime.Dev17.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format. System.BadImageFormatException: Could not load file or assembly 'file:///c:\users\test\appdata\local\microsoft\visualstudio\17.0_45d60efe\extensions\44g3sfld.gyw\WakaTime.Dev17.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format. File name: 'file:///c:\users\test\appdata\local\microsoft\visualstudio\17.0_45d60efe\extensions\44g3sfld.gyw\WakaTime.Dev17.dll' at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark) at System.Reflection.Assembly.LoadFrom(String assemblyFile, Evidence securityEvidence) at System.Activator.CreateInstanceFromInternal(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo) at System.AppDomain.CreateInstanceFrom(String assemblyFile, String typeName) WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Is there any workaround for this and when can we expect official support for ARM processors?

alanhamlett commented 2 years ago

If you're running VS on Windows inside a virtual machine, it shouldn't matter if the host is using M1 or Intel processor right?

AerosTurbo commented 2 years ago

It matters...: "An attempt was made to load a program with an incorrect format.". Extension has been installed using integrated Visual Studio extensions installer.

Screenshot 2022-07-19 at 06 59 00 Screenshot 2022-07-19 at 07 03 22
alanhamlett commented 2 years ago

That message means Visual Studio is trying to install the 32-bit version of the WakaTime extension when your OS is 64-bit.

Are you able to install other extensions in your Visual Studio?

AerosTurbo commented 2 years ago

Other extensions works normally. How can I force WakaTime to install 64-bit version?

leemcmullen commented 1 year ago

@alanhamlett @tpesl I'm getting the same issue. Wondered if there's a workaround yet? 🀞

Let me know if I can help to troubleshoot further or I can provide any info to help πŸ‘

leemcmullen commented 1 year ago

@alanhamlett Any thoughts on this issue mate?

Let me know if there’s anything I can do to help troubleshoot?

gandarez commented 1 year ago

Currently visual studio is built either in x86 and x64 for amd architecture. Few months ago Microsoft announced that v4.8.1 natively added support for arm architecture but it still targets v.4.8.

https://visualstudiomagazine.com/articles/2022/08/12/net-framework-4-8-1.aspx?m=1

I can take a look and figure out how to build for arm.

leemcmullen commented 1 year ago

@alanhamlett @gandarez @tpesl

Ok, good news, I've got it working in VS Community 2022 (ARM 64-bit) version 17.4.2 running on Windows 11 within Parallels on a MBP M1 πŸŽ‰πŸŽ‰

I did the following steps in this order. Caveat: I've never done any extension dev and was just feeling my way around in the dark really! So some of this might not have been/probably wasn't required/necessary πŸ˜‚:

No idea how this should be worked into the actual repo etc but hopefully it's useful information and might help some others get unstuck.

gandarez commented 1 year ago

Hi @leemcmullen I really appreciate the walkthrough you created, it helped a lot! Because I'm not in an ARM machine I can't build it. Would you mind checking out the branch feature/arm64 and test it for me?

https://github.com/wakatime/visualstudio-wakatime/tree/feature/arm64

135

leemcmullen commented 1 year ago

Hi @gandarez,

Sure, leave with me and I'll take a look.

I'll remove the version I have installed from my initial messing around, then I'll checkout your branch, build and attempt to install the resulting extension file manually.

Aside from that, is there anything else you specifically want me to test?

Cheers, Lee

gandarez commented 1 year ago

Lee just make sure your dashboard gets updated from this one.

leemcmullen commented 1 year ago

Hi @gandarez,

Checked out the branch, I changed nothing and it built first time. However it defaulted to x64 (i.e. output directory for VSIX file was bin/x64/Debug) which then failed to load after install.

So I changed current Active Solution Platform to ARM64, ran clean and then build. This time output was bin/ARM64/Debug and it installed and loaded just fine. I then verified data was coming through to the dashboard post install.

HTH

Cheers, Lee

alanhamlett commented 1 year ago

We can automate this with GitHub Actions, since the arm64 build is working.

I assume we need another Visual Studio Marketplace listing specific to Arm unless the marketplace has added support for multiple VSIX files per listing?

Previously, their docs said it wasn't supported but was being worked on. I can't find that doc, but here's some other relevant ones:

Supporting Multiple Versions of Visual Studio

Choose between shared and versioned VSPackages

grovolis commented 1 year ago

Any updates on this? Still no easy way to use wakatime on arm?

roycornelissen commented 1 year ago

I would also love to have an ARM build of this... any chance it can be released soon?

I will build one by hand for now...

baskren commented 1 year ago

@alanhamlett and @leemcmullen πŸ‘

I just tried the feature/arm64 branch. THANK YOU!!!

grovolis commented 1 year ago

@alanhamlett and @leemcmullen πŸ‘

I just tried the feature/arm64 branch. THANK YOU!!!

Can you share the process?

For anyone else looking for an answer, here's what I did:

  1. Clone the repo
  2. Checkout branch feature/arm64
  3. Clean solution
  4. Build project Dev17 (for VS 2022)
  5. Find the installer in bin\arm64\Debug

Once installer is finished, you WakaTime should prompt you for an API key.

alanhamlett commented 1 year ago

@gandarez let's get the arm branch merged and released?

gandarez commented 1 year ago

@gandarez let's get the arm branch merged and released?

@alanhamlett I think we first need create the pipeline to aumotate releasing part and then get branch merged?