Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / CompMod / System / CodeDOM / Compiler / RedistVersionInfo.cs / 5 / 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
- ZipIOCentralDirectoryDigitalSignature.cs
- XmlCompatibilityReader.cs
- SemanticValue.cs
- StateValidator.cs
- String.cs
- CharAnimationBase.cs
- CacheMemory.cs
- TypeToken.cs
- SrgsItemList.cs
- HttpCacheVary.cs
- SignatureResourcePool.cs
- OdbcFactory.cs
- httpstaticobjectscollection.cs
- QilStrConcat.cs
- DataGridViewCellMouseEventArgs.cs
- SafeEventLogWriteHandle.cs
- DesignerObject.cs
- WsatServiceAddress.cs
- EntityChangedParams.cs
- SelectionItemPattern.cs
- UserControlParser.cs
- SafeNativeMethods.cs
- DecodeHelper.cs
- CompiledIdentityConstraint.cs
- SelectionProviderWrapper.cs
- DataRecordObjectView.cs
- HwndMouseInputProvider.cs
- Path.cs
- SoapFormatterSinks.cs
- PolyBezierSegment.cs
- TableParagraph.cs
- DropTarget.cs
- DataSourceCacheDurationConverter.cs
- TreeViewHitTestInfo.cs
- TextEditorDragDrop.cs
- PropertyAccessVisitor.cs
- Container.cs
- Viewport3DVisual.cs
- SoapAttributeAttribute.cs
- Variant.cs
- CodeThrowExceptionStatement.cs
- ClientUtils.cs
- ServiceModelPerformanceCounters.cs
- Regex.cs
- DataPointer.cs
- _SSPIWrapper.cs
- ValueProviderWrapper.cs
- DBCSCodePageEncoding.cs
- ActiveXSite.cs
- AuthenticationConfig.cs
- PathData.cs
- BinaryQueryOperator.cs
- DesignerDataTableBase.cs
- PersonalizationAdministration.cs
- MethodBody.cs
- SrgsGrammar.cs
- MultiTrigger.cs
- EndpointAddressAugust2004.cs
- ConfigXmlSignificantWhitespace.cs
- TrackingServices.cs
- TextDpi.cs
- WorkflowEnvironment.cs
- HtmlInputReset.cs
- ResXFileRef.cs
- XmlLangPropertyAttribute.cs
- FontConverter.cs
- CommonXSendMessage.cs
- ListenerUnsafeNativeMethods.cs
- DataGridViewRowsRemovedEventArgs.cs
- _LocalDataStore.cs
- WebControlsSection.cs
- KeyedPriorityQueue.cs
- RegexRunner.cs
- SqlFacetAttribute.cs
- ReadOnlyCollectionBase.cs
- EmptyEnumerator.cs
- SafeHandle.cs
- TextSchema.cs
- WebPartConnectionsConfigureVerb.cs
- References.cs
- SocketElement.cs
- ExecutedRoutedEventArgs.cs
- QueueTransferProtocol.cs
- DataChangedEventManager.cs
- EdmItemCollection.cs
- SqlBooleanizer.cs
- Bold.cs
- HandlerFactoryCache.cs
- TextRangeBase.cs
- SurrogateSelector.cs
- PointCollectionValueSerializer.cs
- TextTreeRootNode.cs
- VectorCollection.cs
- wgx_exports.cs
- SqlProviderManifest.cs
- MessageSecurityOverTcpElement.cs
- DataGridAddNewRow.cs
- InputBuffer.cs
- StatusBarDrawItemEvent.cs
- OleDbDataReader.cs