MS-Build returning the visual studio installation path - visual-studio

How can the entry
<MsTestExePath>$(MSBuildProgramFiles32)Microsoft Visual Studio 14.0\Common7\IDE\mstest.exe</MsTestExePath>
in a .proj file be generalised, such that the build works for different licenses of Visual Studio 2019 as well, where mstest.exe is located at
C:\Program Files (x86)\Microsoft Visual
Studio\2019\Enterprise\Common7\IDE\MSTest.exe
in the case of an enterprise license?
The most generic solution may be to replace the variable parts of the path with msbuild macros, but which ones would that be?

According to this documentation,
The macro
$(VSInstallDir)
returns the path to the installation folder of the Visual Studio version currently used.
The following entry should therefore work for all versions of visual studio, for which mstest.exe is located in the subfolder \Common7\IDE\ under the installation directory:
<MsTestExePath>$(VSInstallDir)Common7\IDE\mstest.exe</MsTestExePath>

Related

Can Visual Studio C++ header/lib files be used to build on a machine without Visual Studio installed?

I am attempting to cross-compile a Windows application on Linux using Clang, and based on their CMake file, it looks like I need to copy the header and lib files from a Visual Studio installation. I have Visual Studio 2015, but it looks like the list of redistributable files doesn't include those. They are in "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include" for me, and that's not on the list. So, am I allowed to use those header/lib files on a machine that doesn't have a Visual Studio license, or is there some other way to get these files?

How to Enable WiX Projects in Visual Studio 2017

In Visual Studio 2017's New Project dialog, there is no entry for Windows Installer XML (WiX).
Is it possible to enable WiX projects in Visual Studio 2017?
You can manually enable Visual Studio 2017 compatibility with WiX 3.10 or earlier:
Close all instances of Visual Studio.
Copy
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\WiX to
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\Microsoft\WiX
(In the destination path, replace "Enterprise" with "Professional" or "Community" depending on your edition.)
You may need to provide Administrator permission:
The result will look like this:
Copy C:\Program Files (x86)\MSBuild\Microsoft\WiX to C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\WiX
Then execute the following command as Administrator:
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\devenv" /setup
(Again, replace "Enterprise" with "Professional" or "Community" depending on your edition.)
When you open Visual Studio 2017, WiX 3.10 and earlier projects will be compatible.
WiX v3.11.0.1507 provides full support for the VS 2017 Extension For WiX.
The Release Notes provide insight into why it has taken so long to provide the extension and compatibility with the extension and older versions of WiX
Note: You can use the "WiX Toolset Visual Studio 2017 Extension" with previous versions of the WiX Toolset but there is a forwards compatibility issue when building managed custom actions that is only fixed in the WiX v3.11 RC release. In other words, if you have managed custom actions and you want to use VS 2017 then you must upgrade to WiX v3.11 RC.
Edit:
The VS 2019 Extension is now available.
Edit:
The VS 2022 Extension is now available.
The Wix Releases Page has links to the other extensions.
I found that I also had to copy the WiX folder from "C:\Program Files (x86)\MSBuild\Microsoft" "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft". Without this, I got an error trying to load my WiX project that one of the MSBuild targets files couldn't be found.
WiX now offers support for Visual Studio 2017.
All you have to do is:
Close Visual Studio 2017
Install the WiX Toolset Build Tools
Install the WiX Toolset Visual Studio 2017 Extension
The answer by Chris works, but on my machine, for some reason, the Wix folder in "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\WiX" had only one template named "CustomActionCPP.zip". I had to search for a complete Wix folder in other older versions of Visual Studio. It worked for me by copying Wix from "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\WiX\ProjectTemplates".
Also, had to apply the answer by Basim, by copying Wix from "C:\Program Files (x86)\MSBuild\Microsoft" to "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft".
I have installed ONLY VS2017 and had to copy from another machine where VS2015 was installed the mentionen folder of #Chris Schiffhauer. The same for the folder of #Basim mentioned.
Addiontally I had to copy the "C:\Program Files (x86)\Wix Toolset 3.10\" because when I have installed WiX on my machine in this folder were still some assemblies missing.
Install the Wix Toolset Visual Studio 2019 Extension and reload the project
right-click the project folder in the path and uncheck the read-only
after install the Extension reload the Wix
use the below URL download
https://marketplace.visualstudio.com/items?itemName=WixToolset.WixToolsetVisualStudio2019Extension

Why does 'iprtrmib.h' in Window Kits 8.0 reference 'mprapidef.h' in window 'kits 8.1'?

I am using Visual Studio 2012 (Update 5) with MS Window Kits 8.0 and .NET Framework 4.5.51209. Recently, I also installed MS Window Kits 8.1.
Now, I have a file: '\windows kits\8.0\include\shared\iprtrmib.h' that failes to include 'mprapidef.h'.
That include file only exists at: '\Windows Kits\8.1\Include\shared\mprapidef.h', which is not in my include path.
My Visual Studio 'Include Directories' is set to: "$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);".
These are my Visual Studio macros:
VCInstallDir: C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\
WindowsSDK_IncludePath: C:\Program Files (x86)\Windows Kits\8.0\Include\um;C:\Program Files (x86)\Windows Kits\8.0\Include\shared;C:\Program Files (x86)\Windows Kits\8.0\Include\winrt
When searching, I found a slightly similar question: missing header file on a new installation of visual studio 2012
I tried repairing my Visual Studio installation. I do not want to change the 'Include Directories' for each of my projects. What else should I try?
I installed vs2015 and vs2012, then the same problem occurs,however, I find a solution.
open visual studio project settings,click VC++ Directories, find Include Directories,add the following line to it.
C:\Program Files (x86)\Windows Kits\8.1\Include\shared
One may add the corresponding 8.1 paths to the environment variable.
Maybe it's necessary to do the same thing with the lib environment variable (WindowsSDK_LibraryPath_x86).

How does Windows know what version of Visual Studio a .sln file relates to?

If I have a VS 2005 solution then it shows up as "Version: Visual Studio 2005". If I have a VS 2010 solution, the sln file shows up as related to that.
Both of them have a .sln suffix. So how does Windows know which version of VS to open it with?
It uses Property Handler and Icon Handler shell extensions (part of the Visual Studio Version Selector)
These are registered by the registry key HKEY_CLASSES_ROOT\VisualStudio.Launcher.sln (referenced by HKEY_CLASSES_ROOT\.sln)
When you open the file, it runs "c:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv\VSLauncher.exe" "%1", which reads the version from the .sln file and open the correct version.

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