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

Dynamically detect the location of AdskidentityManager #391

Open
alextrical opened this issue Feb 13, 2024 · 24 comments
Open

Dynamically detect the location of AdskidentityManager #391

alextrical opened this issue Feb 13, 2024 · 24 comments
Labels
documentation Improvements or additions to documentation

Comments

@alextrical
Copy link
Contributor

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

alextrical commented Feb 14, 2024

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

alextrical commented Feb 14, 2024

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

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

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)

@cryinkfly cryinkfly added the documentation Improvements or additions to documentation label Feb 14, 2024
@Sjgharib
Copy link

Sjgharib commented Feb 15, 2024

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

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

Sjgharib commented Feb 15, 2024

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 <WINEPREFIX=$ROOTFOLDER/wineprefixes/default>. 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
Copy link

dzervas commented Feb 16, 2024

The login problem is split in 3.5 steps:

  • Get wine to open a native browser window (e.g. the linux firefox) - needs wine > 8.14
  • ( After logging in an adskidmgr://... URL is generated and has to be handled by xdg )
  • That handler needs to exist
  • That handler needs to point to the correct AdskIdentityManager.exe binary and execute it through wine

@Sjgharib
Copy link

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

Tony763 commented Feb 18, 2024

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

alextrical commented Feb 18, 2024

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

Tony763 commented Feb 19, 2024

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

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

axelkar commented Mar 4, 2024

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

alextrical commented Mar 4, 2024

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

badsmoke commented Mar 6, 2024

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

Matt2D3 commented Mar 8, 2024

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

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

Ameb commented Mar 23, 2024

anybody got this working through bottles?

Check #393

@Thermionix
Copy link
Contributor

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

Tony763 commented Apr 22, 2024

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

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

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

Tony763 commented Apr 22, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests