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

Support for M1 ARM #131

Open
AerosTurbo opened this issue Jul 18, 2022 · 19 comments
Open

Support for M1 ARM #131

AerosTurbo opened this issue Jul 18, 2022 · 19 comments

Comments

@AerosTurbo
Copy link

AerosTurbo commented Jul 18, 2022

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
Copy link
Member

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
Copy link
Author

AerosTurbo commented Jul 19, 2022

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
Copy link
Member

alanhamlett commented Jul 19, 2022

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
Copy link
Author

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

@leemcmullen
Copy link

@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
Copy link

@alanhamlett Any thoughts on this issue mate?

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

@gandarez
Copy link
Member

gandarez commented Dec 13, 2022

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
Copy link

leemcmullen commented Dec 13, 2022

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

@gandarez
Copy link
Member

gandarez commented Dec 18, 2022

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 gandarez mentioned this issue Dec 18, 2022
@leemcmullen
Copy link

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
Copy link
Member

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

@leemcmullen
Copy link

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
Copy link
Member

alanhamlett commented Mar 16, 2023

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
Copy link

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

@roycornelissen
Copy link

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
Copy link

baskren commented Jun 16, 2023

@alanhamlett and @leemcmullen 👍

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

@grovolis
Copy link

grovolis commented Aug 25, 2023

@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
Copy link
Member

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

@gandarez
Copy link
Member

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

@alanhamlett alanhamlett changed the title VisualStudio WakaTime extension on M1 ARM doesn't work Not working on M1 ARM Jan 19, 2024
@alanhamlett alanhamlett changed the title Not working on M1 ARM Support for M1 ARM Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants