Sequencing AutoCAD 2015 in App-V 5

Please see updates to this post HERE.

The stars had aligned! I had finished all of the testing for The Deployment Performance Series research, published the first of the 8 papers, shipped my server down to North Carolina for our next training class. And great summer weather was set for a great week of golf. Then my knee acted up so I needed to give it a couple days of rest. Feeling rather pissed off, I decided to work on something horrible. Which is good for you.

I first sequenced the 2000i version of AutoCAD back in 2001. Autodesk was one of the early ISVs to really get in and support the concept of virtualizing applications. They didn’t have as many versions back then, I recall just one version of AutoCAD plus 3DS Max. But it was still big and hairy and it took more than a few passes to get it right.

Over the years, the software designers at AutoDesk are seemingly always using some cutting edge developer stuff inside their annual releases. And sometimes we struggle with how to make that work for a couple weeks, but it always does. Until a couple of years ago. The first Autodesk version I ran into with a seemingly unsolvable problem was AutoCAD Architecture 2012. Then some versions of the 2013 series, like Revit and Creation Suite seemed to have the same kind of launch issue. This was against a 4.6 sequencer, but testing against the new 5.0 showed the same symptom. The app would launch and immediately spit out an application specific error that it was not installed properly, and all of the procmons and xperfs could not help. I worked a trouble ticket with Microsoft for one customer for about 9 months before we gave up in frustration. This unanswered forum post remains.

So on a whim I pulled out App-V 5.0 SP2 with Hotfix 4 and AutoCAD 2015 and went to work in a pissed off mood. And I got it working. Here’s how.

Step 1.  The first thing you do with any Autodesk product is deal with the dependencies. There are some dependencies that are incompatible with App-V, and others that are inconvenient. These must be identified and the installer configured to not install them. You then treat them as dependencies to be installed on the sequencer prior to sequencing, and pushed out to any client machines natively that are going to get the working package.

To configure the installer, which will be a setup.exe, you modify the setup.ini file. Make a backup copy of it and then edit the setup.ini file using your favorite text editor like Notepad.

The ini file is organized in sections. A section starts with a line contained in square brackets, such as [ACAD]. You start in the [SETUP] section at the top of the file. There are several lines that set variables like “EXE_SEQUENCE”. Depending on how you start the installer, one of these is used, and it identifies which of the remaining sections will be run. I simply ignore these and make all fixes in the sections themselves.

#============================= Install Execute & UI Sequence =============================
EXE_SEQUENCE=ACAD;NLM;CADM;SNAP;AUTODESK_RECAP;ACADAPPMGR;ACADFEATUREDAPPS;PERFORMANCETOOL;GLUE_PLUGIN_AUT;ADSYNC;ADAPPLICATIONMANAGER
INSTALL_SEQUENCE=NLM;CADM;SNAP;ACAD;AUTODESK_RECAP;ACADAPPMGR;ACADFEATUREDAPPS;PERFORMANCETOOL;GLUE_PLUGIN_AUT;ADSYNC;ADAPPLICATIONMANAGER
UI_SEQUENCE=LaunchDlg;BeginDeploymentDlg;LicenseDlg;ProductInfoDlg;ProductSelectionDlg2;ACAD;CADM;SNAP;ADSYNC;ADAPPLICATIONMANAGER;FullProgressDlg;InstallCompleteDlg;DeploymentCompleteDlg;DeploymentFailedDlg

Inside a section, such as the [ACAD] section, will be a variable called “PREREQUISITE”. This variable defines other sections that are to be installed before installing the software named in the EXE_PATH variable in the section. I make a copy of the PREREQUISITE line and comment out the old copy (lines starting with a “#” are comments). I then just remove items from the list that I want to treat as dependencies.
[ACAD]
PLATFORM=NATIVE
PRODUCT_NAME=Autodesk® AutoCAD® 2015
#PREREQUISITE=ACAD_VISTA_BLOCK;IE;SSE2;DOTNET45;DOTNET45LANG;VCREDIST2008SP1X86;VCREDIST2008SP1X64;VCREDIST2010SP1X86;VCREDIST2010SP1X64;VCREDIST2012X86UPD4;VCREDIST2012X64UPD4;DIRECTX;MSXML6;WMF95X64;CM;CMILB;SNAP_PRE
PREREQUISITE=CM;CMILB;SNAP_PRE
POSTREQUISITE=ACAD_PSPACK;ACADSKETCHUPIMPORT
EXE_PATH=%platform%\acad\acad.msi
EXE_PARAM=

If you want to know what any of the dependencies are, you locate that section and look at its lines. Some, like IE just check to see if you have internet explorer and bomb out if it isn’t present. Others, like DOTNET45, install things. Typically the installer doesn’t first check to see if it is already present, so I prefer to remove the entry as a prerequisite as shown above.

Only DOTNET45, DOTNET45LANG, and DIRECTX are incompatible with the current sequencer. WMF and MSXML6 were App-V 5 prerequisites and will already be present. Those VCRuntimes are things I still prefer to keep out of my packages anyway. By looking at the prerequisite’s section, I can find the version of the installer they would have used (typically under a folder called 3rdParty). Especially with the VCRuntimes, it is important to use the version that they provide. Autodesk loves to use names, like “VC++ 2008 SP1” that isn’t exactly the same version you’ll find on the internet with that name. In some cases over the years I have found them using VC Runtime builds that apparently never appeared on Microsoft’s public download sites. I maintain a list of VC Runtime versions here to aid in identifying versions.

You must walk through the entire file editing these prerequisites (hint: use the find function of notepad on “PREREQUISITE”) and remove the item from each. You can even be pedantic and remove the offending section completely also. Save off the edited file.

You can get bonus points for figuring out how to set your license information in the file, and removing features you don’t want, but I like to handle that through the GUI when sequencing anyway.

Step 2.  Install the prerequisites on the sequencer. My preference is to order the installs the same way that AutoDesk would have. And then reboot (if you used the command line arguments you found in the appropriate section you instructed the installer to suppress reboot notifications). And then take a snapshot. You probably won’t get the package right the first time, even with these notes to help.

Step 3.  Start the Sequencer, but not a Sequence yet.

In the Tools–>Options menu of the sequencer remove the LOCAL APPDATA exclusion. Autodesk likes to put some important stuff here that needs to be in the package. If you want to be a perfectionist, add AppData/Local/Microsoft to the list.

Step 4.  Start Sequencing. Note that if you run the installer off of a share (or even a local path) that has the path to the setup.exe longer than around 100 characters, it will fail (there actually is a section that checks for that in the setup.ini).

Take care of the licensing, select your features and go. At the finish, it prompts you to reboot. You need to immediately perform the reboot, then immediately log back in. I found that if you wait to long the sequencer doesn’t work right (at least on this package). The sequencer will pick back up and tell you to continue installing. And while you might think that you are done, you are not.

Step 5.  Wait.

The main installer will check for updates. There isn’t any right now, but Autodesk usually produces updates almost monthly. If any appear, you probably want them now. Click the Finish button for the installer when done.

Step 6.  If you included the “360” feature, wait more. Maybe 15 minutes.

This uses a different updater and will automatically download the update in the background (there is one already) and then notify you above the icon tray. Install it.

Reboot again.

Step 7.  Fix FlexNet.

Autodesk uses Flexera’s FlexNet service for licensing. To assure the ISV that users won’t tamper with the licensing service, Flexera hardens the service security in a way that is incompatible with App-V and the client won’t be able to start the virtual service for you. Here is how I fix it.

Start a command prompt using “Run As Administrator”. Yeah, I know that you’re already an admin, but you have to elevate anyway. Then type in the following command. Scratch that, copy and paste it!
sc sdset "FlexNet Licencing Service 64" D:(A;;CCDCLCSWRPWPDTLOCRGASDRCWDWO;;;WD)

If you want to know what that is, get some scotch and google DACL. NOTE: If you have more than one virtual app running at the same time with Flexnet licensing, you’ll need to remove the service from the package and run it externally.

Step 8.  Kill the autoupdaters.

Use the tray icon for “app manager”, go to settings and uncheck box to check for updates on logon.

Afterwards, use the windows services manager and change AutoDesk Application Manager service to Manual or Disabled. (Hint: Disabled is better).

Step 9.  Avoid the AppPath bug.

My friend Rory Dan Gough (@packageologist) recently noticed that AppPaths don’t work under App-V they way they should. When a program declares an AppPath it is supposed to be used to prepend the identified paths in front of the path variable, but he noticed it was replacing the path variable. AutoCAD 2015 has two executables declaring an AppPath to prepend a common autodesk folder.

Use RegEdit and locate them under HKLM\Software\Microsoft\Windows\CurrentVersion\AppPath. You are looking for two keys named something like”AdAppMgr” which will conveniently enough be at the top of the alphabetized list. Make a copy of the path listed under the key, and delete both keys.

Then use an elevated cmd prompt to set the path variable like this:
set PATH="C:\Program Files x86\Common Files\Autodesk Shared\AppManager\R1";%PATH%

Step 10.  Avoid the TRUSTED CODE problem.

Autodesk engineers invented a new way to check that their program doesn’t launch something untoward. It breaks things at the client complaining that the file being run isn’t in the trusted path. So I edited the variable for it here.

Regedit and change
HKCU\Software\Autodesk\AutoCAD\R20.0\ACAD-E001:409\Profiles\< >\\Variables\TRUSTEDPATHS to a value of C:\Program Files\Autodesk\AutoCAD 2015/support/en-US

Step 11.   Don’t run AutoCAD! If you need to configure anything, figure out a different way to get it set.

Step 12.  Fix Stupidity.

Advance through the sequence (again, Don’t launch!) and get to the sequence editor. On the Files tab, locate the following folder:
Root\VFS\appdata\roaming\autodesk\AutoCAD 2015\r20.0\enu\

Right click on the folder and set to “Merge with Local”. Do the same for its parents up the tree.

What’s up with that? It seems that the runtime will add a couple of DLL files into that folder the first time the user opens a drawing. Somehow it manages to do this outside of the virtual environment, so the package folder hides it and you get prompted with an error that it can’t find the dll. Who the h3ll puts dlls in the user’s appdata roaming folder? What were they thinking over there?

Step 13.  Finishing off.

Clean up your shortcuts and FTAs as desired. I went to the advanced box and checked all three options. Did I need to? I don’t know, but it worked. You should probably try it without.

Here is a summary of the package contents, taken from AppV_Manage:

By Tim Mangan

Tim is a Microsoft MVP, and a Citrix CTP Fellow. He is an expert in App-V and MSIX.