Now that Microsoft .NET Framework 4.0 and Visual Studio 2010 have been released, developers may wonder how to detect them on the system. As with previous releases, we support registry detection of either product family and Windows Installer component detection for Visual Studio. Detecting either product uses a separate set of supported keys.
The .NET Framework has and continues to use registry keys and values under HKLM\Software\Microsoft\NET Framework Setup. To detect .NET Framework 4.0, you can check if the following key is present and the value is set to 1.
HKLM\Software\Microsoft\NET Framework Setup
The core .NET Framework 4.0 package is English, so 1033 is always available. To detect specific language support, see the LCIDs listed in the table of supported languages. You can also detect if the full package is installed, which includes the core (Client) and extended support, such as ASP.NET.
For more information, see the .NET Framework 4.0 deployment guide for developers. Administrators may be interested in the .NET Framework deployment guide for administrators.
The detection keys for Visual Studio are used both to detect if the product is installed and what service pack level is installed. As with previous versions, these keys and values are under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DevDiv\VS\Servicing.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DevDiv\VS\Servicing
The values for $(var.ProductEdition) include the following table. The for other products, this value corresponds to the ProductEdition property in the Property table of the Windows Installer package for that product. The locale IDs for $(Var.LCID) are listed here.
For Dev10 we have also added detection values to the edition keys so that you do not have to detect every single language for ever edition.
These registry keys and values are also used to detect the service pack level. Instead of checking for the Name registry value, check the SP registry value. Ignore SPIndex; Microsoft uses this internally. In addition to the registry keys above, we also set a version-dependent registry value listed below.
Keep in mind, however, that as with all shared resources the more shared a resource is the less accurate it may be. This is because there is no version policy for registry values and other resources that do not have versions like text files. If two languages were installed at different servicing pack levels – which is unsupported but possible – the value would be set by the last product to be installed or reinstalled (repaired).
For more information, see the Visual Studio 2010 detection system requirements. This also includes information to use the CompLocator in your Windows Installer package as an alternative to registry detection.
On all 64 bit platforms the path would be
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432node\Microsoft\NET Framework Setup\NDP\v4\Client
Note that the IntShell key does not have a detection value, so you must look in the $(var.LCID) key.
On Windows Server 2003 Enterprise x64 with Visual Studio 2010 installed there is no HKLM\Software\Microsoft\DevDiv\VS\Servicing\10 key. How do we detect the presence of Visual Studio 2010 in such a case?
@Jason Gibbons, on an 64-bit platform you need to check the WOW64 key: HKLM\Software\Wow6432Node\Microsoft\DevDiv\VS\Servicing\10.0. Most packages we chain are 32-bit installers. Onlky 64-bit packages will write to the native 64-bit key.