1

Closed

VS2012 randomizes the installation directory of a VSIX

description

Issue
In VS2010, the VSIXInstaller.exe program which is used to install VSIXes uses a deterministic algorithm to calculate an install path for a VSIX extension, in the format: %localappdata%\Microsoft\VisualStudio\10.0\Extensions\<Extension.Author>\<Extension.Name>\<Extension.Version>
When VS2012 is installed on a machine, the VSIXInstaller.exe program is upgraded and takes responsibility for installing VSIX extension for both VS2012 and VS2010 extensions. It uses a non-deterministic algorithm to calculate an install path for an extension, in the format: %localappdata%\Microsoft\VisualStudio\1X.0\Extensions\<RandomIdentifier>

A Pattern Toolkit Project (.csproj) built with NuPattern, imports a .targets file which ultimately resides in the installation directory, but is referenced by an intermediary *.targets file in a known, deterministic (and version independent) location: %localappdata%\Microsoft\MsBuild\NuPattern\NuPattern Toolkit Builder VS201X. The version independent *.targets file has MSBUILD variables defined in it that import the patterntoolkit.targets file from the VSIX installation directory.

When installing in VS2010 (standalone), these paths were known before installation time. But when VS2012 is installed on the machine (in either standalone or side-by-side with VS2010) these paths cannot be known before installation.

The impact of this is that , when VS2012 is installed on the user's machine, pattern toolkit projects will not load in VS.

Resolution
The version independent .targets file is automatically written and updated by the NuPattern Toolkit Builder extension, when it first starts up in VS. This component will now need to calculate the installtion paths by querying VS as it starts up, and write these variable paths into the .targets file, instead of determining them before installation.

With this resolution in place, a further arises when VS2010 and VS2012 are installed on the same machine side-by-side.
When VS (either version) starts up the NuPattern Toolkit Builder extension verifies that the version independent *.targets file is up to date and rewrites the installation paths of the 'NuPattern Toolkit Builder' extension as it is installed for that version of VS. Which means that the last version of VS to startup overwrites the previous settings.
This means that if a user starts both VS2010 and then VS2012 at the same time, then the last version to start and re-write the file wins. If the first version of VS has a pattern toolkit project loaded, the project will fail to load or compile. This will confuse the user. The scenario is perhaps unlikely, but one possible workaround is to have seperate versions of the version independent *.targets (in different folders, named according to VS version NuPattern installed), and the pattern toolkit project could reference either one depending on which version of VS they are targeting. This makes creating a multi-targeted pattern toolkit slightly harder for the author, as the path to the version independent targets file is dependent on the version of VS.
Closed Apr 27, 2013 at 2:04 AM by jezzsa

comments

jezzsa wrote Feb 10, 2013 at 7:50 AM

The randomization issue is fully resolved.

As far as the side-effect of possible collisions with the shared targets file, byt both VS2010 and VS2012 simultaneously. I have decided that the risk of opening VS2010 and VS2012 simultaneously AND having a pattern toolkit solution open in the first version opened; whilst possible, is probably unlikely.
And therefore, the current resolution should be sufficient in most cases.
If not, then we can pursue a better solution at a later date.
For now though, all pattern toolkit projects, in all versions of VS will share tehsame *.targets file.