Visual Studio installer project - keep file while uninstall - visual-studio

I am using Visual Studio Installer Projects to generate MSI files, it includes create log folder when it doesn't exist. When uninstall the program, that log folder and files inside will also deleted. Is there a way to keep those log folder and files during uninstall?

Related

Installing Visual Studio Installer Projects extension offline

The Microsoft Visual Studio Installer Projects web pag at VisualStudio Marketplace has a Download button for offline installation, but the resulting file is a compressed file InstallerProjects.zip which contains lots of different folders and files but no installation instructions. How do I install this extension?
Even though the file is called InstallerProjects.zip, it is actually a .vsix file and can be installed as explained in this answer:
There is an app called: VSIXInstaller.exe. Its exact location depends on which version of Visual Studio you are using; for me it is located at
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE
Right-clicked on the extension file > Open-With > Choose Default Program > More Options > Scroll down to 'Look for another app on this PC' > navigate to the location of VSIXInstaller.exe and select it.

How to install vstest.console.exe offline

I am supposed to do an offline installation of vstest.console.exe in the folder path as follows: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow
I have tried using offline packages such as vs_testagent.exe and vs_testcontroller.exe according to the following link: https://learn.microsoft.com/en-us/visualstudio/install/create-a-network-installation-of-visual-studio. However, these packages do not contain vstest.console.exe.
I am also unable to do a full installation of VS2017 due to space issues. Do anyone have any suggestions? Thanks.
Download the nuget package: Microsoft.TestPlatform, rename it a zip file. Open the zip file, you will find all you need from this folder: .\tools\net451\Common7\IDE\Extensions\TestPlatform, including vstest.console.exe, testhost.**.exe, QTAgent.exe, datacollector.exe.
If you added the nuget package to project, it just downloads the package to packages folder and won't complie to bin, so you have to add a Post-Build event to copy files to bin folder from the packages folder.
You are looking for "Build Tools for Visual Studio" (Microsoft login required). It will give you an installer "vs_BuildTools.exe", which will install by default the build tools in:
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools
(by default)
Two versions of vstest console were installed when I ran it:
...\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe
...\Common7\IDE\Extensions\TestPlatform\vstest.console.exe
I do not know why, nor how they are different. I use the first one.
I used the chocolatey package visualstudio2019testagent to install VS 2019 Test Agent.
Not sure if this would help someone in the future.
Download the Visual Studio Build Tools installer from https://my.visualstudio.com/Downloads?q=build%20tools%20for%20visual%20studio
Run the installer, click the tab Individual components and select Testing tool core features - Build Tools
After installation the vstest.console.exe is located in folder
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\IDE\CommonExtensions\Microsoft\TestWindow

How to delete installation directory when program is uninstalled by visual studio installer project?

I have created an installer using visual studio 2010 installer project. The program installs correctly and works fine for all the features.
But the problem is in uninstallation, when I uninstall the program it does not delete the application directory from file system but deletes the contents of it.
Suppose I am installing the program in C:\Program Files\MyApp, it deletes the contents of MyApp folder but doesn't delete the folder it self.
Any way to do this? If there is a way then how to do this?
Does your application create files in this directory after it's been installed? If so, you might want your app to move that user-data to a more user-data-centric location like %PROGRAMDATA% so that application files and user-data are separated.
It also helps to make sure uninstall cleans up everything, and it's easier to persist user-data across upgrades.
Relevant thread - http://www.itninja.com/question/delete-folders-after-uninstall

Visual Studio Installer Sub-directory

I am building an install msi using the Visual Studio 2010 installer.
I need to add files to a subdirectory of my installation. I know about the Add Files function but that will add them to the main directory. I don’t see how to add them automatically to a subdirectory. In my case it is the /Report subdirectory.
Right-click your Installer project, go to View->File System.
Now right-click on the 'Application Folder' and select Add->Folder (see screenshot below). Name your folder 'Reports' or whatever you need.
Done.
Now you can place your files under [Application Folder\Reports] on the target machine.

How can I delete bad Visual Studio templates?

How do you remove the following noise templates that don't even work?
In Visual Studio: go to Tools > Extensions and Updates and then uninstall or disable the template.
To save a bit of time for 2010 users, the folder has moved:
...\My Documents\Visual Studio 2010\Templates\ProjectTemplates
For Visual Studio 2013, I found my template cache here:
%USERPROFILE%\AppData\Roaming\Microsoft\VisualStudio\12.0\ProjectTemplatesCache
Deleting them off of disk should do the trick. Where they exist will depend a bit on where you installed them. If you installed them for all users they will be at
%ProgramFiles%\Microsoft Visual studio 9.0\Common7\Ide\ProjectTemplatesCache
For a single user they will be at
%USERPROFILE%\Visual Studio 2008\Templates\ProjectTemplates
EDIT
If InstallVSTemplates fails, it is likely one of the following. The one I can't help with is some program randomly dumping files inside of the ProjectTemplatesCache directory.
The other more likely cause is there is a bad template in the ProjectTemplates directory. InstallVSTemplates really just goes through this directory, and unzips all of the files into the ProjectTemplatesCache directory. You will have to search through this directory and find the .zip file which contains the junk files being added to your project Once you find the file, delete it, delete ProjectTemplatesCache, and then re-run InstallVSTemplates.
After manually searching for some of the custom profile templates(.vstemplate),I found them at the following location:
%userprofile%\AppData\Local\Microsoft\VisualStudio\10.0\Extensions
It appears VS2010 installs some of the templates as extesions or the authors made it that way.I hope this helps someone.
May need to run "devenv /setup" at the run command to refresh the VS2010 after you delete the templates.
For me it was a matter of removing it from here using VS2017:
%USERPROFILE%\AppData\Roaming\Microsoft\VisualStudio\15.0_45552a03\ProjectTemplatesCache
Delete the bad/unwanted project folders from
C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplates
Clear cache
C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplatesCache
Delete stuff from (perhaps not necessary)
C:\Users[Your User Name]\Documents\Visual Studio 2008\Templates\ProjectTemplates
and finally open Visual Studio 2008 Command Prompt as Administrator and run
devenv /installvstemplates
For me the issue got resolved when I deleted the cache.bin file from ItemTemplatesCache folder. Full path of this folder is:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplatesCache
Also make sure you delete the template files from below locations:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplates
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplatesCache
C:\Users\Default\Documents\Visual Studio 2010\Templates\ItemTemplates
C:\Users[NT-USERNAME]\Documents\Visual Studio 2010\Templates\ItemTemplates
For Visual Studio 2019:
Extensions > Manage extensions > Installed > Uninstall
Worke for VS 2012 and 2015 :
In Visual Studio: go to Tools > Extensions and Updates and then uninstall or disable the template.
worke in VS 2019 :
1- In VS2019, custom templates can be removed by deleting the template folder from %USERPROFILE%\AppData\Roaming\Microsoft\VisualStudio{VSVersion}\ProjectTemplatesCache. Look for a {VSVersion} that begins with "16".
https://i.stack.imgur.com/V6SQ5.png
2- Delete What You Want From Templates Folder in {C:\Users\USERName\Documents\Visual Studio 2019\My Exported Templates}
Notes :
{ProjectTemplatesCache} Or {ItemTemplatesCache}
https://i.stack.imgur.com/9BM9p.png
For Visual Studio Express 2010 you should delete all folders under
%USERPROFILE%\AppData\Local\Microsoft\VCSExpress\10.0\Extensions
For Visual Studio 2013 Community, you have to delete {program folder}\Common7\IDE\ItemTemplatesCache\cache.bin after deleting all the unwanted files as described above. Afterwards VS will rebuild the templates listing in the New Project... dialog.
You could also try this:
dotnet new --uninstall <PATH|NUGET_ID>
It works for me in VS 2019 and VS 2022 to uninstall the Avalonia templates.
Description
The dotnet new --uninstall command uninstalls a template package at the PATH or NUGET_ID provided. When the <PATH|NUGET_ID> value isn't specified, all currently installed template packages and their associated templates are displayed. When specifying NUGET_ID, don't include the version number.
Examples
Uninstall the Avalonia templates
dotnet new --uninstall Avalonia.Templates
From MicrosoftDocs
If the template was installed by double clicking a VSIX file, it is considered an extension and can be uninstalled using the technique described by Hamid Behnam above. Otherwise, it can be deleted from one of the template directories mentioned above.
It looks like in each case we use different recipe. Unfortunately, commands line and VS menu command listed in this thread did not work in my case, which is MS VS 2019 Community Edition on Win7 x64:
First, close VS, remove unwanted *.zip files from all following folders, as well as hidden cache.bin file from the last \ProjectTemplatesCache folder (it will be restored at VS startup), then restart VS. Here are those 3 folders:
{Documents}\Visual Studio 2019\My Exported Templates
{Documents}\Visual Studio 2019\Templates\ProjectTemplates
{User}\AppData\Roaming\Microsoft\VisualStudio{Number}\ProjectTemplatesCache

Resources