Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / CompMod / System / CodeDOM / Compiler / RedistVersionInfo.cs / 1 / RedistVersionInfo.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.CodeDom.Compiler { using System; using System.Diagnostics; using System.IO; using System.CodeDom.Compiler; using System.Configuration; using System.Collections.Generic; using Microsoft.Win32; internal static class RedistVersionInfo { internal const String NameTag = "CompilerVersion"; // name of the tag for specifying the version internal const String DefaultVersion = InPlaceVersion; // should match one of the versions below //internal const String LatestVersion = "Latest"; // always bind to the latest version internal const String InPlaceVersion = "v2.0"; // always bind to Whidbey version internal const String RedistVersion = "v3.5"; // always bind to the Orcas version private const string dotNetFrameworkSdkInstallKeyValueV35 = "MSBuildToolsPath"; private const string dotNetFrameworkRegistryPath = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\3.5"; public static string GetCompilerPath(IDictionaryprovOptions, string compilerExecutable) { string compPath = Executor.GetRuntimeInstallDirectory(); // if provOptions is provided check to see if it alters what version we should bind to. // provOptions can be null if someone does new VB/CSCodeProvider(), in which case // they get the Whidbey behavior. if (provOptions != null) { string versionVal;//, newPath; if (provOptions.TryGetValue(RedistVersionInfo.NameTag, out versionVal)) { switch (versionVal) { //case RedistVersionInfo.LatestVersion: // always run against the latest version of the compiler // newPath = GetOrcasPath(); // if (newPath != null && File.Exists(Path.Combine(newPath, compilerExecutable))) // compPath = newPath; // break; case RedistVersionInfo.RedistVersion: // lock-forward to the Orcas version, if it's not available throw (we'll throw at compile time) compPath = GetOrcasPath(); break; case RedistVersionInfo.InPlaceVersion: // lock-back to the Whidbey version, no-op break; default: compPath = null; break; } } } if (compPath == null) throw new InvalidOperationException(SR.GetString(SR.CompilerNotFound, compilerExecutable)); return compPath; } /// /// this method returns the location of the Orcas compilers, but will return whatever /// version is requested via the COMPlus_ environment variables first /// private static string GetOrcasPath() { string dir = null; // if this is running in a private running environment such as Razzle, we would use the path // based on the environment variables: COMPLUS_InstallRoot and COMPLUS_Version. string comPlus_InstallRoot = Environment.GetEnvironmentVariable("COMPLUS_InstallRoot"); string comPlus_Version = Environment.GetEnvironmentVariable("COMPLUS_Version"); if (!string.IsNullOrEmpty(comPlus_InstallRoot) && !string.IsNullOrEmpty(comPlus_Version)) { dir = Path.Combine(comPlus_InstallRoot, comPlus_Version); if (Directory.Exists(dir)) return dir; } dir = Registry.GetValue(dotNetFrameworkRegistryPath, dotNetFrameworkSdkInstallKeyValueV35, null) as string; if (dir != null && Directory.Exists(dir)) { return dir; } return null; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.CodeDom.Compiler { using System; using System.Diagnostics; using System.IO; using System.CodeDom.Compiler; using System.Configuration; using System.Collections.Generic; using Microsoft.Win32; internal static class RedistVersionInfo { internal const String NameTag = "CompilerVersion"; // name of the tag for specifying the version internal const String DefaultVersion = InPlaceVersion; // should match one of the versions below //internal const String LatestVersion = "Latest"; // always bind to the latest version internal const String InPlaceVersion = "v2.0"; // always bind to Whidbey version internal const String RedistVersion = "v3.5"; // always bind to the Orcas version private const string dotNetFrameworkSdkInstallKeyValueV35 = "MSBuildToolsPath"; private const string dotNetFrameworkRegistryPath = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\3.5"; public static string GetCompilerPath(IDictionaryprovOptions, string compilerExecutable) { string compPath = Executor.GetRuntimeInstallDirectory(); // if provOptions is provided check to see if it alters what version we should bind to. // provOptions can be null if someone does new VB/CSCodeProvider(), in which case // they get the Whidbey behavior. if (provOptions != null) { string versionVal;//, newPath; if (provOptions.TryGetValue(RedistVersionInfo.NameTag, out versionVal)) { switch (versionVal) { //case RedistVersionInfo.LatestVersion: // always run against the latest version of the compiler // newPath = GetOrcasPath(); // if (newPath != null && File.Exists(Path.Combine(newPath, compilerExecutable))) // compPath = newPath; // break; case RedistVersionInfo.RedistVersion: // lock-forward to the Orcas version, if it's not available throw (we'll throw at compile time) compPath = GetOrcasPath(); break; case RedistVersionInfo.InPlaceVersion: // lock-back to the Whidbey version, no-op break; default: compPath = null; break; } } } if (compPath == null) throw new InvalidOperationException(SR.GetString(SR.CompilerNotFound, compilerExecutable)); return compPath; } /// /// this method returns the location of the Orcas compilers, but will return whatever /// version is requested via the COMPlus_ environment variables first /// private static string GetOrcasPath() { string dir = null; // if this is running in a private running environment such as Razzle, we would use the path // based on the environment variables: COMPLUS_InstallRoot and COMPLUS_Version. string comPlus_InstallRoot = Environment.GetEnvironmentVariable("COMPLUS_InstallRoot"); string comPlus_Version = Environment.GetEnvironmentVariable("COMPLUS_Version"); if (!string.IsNullOrEmpty(comPlus_InstallRoot) && !string.IsNullOrEmpty(comPlus_Version)) { dir = Path.Combine(comPlus_InstallRoot, comPlus_Version); if (Directory.Exists(dir)) return dir; } dir = Registry.GetValue(dotNetFrameworkRegistryPath, dotNetFrameworkSdkInstallKeyValueV35, null) as string; if (dir != null && Directory.Exists(dir)) { return dir; } return null; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ClrProviderManifest.cs
- EntityDataSourceContainerNameItem.cs
- OpenFileDialog.cs
- DataGridViewControlCollection.cs
- _KerberosClient.cs
- GraphicsPath.cs
- GuidelineSet.cs
- ErrorWebPart.cs
- XPathChildIterator.cs
- PerformanceCounterPermissionEntry.cs
- AutomationAttributeInfo.cs
- TextEndOfLine.cs
- ApplicationDirectory.cs
- TargetException.cs
- WebMessageEncoderFactory.cs
- Span.cs
- WsdlExporter.cs
- RouteItem.cs
- SharedPerformanceCounter.cs
- InputBindingCollection.cs
- BaseValidator.cs
- MethodExpr.cs
- IChannel.cs
- CommandDevice.cs
- RectKeyFrameCollection.cs
- LinqDataSource.cs
- PropertyChangedEventManager.cs
- TextSelection.cs
- ListViewSelectEventArgs.cs
- SqlProfileProvider.cs
- SqlBuilder.cs
- CultureMapper.cs
- ScriptReferenceEventArgs.cs
- ObjectListFieldsPage.cs
- ListViewItem.cs
- ObjectSet.cs
- MulticastOption.cs
- MSG.cs
- StreamUpdate.cs
- WebPageTraceListener.cs
- Thread.cs
- GridViewCommandEventArgs.cs
- MethodToken.cs
- TimeStampChecker.cs
- DataSourceProvider.cs
- OracleConnection.cs
- MailMessage.cs
- EntityTemplateFactory.cs
- ProcessingInstructionAction.cs
- MenuScrollingVisibilityConverter.cs
- TableProviderWrapper.cs
- QueryPageSettingsEventArgs.cs
- RegexInterpreter.cs
- DelegatingStream.cs
- TextEditorCharacters.cs
- StorageMappingItemCollection.cs
- SchemaHelper.cs
- CompilerCollection.cs
- Border.cs
- CompatibleIComparer.cs
- SqlPersonalizationProvider.cs
- EntityConnectionStringBuilderItem.cs
- CompareValidator.cs
- DetailsViewRowCollection.cs
- Point4D.cs
- WsatTransactionHeader.cs
- AssemblyContextControlItem.cs
- DbProviderFactories.cs
- DbDataSourceEnumerator.cs
- TextSegment.cs
- Tracking.cs
- FixedLineResult.cs
- StrokeCollection2.cs
- DataColumn.cs
- SchemaMapping.cs
- WebPartConnectionsCloseVerb.cs
- WSSecurityTokenSerializer.cs
- XslTransform.cs
- DataStreamFromComStream.cs
- RuntimeHandles.cs
- CommandDevice.cs
- SafeWaitHandle.cs
- GregorianCalendarHelper.cs
- CompilerGeneratedAttribute.cs
- ProfileService.cs
- DecimalStorage.cs
- XmlSchemaImporter.cs
- WebBrowserNavigatingEventHandler.cs
- CodeBlockBuilder.cs
- Events.cs
- CodeMemberField.cs
- ContainerParaClient.cs
- TopClause.cs
- FtpCachePolicyElement.cs
- SecureUICommand.cs
- BitmapEffect.cs
- GeneralTransformGroup.cs
- sitestring.cs
- UrlPath.cs
- XmlSchemaSimpleType.cs