Visual Studio Setup Project: Application Folder - Default Location - visual-studio

In a visual studio setup project, is there a way I can enumerate the logical drives on the target machine and set a path on a drive on which windows is not installed as the value of the property "DefaultLocation" for the Application Folder instead of the usual [ProgramFilesFolder][Manufacturer]\[ProductName] ? Or is there a way I can force the users to select the installation path on a drive other than the windows drive, without which the installation should not proceed?
Thanks in advance.

No, not in a Visual Studio setup project. There is no support for running any code during the UI sequence, and so there is no way to check the user's input if offered a dialog to choose the location.
Is there a problem you're trying to solve and this is the solution you've chosen? It's not clear why the standard location in Program Files is unacceptable.
If you were willing to force the issue you could write a launch program that would find the drive and then install the MSI (omitting the destination folder dialog) with a command line that includes TARGETDIR=[folder path for install]

Related

How to update web-installed Microsoft Visual Studio 2017 offline (saved layout)?

I have Visual Studio 2017 which was installed from the web.
Meanwhile, the corporate firewall rules changed and it's no longer possible to update the installation (download.visualstudio.microsoft.com is blocked).
At home I was able to download a complete Visual Studio 2017 layout to an external drive.
Now, how can I instruct Visual Studio Installer to use the external drive layout instead of trying to download from the web?
After googling a bit, I found some clues here and there, but never got a direct answer. I had to do some experiments until I found a very simple solution:
Open folder C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances (or equivalent in your machine). This folder should contain a subfolder with the VS2017 instance GUID (from now on referred to as VS_GUID). Note: ProgramData is a hidden folder.
(Optional) Create a backup of file C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances\{VS_GUID}\state.json in another directory of your choice.
Edit file C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances\{VS_GUID}\state.json (note: VS_GUID is the sub-folder name found in step 1)
and change layoutPath to your local layout folder and installChannelUri to the full path to ChannelManifest.json (which should be present in the layout folder root).
Example (when layout path is D:\vs2017layout):
(...)
"layoutPath":"D:\\vs2017layout",
"installChannelUri":"D:\\vs2017layout\\ChannelManifest.json"
(...)
Save state.json and launch vs_professional_xxxxxxxxx.yyyyyyyy.exe (or equivalent) which is located in the layout folder. If it detects the updated installation files then the "download" progress should move to 100%.
This worked for me.

Visual Studio 2015 Update 3 installation failed

I have a problem with installation Visual Studio Professional 2015 Update 3. I don't know what cause the problem, but setup is failed every time in each setup configuration. Setup manager shows me following error and warning:
Microsoft Visual Studio Services Hub
The system cannot open the device or file specified
I really don't know how to solve this problem. Does anyone know what is wrong and how can I install this program?
Greetings
SOLUTION
I know what was the problem! I didn't check thoroughly the default location where Visual Studio wants to install. On my PC I have installed a 64-bit Windows 7. After many tries of installation I saw that installator chose wrong Program Files folder. It tries to install Visual Studio in Program Files (x86) (dedicated for 32-bit programs). I really don't know why VS installator chose a default folder for a 32-bit programs while my VS is a 64-bit version and also Windows is a 64-bit version.
I hope that this solution will help someone who has the same problem.
Most likely this is because of Windows Installer cannot access the %TEMP% folder (I had similar error once, but with MSSQL setup). So:
First of all check if you %TEMP% environment variable points to the
right location
Then check if the account which is running VS setup has privileges to
access TEMP folder. Better yet, make sure you run setup as
administrator
Finally make sure you have disabled all disk or folder encryption
features
Also just to be sure disable any antivirus software you have running
The error message “The system cannot open the device or file specified” often related to the specific folder is encrypted, you can have a look at this article and try the following methods:
Save the VS installer file to a folder that is not encrypted
Install the VS to a folder that is not encrypted
Turn off encryption on the %temp% folder
To check the encryption of the specific folder, you can right click the folder and select ‘Properties’— ‘General’ tab, click ‘Advanced’ button and confirm the checkbox of ‘Encrypt contents to secure data’ is checked or not.
You can click the ‘log file’ in the VS installer screen that you shared, and find the specific folders that these 2 components ‘Microsoft Visual Studio Services Hub’ and ‘Visual C++ IDE Common Package’ stores and check if those folders are encrypted or not.

Force extension installation in Visual Studio

We're working in quite a large project and is having a hard time getting people to configure their Visual Studio correct (tabs instead of spaces etc.). We found a great solution in using the EditorConfig extension for Visual Studio.
However there are still some developers that seems to ignore our request to install this extension to their Visual Studio and hence I'm wondering if there is any way to force an extension to be installed before a solution can be opened, maybe some setting in the .sln file?
No there is no such option built-in. If your machines are domain joined, you could push out the installer through System Center or domain logon scripts.
You could cheat and create a solution level pre-build step. Create a target file named: before.{solutionname.sln}.targets and store it next to your solution file. Check it into source control. In the targets file you can use standard MsBuild to see if the extension is installed (you'll need to check the file system probably) and if not present force the installation by calling vsixinstaller.exe to trigger the install.

add own path to the targetpath during installation

I want to attach my own folder name to the "DefaultLocation" during msi installation (using VS 2005). Currently all programs installs at "C:\Program Files (x86)". I want to append some "xyz" path to the installation path during installation. So, once the user clicks next, the path for the installation should be "C:\Program Files (x86)\xyz".
Can anyone tell me how to do this in the windows installer.
The short answer is no, because here is nothing in Visual Studio setup projects to support that. You'd need the ability to change the target directory in the UI sequence after that dialog, that's what's missing.
VS setup projects are limited in their support for all the features of Windows Installer, so migrating to a different tool would be useful if this is the kind of customization you're looking for.
Could anyone tell you how to do this in Windows Installer? Technically yes. You'd need somebody who knows enough about the insides of MSI files generated by VS to design a solution (a custom action based off the Next button?) and change the MSI file manually to do it, and how to repeat that after every build (a post build script), and for you or your company to understand enough to fix it if it stops working. That doesn't seem practical compared to just using a tool that will let you do it. My apologies for the editorial but if VS doesn't support it your choices are limited.

Installation of demo project - best practices

Using Windows Installer (targeting XP and Vista), is there a best practice for installing demo projects and files with your application?
From experience installing on Vista/XP I would recommend...
1, Install the source code/project/solution files into the 'Users' directory for Vista. That way when the user opens up the demo and compiles they have write access for generating the output files. If you put the files into the 'Program Files' directory under Vista you do not have write access and so the compile will just fail.
2, Add a shortcut to the solution to either the desktop or the start menu so that the user can then get access to it without having to know the exact location. Under Vista/XP when you install into the 'Users'/'Documents and Settings' directory it is not easy to find the installed files because they are placed inside a directory that is not shown unless you select 'Show Hidden Files' in file explorer.
3, I would recommend you sign the installer using your publisher certificate so that when the user gets a UAC dialog on Vista they can see the name of the publiser and be more likely to continue with the process.
4, At the moment the split between Visual Studio 2005/2008 is about 50%/50% and so make sure you provide both versions of the project/solutions files. Alternatively just supply the VS2005 files and let the user upgrade using the wizard in VS2008.

Resources