visualstudio-wakatime icon indicating copy to clipboard operation
visualstudio-wakatime copied to clipboard

Support for M1 ARM

Open AerosTurbo opened this issue 2 years ago β€’ 19 comments

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?

AerosTurbo avatar Jul 18 '22 10:07 AerosTurbo

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?

alanhamlett avatar Jul 19 '22 04:07 alanhamlett

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

AerosTurbo avatar Jul 19 '22 05:07 AerosTurbo

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?

alanhamlett avatar Jul 19 '22 17:07 alanhamlett

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

AerosTurbo avatar Jul 19 '22 20:07 AerosTurbo

@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 avatar Sep 14 '22 12:09 leemcmullen

@alanhamlett Any thoughts on this issue mate?

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

leemcmullen avatar Dec 12 '22 23:12 leemcmullen

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.

gandarez avatar Dec 13 '22 07:12 gandarez

@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 πŸ˜‚:

  • Cloned the repo and opened it in VS version above
  • Was getting a whole bunch of errors on the Dev14 proj so unloaded it
  • Focused on Dev17 proj only (assumed the "17" here aligns with VS version it's going to be installed in)
  • Added following entry within "source.extension.vsixmanifest" -> "Install Targets":
    • Identifier: Microsoft.VisualStudio.Community, VersionRange: [17.0,18.0), Product Architecture: arm64
  • Build now failed mentioning product enum issue. Updated all nuget packages to latest versions
  • Now building ok, same loading issue once installed though
  • Updated TargetFramework to 4.8.1
  • Added the following to the csproj file:
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|arm64'">
  <DebugType>full</DebugType>
  <PlatformTarget>ARM64</PlatformTarget>
  <OutputPath>bin\arm64\Debug\</OutputPath>
  <DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
  • Went to Configuration Manager and changed the Platform for Debug -> Dev17 to arm64
  • It started showing a warning about a <RuntimeIdentifiers> entry so added the following to the bottom of the csproj:
<PropertyGroup>
  <RuntimeIdentifiers>win-arm64;</RuntimeIdentifiers>
</PropertyGroup>
  • Clean, Build
  • Close VS. Double click the generated vsix within the bin\arm64\Debug directory to install
  • Next time I opened VS, I was prompted for my API Key. One odd thing here actually, I copied my API key from my dashboard settings and it has a waka_ prefix before the rest which looks like a GUID. Copying it with the waka_ prefix didn't work, an error was returned about an invalid key (sorry didn't note the actual message). I removed the waka_ prefix though and it was accepted
  • Clicked around in some files, made some edits and observed data coming through to my dashboard πŸŽ‰πŸŽ‰

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.

leemcmullen avatar Dec 13 '22 11:12 leemcmullen

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

gandarez avatar Dec 18 '22 21:12 gandarez

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

leemcmullen avatar Dec 19 '22 23:12 leemcmullen

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

gandarez avatar Dec 20 '22 00:12 gandarez

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

leemcmullen avatar Dec 20 '22 11:12 leemcmullen

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

alanhamlett avatar Mar 16 '23 06:03 alanhamlett

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

grovolis avatar May 30 '23 10:05 grovolis

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...

roycornelissen avatar Jun 15 '23 07:06 roycornelissen

@alanhamlett and @leemcmullen πŸ‘

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

baskren avatar Jun 16 '23 15:06 baskren

@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.

grovolis avatar Aug 25 '23 10:08 grovolis

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

alanhamlett avatar Aug 25 '23 13:08 alanhamlett

@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?

gandarez avatar Aug 27 '23 00:08 gandarez