cryinkfly / Autodesk-Fusion-360-for-Linux

This is a project, where I give you a way to use Autodesk Fusion 360 on Linux!
https://github.com/cryinkfly/Fusion-360---Linux-Wine-Version-/wiki
MIT License
1.78k stars 115 forks source link

Dynamically detect the location of AdskidentityManager #391

Open alextrical opened 4 months ago

alextrical commented 4 months ago

Describe the bug the location of AdskidentityManager.exe changes with every update, resulting in more maintenance of the .desktop mimetype link.

I see this is resulting in a lot of chatter, and i'm not sure if the main script includes the creation of the .desktop and registering of it as a default mimetype.

@cryinkfly The solution to this came to me while talking to @dzervas We can use the registry values from Fusion to track the correct latest folder, and utilize that at the time we create the desktop link. Every following update will also need to update it.

I will start drafting up the script tomorrow. But for now there may need to be a central post on the main page to address the influx of issues

alextrical commented 4 months ago

This does the job to identify the current/latest install folder, not the nicest code I've ever written, but it gives the location we need dynamically

wine reg query "HKLM\Software\Classes\fusion360\shell\open\command" /ve  | sed "s/    (Default)    REG_SZ    \"//" | sed "s/HKEY_LOCAL_MACHINE\\\Software\\\Classes\\\fusion360\\\shell\\\open\\\command//" | sed '/^[[:space:]]*$/d' | sed "s/NLauncher.exe\" \"%1\"//"
alextrical commented 4 months ago

amended working Proof Of Concept script. Will add the same to Bottles once i get their infrastructure working as needed

export env ROOTFOLDER=~/.fusion
mkdir {$ROOTFOLDER,$ROOTFOLDER/wineprefixes,$ROOTFOLDER/Downloads}
rm -r $ROOTFOLDER/wineprefixes/default
export env WINEPREFIX=$ROOTFOLDER/wineprefixes/default
export env WINEDEBUG=fixme-all #Hide the fixme messages intended for Wine developers
SP_FUSION360_INSTALLER_URL="https://dl.appstreaming.autodesk.com/production/installers/Fusion%20Admin%20Install.exe"
SP_WEBVIEW2_INSTALLER_URL="https://github.com/aedancullen/webview2-evergreen-standalone-installer-archive/releases/download/109.0.1518.78/MicrosoftEdgeWebView2RuntimeInstallerX64.exe"

#Wine version checking, warn user if their wine install is out of date
WINE_VERSION="$(wine --version  | cut -d ' ' -f1 | sed -e 's/wine-//' -e 's/-rc.*//')"
WINE_VERSION_MINIMUM=8.14
if (( $(echo "$WINE_VERSION < $WINE_VERSION_MINIMUM" | bc -l) )); then
    echo "Your version of wine ${WINE_VERSION} is too old and will not work with Autodesk Fusion. You should upgrade to at least ${WINE_VERSION_MINIMUM}"
fi

#Install required Font, the Navigation bar will not work without this font.
wget https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks -O $ROOTFOLDER/Downloads/winetricks
chmod +x $ROOTFOLDER/Downloads/winetricks
$ROOTFOLDER/Downloads/winetricks arial
wine winecfg -v win10

#Remove tracking metrics/calling home
wine REG ADD "HKCU\Software\Wine\DllOverrides" /v "adpclientservice.exe" /t REG_SZ /d "" /f
#Navigation bar does not work well with anything other than the wine builtin DX9
wine REG ADD "HKCU\Software\Wine\DllOverrides" /v "AdCefWebBrowser.exe" /t REG_SZ /d builtin /f
#Use Visual Studio Redist that is bundled with the application
wine REG ADD "HKCU\Software\Wine\DllOverrides" /v "msvcp140" /t REG_SZ /d native /f
wine REG ADD "HKCU\Software\Wine\DllOverrides" /v "mfc140u" /t REG_SZ /d native /f

cat > $ROOTFOLDER/Downloads/NMachineSpecificOptions.xml << EOL
<?xml version="1.0" encoding="UTF-16" standalone="no" ?>
<OptionGroups>
  <BootstrapOptionsGroup SchemaVersion="2" ToolTip="Special preferences that require the application to be restarted after a change." UserName="Bootstrap">
    <driverOptionId ToolTip="The driver used to display the graphics" UserName="Graphics driver" Value="VirtualDeviceDx9"/></BootstrapOptionsGroup>
</OptionGroups>
EOL

#Download and install WebView2 to handle Login attempts, required even though we redirect to your default browser
wget -N $SP_WEBVIEW2_INSTALLER_URL -P $ROOTFOLDER/Downloads
wine $ROOTFOLDER/Downloads/MicrosoftEdgeWebView2RuntimeInstallerX64.exe /install #/silent

#Download latest Admin Install, only if the file has changes since last time we connected to the server
wget -N $SP_FUSION360_INSTALLER_URL -P $ROOTFOLDER/Downloads

#Extract the icon from the installer, this will give the latest icon without breaking any distribution licenses
wrestool -x --output=$ROOTFOLDER/Downloads/Fusion360.ico -t14 "${ROOTFOLDER}/Downloads/Fusion Admin Install.exe"

#Install the application, the UI doesn't work for us, so install in the background. Could do with tracking folder size to get a progress bar for the user here
wine $ROOTFOLDER/Downloads/Fusion\ Admin\ Install.exe --quiet

mkdir -p "${ROOTFOLDER}/wineprefixes/default/drive_c/users/$USER/AppData/Roaming/Autodesk/Neutron Platform/Options"

cp $ROOTFOLDER/Downloads/NMachineSpecificOptions.xml "${ROOTFOLDER}/wineprefixes/default/drive_c/users/$USER/AppData/Roaming/Autodesk/Neutron Platform/Options"

#Disable Debug messages on regular runs, we dont have a terminal, so speed up the system by not wasting time prining them into the Void
sed -i 's/=env WINEPREFIX=/=env WINEDEBUG=-all env WINEPREFIX=/g' "$HOME/.local/share/applications/wine/Programs/Autodesk/Autodesk Fusion.desktop"

#Cleanup any shortcuts created we dont want, though they seem to work well now
#rm -f "$HOME/.config/menus/applications-merged/wine-Programs-Autodesk-Autodesk Fusion.menu"
#rm -rf "$HOME/.local/share/applications/wine/Programs/Autodesk/Autodesk Fusion.desktop"

#Fetch the location of AdskIdentityManager
ADSKCUR=$(env LANG=en_US.UTF-8 wine reg query "HKLM\Software\Classes\fusion360\shell\open\command" /ve  | sed "s/    (Default)    REG_SZ    \"//" | sed "s/HKEY_LOCAL_MACHINE\\\Software\\\Classes\\\fusion360\\\shell\\\open\\\command//" | sed '/^[[:space:]]*$/d' | sed "s/NLauncher.exe\" \"%1\"//" )

#Create mimetype link to handle web login call backs to the Identity Manager
cat > $HOME/.local/share/applications/adskidmgr-opener.desktop << EOL
[Desktop Entry]
Type=Application
Name=adskidmgr Scheme Handler
Exec=env WINEPREFIX="$ROOTFOLDER/wineprefixes/default" wine "$ADSKCUR\Autodesk Identity Manager\AdskIdentityManager.exe" %u
StartupNotify=false
MimeType=x-scheme-handler/adskidmgr;
EOL
xdg-mime default adskidmgr-opener.desktop x-scheme-handler/adskidmgr
alextrical commented 4 months ago

Out of curiosity, if WGET with no clobber can tell when there is an update to the remote installation file, why don't we use that to initiate an update of the software? We could them make the script fully self contained, without reliance on remote repos, (i.e a fully version locked script that can be downloaded and run stand alone) or tracking a text file for updates.

alextrical commented 4 months ago

alternatively we can also scrape the information we need out of the SQLite DB at C:/Program Files/Autodesk/webdeploy/meta/registry and browse the record in the tblAPPLICATIONS something along the lines of SELECT * FROM tblAPPLICATIONS WHERE LIKE '%AdskIdentityManager.exe' (Assuming SQLite is similar to Transact SQL)

Sjgharib commented 4 months ago

So will this ultimately solve the issue with Fusion login? I cannot seem to fix that issue.

This script runs nicely, but when you hit "login" on the Fusion360 splash page it acts like the browser should open, but nothing happens and eventually you get a snap error (ubuntu)

alextrical commented 4 months ago

This would help redirect the login from the web browser back to the application.

If you are unable to get your web browser to open from the Fusion application, it's most likely that the version of Wine you are using doesn't have the required patch that was made part of Wine 8.14 and higher that can handle the pressing "login" button and then opening the web browser

Sjgharib commented 4 months ago

I am running Wine 9.2 on Ubuntu. I'm a bit confused on how it's supposed to behave - is it supposed to launch a native linux browser (e.g. firefox) or is it supposed to launch a browser within wine?

I am on a completely clean install of 23.10 I'm running the following commands to install wine etc:

sudo apt-get update sudo apt-get --allow-releaseinfo-change update sudo dpkg --add-architecture i386 sudo mkdir -pm755 /etc/apt/keyrings sudo wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/mantic/winehq-mantic.sources sudo apt update sudo apt-get install p7zip p7zip-full p7zip-rar curl winbind cabextract wget sudo apt install --install-recommends winehq-staging

Then I run your script above. However I noted that the registry call wasn't looking in the correct place to return the registry key that gives you the path to the Identity Manager. Shouldn't it be:

ADSKCUR=$(WINEPREFIX=$ROOTFOLDER/wineprefixes/default wine reg query "HKLM\Software\Classes\fusion360\shell\open\command" /ve | sed "s/ (Default) REG_SZ \"//" | sed "s/HKEY_LOCAL_MACHINE\\Software\\Classes\\fusion360\\shell\\open\\command//" | sed '/^[[:space:]]*$/d' | sed "s/NLauncher.exe\" \"%1\"//")

I added the . Otherwise on my system the original code would return an error of "not found"...

Thoughts? Am I installing wine incorrectly? There was another thread that indicated that I may need to change the default browser settings in the HTTP & HTTPS registry key to point it towards the linux browser. Do we need to do that?

dzervas commented 4 months ago

The login problem is split in 3.5 steps:

Sjgharib commented 4 months ago

Thanks - that's very helpful.

So aside from 8.14 (since I installed 9.2), what else is required to spawn that native browser? (your first bullet above) I believe it's stuck there. Are there registry settings i need to change?

The Autodesk greeting window does change - below the "sign in" box it inially says "we will take you to your web browser to sign in, then bring you back here." and the window is active and you can close it. When you hit "sign in", the message changes to "check your web browser to sign in", and the window basically locks and you can no longer close it. In fact the only way to kill it is to find the process or just log out. So it definitely seems to be trying to do something...?

It would be helpful to understand what's going on behind the scenes I assume. I will see if I can figure out how to launch it in a terminal window to see if there are any messages...

Tony763 commented 4 months ago

Hi @alextrical, just small finding. To make your sed command work on system with default language other than English, it need to be run with forced language: env LANG=en_US.UTF-8 wine reg query ...

alextrical commented 4 months ago

Hopefully that amendment can be added into the main script by @cryinkfly

For what it's worth the sed command I've used is almost certainly a lot more convoluted than a search and replace could be by using some smarter/cleaner regex

Tony763 commented 4 months ago

I see You eddited Your PoC, but it somehow apend double / and ^M to string, removing them fixes starting Ident Manager

Steps:

export env ROOTFOLDER=~/.applications/fusion/
export env WINEPREFIX=$ROOTFOLDER/wineprefixes/default
ADSKCUR=$(env LANG=en_US.UTF-8 wine reg query "HKLM\Software\Classes\fusion360\shell\open\command" /ve  | sed "s/    (Default)    REG_SZ    \"//" | sed "s/HKEY_LOCAL_MACHINE\\\Software\\\Classes\\\fusion360\\\shell\\\open\\\command//" | sed '/^[[:space:]]*$/d' | sed "s/NLauncher.exe\" \"%1\"//" )

cat > $HOME/.local/share/applications/adskidmgr-opener.desktop << EOL
[Desktop Entry]
Type=Application
Name=adskidmgr Scheme Handler
Exec=env WINEPREFIX="$ROOTFOLDER/wineprefixes/default" wine "$ADSKCUR\Autodesk Identity Manager\AdskIdentityManager.exe" %u
StartupNotify=false
MimeType=x-scheme-handler/adskidmgr;
EOL
xdg-mime default adskidmgr-opener.desktop x-scheme-handler/adskidmgr

Edit: For clarification, code above is meant to reproduce error, not to show correct way to do it. Result into:

[Desktop Entry]
Type=Application
Name=adskidmgr Scheme Handler
Exec=env WINEPREFIX="/home/tony/.applications/fusion//wineprefixes/default" wine "C:\Program Files\Autodesk\webdeploy\production\57cd45aa09be2d79663784069561ec17eda99ca8\^M\Autodesk Identity Manager.exe" %u
StartupNotify=false
MimeType=x-scheme-handler/adskidmgr;

Should be:

[Desktop Entry]
Type=Application
Name=adskidmgr Scheme Handler
Exec=env WINEPREFIX="/home/tony/.applications/fusion/wineprefixes/default" wine "C:\Program Files\Autodesk\webdeploy\production\57cd45aa09be2d79663784069561ec17eda99ca8\Autodesk Identity Manager.exe" %u
StartupNotify=false
MimeType=x-scheme-handler/adskidmgr;
Sjgharib commented 4 months ago

So i've made progress... I switched OS to Linux Mint. The script above worked. So now it opens the browser and I can sign in successfully. Once I sign in, i get this from the browser (pic attached) Screenshot from 2024-02-23 11-49-33 If I say open link, nothing happens. However the process is running if you look. I made sure to check the path is correct, and from the process running it does seem to be finding the right .exe and running it. However Fusion itself doesn't open. After you run the script above, do you then need to go back to the original instructions and run the OpenGL or DXVK commands for the actual Fusion application to launch?

axelkar commented 3 months ago

Thanks @Tony763 ! One small issue. reg returns a trailing backslash and a trailing carriage return so $ADSKCUR\Autodesk ... doesn't work. I used tr -d '\r'

Also in Bottles, I had to change from soda-8.0-2 to caffe-8.21 to get Firefox to even launch.

alextrical commented 3 months ago

Thank you for the update, I will get that added into the code above.

The fix we needed to get the login to work was added into wine in 8.14, any version after that also works.

I've been trying to get the bottles install scrip working, but they are still missing some fundamental options needed for this kind of install. Their manifests can't check for a minimum version of Wine, not does it look like there is a way to create a mimetype on the host. It's close but yet so far from working how I hoped

badsmoke commented 3 months ago

I can't get it to run with bottles, I tried to execute the exec command with flatpak. but have no success

flatpak run --command=bottles-cli com.usebottles.bottles run -b fusion -e "/home/USERNAME/.var/app/com.usebottles.bottles/data/bottles/bottles/fusion/drive_c/Program Files/Autodesk/webdeploy/production/0a22ca515421cec8a3addbf5f00fde68499915d7/Autodesk Identity Manager/AdskIdentityManager.exe" %u

Matt2D3 commented 3 months ago

under bottles, the browser login works and launches AdskIdentitymanager, but the identity manager does not login fusion the AdskIdentitymanager spawned stops when i force stop the bottle, so i think its finding the correct exe for Adskidentitymanager after attempting to login, the main fusion window shows very little activity in btop, AdskIdentitymanager reports to use 12.8% cpu with occasional spikes up to 35.2% the sign in button on fusion also stops working

ubuntu 23.10 caffe-8.21 firefox 123.0.1 (snap)

skarzzzz commented 3 months ago

anybody got this working through bottles?

im very new at this type of stuff i used to have fusion working fine with bottles but from this new update its rendered it useless, ive tried to edit the .desktop file with the install directory with bottles but after i click sign in then it says open xdp then nothing happens

any help is appreciated

Ameb commented 3 months ago

anybody got this working through bottles?

Check #393

Thermionix commented 2 months ago

another way to find AdskIdentityManager.exe

IDENTITY_EXE="$(find "${WINEPREFIX}" -name "AdskIdentityManager.exe" | head -1 | xargs -I '{}' echo {})"
cat > $HOME/.local/share/applications/adskidmgr-opener.desktop << EOL
[Desktop Entry]
Type=Application
Name=adskidmgr Scheme Handler
Exec=env WINEPREFIX="${WINEPREFIX}" wine "${IDENTITY_EXE}" %u
StartupNotify=false
MimeType=x-scheme-handler/adskidmgr;
EOL
xdg-mime default adskidmgr-opener.desktop x-scheme-handler/adskidmgr
Tony763 commented 2 months ago

Hi @Thermionix, nice way, but its only onetime search. To make it truly dynamic, IDENTITY_EXE must be defined inside desktop entry and be called each run of desktop entry. Otherwise address it will not be correct after Fusion update (You would have to start desktop entry creation again).

Thermionix commented 2 months ago

well, this works for me; but I'm not running it within a prefix

[Desktop Entry]
Type=Application
Name=adskidmgr Scheme Handler
Exec=sh -c 'wine "$(find ~/.wine/ -name "AdskIdentityManager.exe" | head -1 | xargs -I '{}' echo {})" "%u"'
StartupNotify=false
MimeType=x-scheme-handler/adskidmgr;
Thermionix commented 2 months ago

to do that within the script, escape the subshell so it prints;

#!/bin/bash
WINEPREFIX="~/.wine"
cat > $HOME/.local/share/applications/adskidmgr-opener.desktop << EOL
[Desktop Entry]
Type=Application
Name=adskidmgr Scheme Handler
Exec=sh -c 'env WINEPREFIX="${WINEPREFIX}" wine "\$(find ${WINEPREFIX} -name "AdskIdentityManager.exe" | head -1 | xargs -I '{}' echo {})" "%u"'
StartupNotify=false
MimeType=x-scheme-handler/adskidmgr;
EOL

output:

$ cat $HOME/.local/share/applications/adskidmgr-opener.desktop
[Desktop Entry]
Type=Application
Name=adskidmgr Scheme Handler
Exec=sh -c 'env WINEPREFIX="~/.wine" wine "$(find ~/.wine -name "AdskIdentityManager.exe" | head -1 | xargs -I '{}' echo {})" "%u"'
StartupNotify=false
MimeType=x-scheme-handler/adskidmgr;
Tony763 commented 2 months ago

With a help from friend, this should do exactly what we need. Wine prefix will be harcoded on creation time. Find command is called each time desktop entry is run. This will preserve function even after update.

WINEPREFIX="~/.wine"
cat > $HOME/.local/share/applications/adskidmgr-opener.desktop << EOL
[Desktop Entry]
Type=Application
Name=adskidmgr Scheme Handler
Exec=sh -c 'env WINEPREFIX="${WINEPREFIX}" wine "\$(find ${WINEPREFIX}/ -name "AdskIdentityManager.exe" | head -1 | xargs -I '{}' echo {})" "%u"'
StartupNotify=false
MimeType=x-scheme-handler/adskidmgr;
EOL
xdg-mime default adskidmgr-opener.desktop x-scheme-handler/adskidmgr

Test it if You can, please.