/// <summary>
 /// Gets the full path of .net framework sdk.
 /// i.e. "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\" for .net v3.5 on VS11.
 /// </summary>
 public override string GetPathToDotNetFrameworkSdk(VisualStudioSpec visualStudioSpec)
 {
     string pathToBinRoot = this.GetPathToDotNetFrameworkSdkTools(visualStudioSpec);
     pathToBinRoot = RemoveDirectories(pathToBinRoot, 1);
     return pathToBinRoot;
 }
 /// <summary>
 /// Gets the full path of .net framework sdk, which is the full path of .net framework sdk tools for v1.1 and v2.0.
 /// </summary>
 public override string GetPathToDotNetFrameworkSdk(VisualStudioSpec visualStudioSpec)
 {
     return this.GetPathToDotNetFrameworkSdkTools(visualStudioSpec);
 }
            /// <summary>
            /// Gets the full path of .net framework sdk tools for the given visual studio version.
            /// </summary>
            public override string GetPathToDotNetFrameworkSdkTools(VisualStudioSpec visualStudioSpec)
            {
                if (_pathToDotNetFrameworkSdkTools == null)
                {
                    _pathToDotNetFrameworkSdkTools = FindRegistryValueUnderKey(
                        dotNetFrameworkRegistryPath,
                        this.DotNetFrameworkSdkRegistryInstallationFolderName);
                }

                return _pathToDotNetFrameworkSdkTools;
            }
 /// <summary>
 /// Gets the full registry key of this .net framework Sdk for the given visual studio version.
 /// i.e. "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework" for v1.1 and v2.0.
 /// </summary>
 public override string GetDotNetFrameworkSdkRootRegistryKey(VisualStudioSpec visualStudioSpec)
 {
     return FrameworkLocationHelper.fullDotNetFrameworkRegistryKey;
 }
            /// <summary>
            /// Gets the full path of .net framework sdk tools for the given visual studio version.
            /// i.e. "C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\" for .net v4.5 on VS11.
            /// </summary>
            public virtual string GetPathToDotNetFrameworkSdkTools(VisualStudioSpec visualStudioSpec)
            {
                string cachedPath;
                if (this._pathsToDotNetFrameworkSdkTools.TryGetValue(visualStudioSpec.Version, out cachedPath))
                {
                    return cachedPath;
                }

                string registryPath = string.Join(@"\", MicrosoftSDKsRegistryKey, visualStudioSpec.GetDotNetFrameworkSdkRegistryKey(Version), this._dotNetFrameworkSdkRegistryToolsKey);

                // For the Dev10 SDK, we check the registry that corresponds to the current process' bitness, rather than
                // always the 32-bit one the way we do for Dev11 and onward, since that's what we did in Dev10 as well.
                // As of Dev11, the SDK reg keys are installed in the 32-bit registry. 
                RegistryView registryView = visualStudioSpec.Version == visualStudioVersion100 ? RegistryView.Default : RegistryView.Registry32;

                string generatedPathToDotNetFrameworkSdkTools = FindRegistryValueUnderKey(
                    registryPath,
                    this.DotNetFrameworkSdkRegistryInstallationFolderName,
                    registryView);

                if (string.IsNullOrEmpty(generatedPathToDotNetFrameworkSdkTools))
                {
                    // Fallback mechanisms.

                    // Try to find explicit fallback rule.
                    // i.e. v4.5.1 on VS12 fallbacks to v4.5 on VS12.
                    bool foundExplicitRule = false;
                    for (int i = 0; i < s_explicitFallbackRulesForPathToDotNetFrameworkSdkTools.GetLength(0); ++i)
                    {
                        var trigger = s_explicitFallbackRulesForPathToDotNetFrameworkSdkTools[i, 0];
                        if (trigger.Item1 == this.Version && trigger.Item2 == visualStudioSpec.Version)
                        {
                            foundExplicitRule = true;
                            var fallback = s_explicitFallbackRulesForPathToDotNetFrameworkSdkTools[i, 1];
                            generatedPathToDotNetFrameworkSdkTools = FallbackToPathToDotNetFrameworkSdkToolsInPreviousVersion(fallback.Item1, fallback.Item2);
                            break;
                        }
                    }

                    // Otherwise, fallback to previous VS.
                    // i.e. fallback to v110 if the current visual studio version is v120.
                    if (!foundExplicitRule)
                    {
                        int index = Array.IndexOf(s_visualStudioSpecs, visualStudioSpec);
                        if (index > 0)
                        {
                            // The items in the array "visualStudioSpecs" must be ordered by version. That would allow us to fallback to the previous visual studio version easily.
                            VisualStudioSpec fallbackVisualStudioSpec = s_visualStudioSpecs[index - 1];
                            generatedPathToDotNetFrameworkSdkTools = FallbackToPathToDotNetFrameworkSdkToolsInPreviousVersion(this.Version, fallbackVisualStudioSpec.Version);
                        }
                    }
                }

                if (string.IsNullOrEmpty(generatedPathToDotNetFrameworkSdkTools))
                {
                    // Fallback to "default" ultimately.
                    generatedPathToDotNetFrameworkSdkTools = FallbackToDefaultPathToDotNetFrameworkSdkTools(this.Version);
                }

                if (!string.IsNullOrEmpty(generatedPathToDotNetFrameworkSdkTools))
                {
                    this._pathsToDotNetFrameworkSdkTools[visualStudioSpec.Version] = generatedPathToDotNetFrameworkSdkTools;
                }

                return generatedPathToDotNetFrameworkSdkTools;
            }
 /// <summary>
 /// Gets the full registry key of this .net framework Sdk for the given visual studio version.
 /// i.e. "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.0A\WinSDK-NetFx40Tools-x86" for .net v4.5 on VS11.
 /// </summary>
 public virtual string GetDotNetFrameworkSdkRootRegistryKey(VisualStudioSpec visualStudioSpec)
 {
     return string.Join(@"\", HKLM, MicrosoftSDKsRegistryKey, visualStudioSpec.GetDotNetFrameworkSdkRegistryKey(Version), _dotNetFrameworkSdkRegistryToolsKey);
 }