VDPROJ auto upgrading vs. uninstall/reinstall - installation

I've seen a confusing behavior regarding the MSI files generated by a VDPROJ file. If I build my MSI in Visual Studio and then right-click and pick "Install" from within Visual Studio, it will automagically uninstall any version that is already installed and then install the new MSI.
However, if take the generated MSI and run it directly it will complain if a previous version is already installed. I have to uninstall it explicitly (in Add/Remove Programs) first.
What's the deal? Is there a command-line argument that Visual Studio executes the MSI with?

Yes Visual Stuido will be passing the REINSTALLMODE and the REINSTALL properties to the windows installer when it runs your install
something like:
msiexec /i your.msi REINSTALLMODE=vomus REINSTALL=ALL
Check the MSDN documents linked above to see what these options are doing
Edit:
Now I come to think of it. Studio may also just be uninstalling your application first by using the /x command line arg
msiexec /x <package> or <product code>
Maybe someone else can confirm which is being used?

Related

How do I fix visual studio installer (2019 community) is empty?

I downloaded the visual studio 2019 community installer and ran it. It ran successfully but instead of opening the visual studio installer when it completed it just closed. I located the visual studio installer 'setup.exe' (under C:/Program Files (x86)/Microsoft Visual Studio/Installer) and ran it. It opens the installer but instead of allowing me to select tools to install it just has 2 empty tabs labeled 'installed' and 'available' and a side bar that shows developer news.
I don't have any antivirus or firewall running. I uninstalled every version of visual studio I had in case the installer was assuming I already have VS2019. I updated windows and my drivers.
EDIT:
I had a hunch that I might find something out by using 'setup -h' in command prompt. It appears that it may be possible to install vs2019 by using the right tags.
I guessed
setup install --productid Microsoft.VisualStudio.Product.Community --channelid VisualStudio.15.Release
might work but the installer says "
A product matching the following parameters cannot be found:
channelId: VisualStudio.15.Release
productId: Microsoft.VisualStudio.Product.Community
"
If you know what the right tags are that might be an adequate solution.
Please try to reinstall it:
1) run cmd as Administrator and then type:
"%programfiles(x86)%\Microsoft Visual Studio\Installer\resources\app\layout\InstallCleanup.exe" -full
2) restart vs_installer again.

How to Install the Visual C++ Redist Using NSIS

My C++ application needs to install the Visual Studio C++ redistributable. I'm using Visual Studio 2019 Community edition. I use NSIS (version 3.04) to create my install program. Should I try to detect if the redist is installed and only install it if it is not up to date?
There are a melange of answers about how to do this, including many methods of how to detect if the redist is installed. I'm not going to say that all of them are incomplete and don't work in a future proof method, but I have not had success with them. So, I think the best thing to do is just install the redist always and let Microsoft take care of it. As of March 2020 this will add 14MB to your installer program, but maybe in this age of high speed Internet that isn't the big deal it once was. Luckily this is quite simple, and hopefully this question will keep you from following all the dated references and links that I did.
Instructions on the redist from Microsoft can be found here: Redistributing Visual C++ Files
To turn this into NSIS:
Find the file you want to redistribute in your Visual Studio install. For me this is:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Redist\MSVC\14.25.28508\vcredist_x86.exe
The version number is definitely subject to change (14.25.28508) in the future, likely just when you install updates to Visual Studio, so remember that you'll need to update that path when your install program breaks. You'll also need to choose between vcredist_x86.exe and vcredist_x64.exe depending on whether your build your application as 32-bit or 64-bit.
Add a section like this to your NSIS install file, probably before you do the main installation. All it does is copy the redist file into the filesystem, run it, wait for completion, then delete the redist file.
Section "Visual Studio Runtime"
SetOutPath "$INSTDIR"
File "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Redist\MSVC\14.25.28508\vcredist_x86.exe"
ExecWait "$INSTDIR\vcredist_x86.exe"
Delete "$INSTDIR\vcredist_x86.exe"
SectionEnd
Substitute the proper path for the redist file you want to use.
As written (and current redist program behavior), this will pop up a dialog that the user will have to follow through to install the redist. You can substitute quiet mode:
ExecWait '"$INSTDIR\vcredist_x86.exe" /quiet'
However I did not have good results with that. YMMV.
to get the additional switches to work you include them within the quotes.
so the above ExecWait command would be the following:
ExecWait "$INSTDIR\vcredist_x86.exe /install /quiet"
I am using this currently, however with the "/quiet" switch the actual NSI installer progress hangs until redist is installed.
Using "/passive" instead will give a progress report on the redist installation
I agree with gdunbar that detection methods are both complex and not so reliable, good summary of such methods is in this thread: Detect if Visual C++ Redistributable for Visual Studio 2012 is installed
However I didn't want to always include the VC redist in the installer, as it significantly increase installer size (e.g. VC++ 2019 redistributable is 24Mb, while my installer without it was 1Mb). So I ended up using what I think is quite reliable method of trying to run the executable, and downloading installer on the fly if needed. Below the details for VC++ 2019 redistributable:
Create console windows app, e.g. Visual Studio 2019 wizard create this code:
#include <iostream>
int main()
{
std::cout << "Hello World!\n";
return 0;
}
The size of this app is 12K (compiled with "Favor small size" option).
Using the following code in NSIS to run it and download the installer if needed:
InitPluginsDir
;the hello word console app
;need to use nsExec plugin to prevent error popup (if redist is missing)
File /oname=$PLUGINSDIR\checkRedist.exe checkRedist.exe
nsExec::Exec '"$PLUGINSDIR\checkRedist.exe"'
Pop $0
${If} $0 != 0
DetailPrint "VC++ Redistributable package is missing!"
inetc::get "https://aka.ms/vs/16/release/vc_redist.x64.exe" $PLUGINSDIR\vcredist.exe
DetailPrint "Installing Visual Studio Redistributable package..."
ExecWait '"$PLUGINSDIR\vcredist.exe" /q /norestart'
DetailPrint "Done"
${Else}
DetailPrint "VC++ Redistributable already installed"
${EndIf}

Visual C++ Build Tools 2015 inside containers and custom directory

Did anyone manage to:
install Visual C++ Build Tools 2015
inside Windows container
and in a custom directory?
Whatever I do, it always installs to standard location: C:\Program Files (x86)\Microsoft Visual Studio 14.0
Below is the example Dockerfile to demonstrate that it silently ignores /CustomInstallPath parameter:
FROM microsoft/windowsservercore:ltsc2016
# download installer
ADD https://go.microsoft.com/fwlink/?LinkId=691126 visualcppbuildtools_full.exe
# install
RUN cmd /c visualcppbuildtools_full.exe /Passive /CustomInstallPath C:\BuildTools
# test
RUN dir C:\BuildTools
I've tried with microsoft/nanoserver base images too, can't install at all.
I've tried installing via Chocolatey which also allows passing /CustomInstallPath, same result.
There are some discussions where people recommend fully uninstalling VS and anything related, but here I'm using a completely standard image, so it shouldn't matter. Anyway I've tried calling /uninstall first - didn't help.
AFAIK some components of the BuildTools "package" will always go in %ProgramFiles(x86)% no matter what (i.e. the C++ compiler).

How to install redistributable with visual studio setup?

I wish to make my installer (visual studio setup) to install redistributable (Visual C++ 2013 redistributable x86) in case it isn't installed on the PC or install the necessary dll for my program. I don't wish to set a launch condition.
If possible, I wish that the installation of the redistributable to be silent.
Any suggestion ?
That's what the Prerequisites button is for in the setup project's Properties. You'll need to set a configuration (such as Release) before you see that button. That's where you add the VC++ runtimes. That will generate a setup.exe that users run - it will install any of those prerequisites and then install your MSI file.
To make it silent you'd need to get into the manifest file that describes the command used to install the runtime, and change it to a silent command. There used to be a tool called the Bootstrap Manifest Generator that would do that kind of thing, if you can still find it.
There's no support I know of for any of the following, but this is how the VS bootstrapper works, so mangle at your own risk :)
You could open the built setup.exe as a file with Visual Studio and examine the resources - under 41 there's a setupcfg that's the specicification for the prereqs. You'd need to export it, alter it and re-import it.
Alternatively, the template for the standard prereqs that this uses comes from the SDK in architecture-dependent locations such as Program Files (x86)\Microsoft SDKs\Windows\v8.1A\Bootstrapper\Packages\vcredist_x86\product.xml so if you go in that Xml file and find the correct VCRedistInstalled settings and command lines, make it silent, and it should propagate into the setup.exe when you do the build. This is unsafe because a) you've altered a file so that will now not be updated by any SDK updates b) The file doesn't match the one installed by the SDK and there may be installer repair issues and c) Every bootstrapper build will be affected.
You can use Merge modules and add it to your setup/msi which will install quietly

Visual studio does not install .vsix files

I've both VS 2012 and VS 2013 installed on my computer. The problem is that when I download an VSIX-File and open it with the Visual Studio version selector the file gets opened by VS but instead of installing it. VS opens the file as if it was an unknown binary format.
The attached image shows how VSIX-files are opened (happens with every file ... this is just an example):
I faced the same issue. Just use the VSIXInstaller to install the extension.
You can open "Developer Command Prompt for VS2012" tool in Start -> Microsoft Visual Studio 2012 -> Visual Studio Tools. On the console, run the below command:
VSIXInstaller <path to vsix file>
Open "Developer Command Prompt for VS2015" as administrator.
Type VSIXInstaller.exe vsixFilePath
Note that this way wouldn't work with me and gives me "Path to vsix file 'G:\Roslyn' is invaild or you don't have required access permissions". To solve this you need to put the path in a double quote like this:
VSIXInstaller.exe "G:\Roslyn SDK.vsix"
I got into a weird situation where in a fresh install of W10 and VS2015 Community, the Player Framework vsix installation won't start, either by dbl click or from command prompt using VSIxInstaller.exe, and would show no message at all. The solution was to open an elevated command prompt (run Developer Command Prompt for VS2015 as administrator) and then type VSIXInstaller.exe worked.
I am not clear whether you want to install or just view the contents of VSIX. If you want to install the extension, you just need to double click it and it will install (Do not try to open it with VS Version selector). If you want to see what is inside VSIX, it is basically an archive. So either try to use program like 7-zip to open it else, rename .vsix to .zip and then unzip it.
Further, there is also a chance that you have wrongly associated vsix files to be opened with Visual Studio. In such a case it will open in Visual Studio any case.
Finally, if you have wrongly associated the vsix to open with Visual Studio, try installing the extension using VSIXInstaller.exe found in C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\VSIXInstaller.exe
To add to the other answers, if the VSIX files either doesn't have an associated program to open with or opens with the wrong application, selecting the VSIXInstaller.exe as the associated commands re-enables the ability to double-click and directly install it (without the need to do it via commandline).
I faced a similar issue when I first installed VS 2017. This is what worked for me.
Resolution:
Restart VS 2017.(I hadn't restarted it before installation)
Install it from Tools->Extension & Updates.Search for "Perforce" and install.
I double clicked on this and it installed just fine.
Couldn't do it on VS2013 through the extensions dialog.
for me the problem was the extension InstallerProjects was on network server so I had to copy it to my machine (local) and it worked

Resources