public static void VerifyFileHash(string filePath, HashCollection hashCollection) { string fileName = Path.GetFileName(filePath); if (hashCollection.Count == 0) { if (!PolicyKeys.RequireHashInManifests()) { Logger.AddWarningInformation(string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("NoHashFile"), new object[1] { (object)fileName })); } else { throw new InvalidDeploymentException(ExceptionTypes.HashValidation, string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("Ex_HashNotSpecified"), new object[1] { (object)fileName })); } } foreach (Hash hash in hashCollection) { ComponentVerifier.VerifyFileHash(filePath, hash); } }
internal static AssemblyManifest FromDocument(string localPath, AssemblyManifest.ManifestType manifestType, Uri sourceUri) { AssemblyManifest manifest; CodeMarker_Singleton.Instance.CodeMarker(CodeMarkerEvent.perfParseBegin); Logger.AddMethodCall("ManifestReader.FromDocument(" + localPath + ") called."); FileInfo info = new FileInfo(localPath); if (info.Length > 0x1000000L) { throw new DeploymentException(Resources.GetString("Ex_ManifestFileTooLarge")); } FileStream input = new FileStream(localPath, FileMode.Open, FileAccess.Read); try { XmlReader reader = PolicyKeys.SkipSchemaValidation() ? XmlReader.Create(input) : ManifestValidatingReader.Create(input); while (reader.Read()) { } Logger.AddInternalState("Schema validation passed."); manifest = new AssemblyManifest(input); Logger.AddInternalState("Manifest is parsed successfully."); if (!PolicyKeys.SkipSemanticValidation()) { manifest.ValidateSemantics(manifestType); } Logger.AddInternalState("Semantic validation passed."); if (!PolicyKeys.SkipSignatureValidation()) { input.Position = 0L; manifest.ValidateSignature(input); } Logger.AddInternalState("Signature validation passed."); } catch (XmlException exception) { string message = string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_ManifestFromDocument"), new object[] { (sourceUri != null) ? sourceUri.AbsoluteUri : Path.GetFileName(localPath) }); throw new InvalidDeploymentException(ExceptionTypes.ManifestParse, message, exception); } catch (XmlSchemaValidationException exception2) { string str2 = string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_ManifestFromDocument"), new object[] { (sourceUri != null) ? sourceUri.AbsoluteUri : Path.GetFileName(localPath) }); throw new InvalidDeploymentException(ExceptionTypes.ManifestParse, str2, exception2); } catch (InvalidDeploymentException exception3) { string str3 = string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_ManifestFromDocument"), new object[] { (sourceUri != null) ? sourceUri.AbsoluteUri : Path.GetFileName(localPath) }); throw new InvalidDeploymentException(ExceptionTypes.ManifestParse, str3, exception3); } finally { if (input != null) { input.Dispose(); } } CodeMarker_Singleton.Instance.CodeMarker(CodeMarkerEvent.perfParseEnd); return(manifest); }
internal DeploymentManager(Uri deploymentSource, bool isUpdate, bool isConfirmed, DownloadOptions downloadOptions, AsyncOperation optionalAsyncOp) { this._deploySource = deploymentSource; this._isupdate = isUpdate; this._isConfirmed = isConfirmed; this._downloadOptions = downloadOptions; this._events = new EventHandlerList(); this._syncGroupMap = CollectionsUtil.CreateCaseInsensitiveHashtable(); this._subStore = SubscriptionStore.CurrentUser; this.bindWorker = new ThreadStart(this.BindAsyncWorker); this.synchronizeWorker = new ThreadStart(this.SynchronizeAsyncWorker); this.synchronizeGroupWorker = new WaitCallback(this.SynchronizeGroupAsyncWorker); this.bindCompleted = new SendOrPostCallback(this.BindAsyncCompleted); this.synchronizeCompleted = new SendOrPostCallback(this.SynchronizeAsyncCompleted); this.progressReporter = new SendOrPostCallback(this.ProgressReporter); this.asyncOperation = optionalAsyncOp != null ? optionalAsyncOp : AsyncOperationManager.CreateOperation((object)null); this._log = Logger.StartLogging(); if (deploymentSource != (Uri)null) { Logger.SetSubscriptionUrl(this._log, deploymentSource); } this._assertApplicationReqEvents = new ManualResetEvent[3]; this._assertApplicationReqEvents[0] = this._trustNotGrantedEvent; this._assertApplicationReqEvents[1] = this._platformRequirementsFailedEvent; this._assertApplicationReqEvents[2] = this._trustGrantedEvent; this._callerType = DeploymentManager.CallerType.Other; PolicyKeys.SkipApplicationDependencyHashCheck(); PolicyKeys.SkipDeploymentProvider(); PolicyKeys.SkipSchemaValidation(); PolicyKeys.SkipSemanticValidation(); PolicyKeys.SkipSignatureValidation(); }
public static bool SuppressLimitOnNumberOfActivations() { if (!PolicyKeys.CheckDeploymentBoolString("SuppressLimitOnNumberOfActivations", true, false)) { return(false); } Logger.AddWarningInformation(Resources.GetString("SuppressLimitOnNumberOfActivations")); return(true); }
public static bool DisableGenericExceptionHandler() { if (!PolicyKeys.CheckDeploymentBoolString("DisableGenericExceptionHandler", true, false)) { return(false); } Logger.AddWarningInformation(Resources.GetString("DisableGenericExceptionHandler")); return(true); }
public static bool SkipSemanticValidation() { if (!PolicyKeys.CheckDeploymentBoolString("SkipSemanticValidation", true, false)) { return(false); } Logger.AddWarningInformation(Resources.GetString("SkipAllSemanticValidation")); return(true); }
public static bool SkipApplicationDependencyHashCheck() { if (!PolicyKeys.CheckDeploymentBoolString("SkipApplicationDependencyHashCheck", true, false)) { return(false); } Logger.AddWarningInformation(Resources.GetString("SkipApplicationDependencyHashCheck")); return(true); }
public static bool SkipDeploymentProvider() { if (!PolicyKeys.CheckDeploymentBoolString("SkipDeploymentProvider", true, false)) { return(false); } Logger.AddWarningInformation(Resources.GetString("SkipDeploymentProvider")); return(true); }
internal static AssemblyManifest FromDocument(string localPath, AssemblyManifest.ManifestType manifestType, Uri sourceUri) { CodeMarker_Singleton.Instance.CodeMarker(7302); Logger.AddMethodCall("ManifestReader.FromDocument(" + localPath + ") called."); if (new FileInfo(localPath).Length > 16777216L) { throw new DeploymentException(Resources.GetString("Ex_ManifestFileTooLarge")); } AssemblyManifest assemblyManifest; using (FileStream fileStream = new FileStream(localPath, FileMode.Open, FileAccess.Read)) { try { XmlReader xmlReader = PolicyKeys.SkipSchemaValidation() ? XmlReader.Create((Stream)fileStream, new XmlReaderSettings() { DtdProcessing = DtdProcessing.Prohibit, XmlResolver = (XmlResolver)null }) : ManifestValidatingReader.Create((Stream)fileStream); do { ; }while (xmlReader.Read()); Logger.AddInternalState("Schema validation passed."); assemblyManifest = new AssemblyManifest(fileStream); Logger.AddInternalState("Manifest is parsed successfully."); if (!PolicyKeys.SkipSemanticValidation()) { assemblyManifest.ValidateSemantics(manifestType); } Logger.AddInternalState("Semantic validation passed."); if (!PolicyKeys.SkipSignatureValidation()) { fileStream.Position = 0L; assemblyManifest.ValidateSignature((Stream)fileStream); } Logger.AddInternalState("Signature validation passed."); } catch (XmlException ex) { throw new InvalidDeploymentException(ExceptionTypes.ManifestParse, string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("Ex_ManifestFromDocument"), new object[1] { (object)(sourceUri != (Uri)null ? sourceUri.AbsoluteUri : Path.GetFileName(localPath)) }), (Exception)ex); } catch (XmlSchemaValidationException ex) { throw new InvalidDeploymentException(ExceptionTypes.ManifestParse, string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("Ex_ManifestFromDocument"), new object[1] { (object)(sourceUri != (Uri)null ? sourceUri.AbsoluteUri : Path.GetFileName(localPath)) }), (Exception)ex); } catch (InvalidDeploymentException ex) { throw new InvalidDeploymentException(ExceptionTypes.ManifestParse, string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("Ex_ManifestFromDocument"), new object[1] { (object)(sourceUri != (Uri)null ? sourceUri.AbsoluteUri : Path.GetFileName(localPath)) }), (Exception)ex); } } CodeMarker_Singleton.Instance.CodeMarker(7303); return(assemblyManifest); }
public static bool FollowDeploymentProviderUri(SubscriptionStore subStore, ref AssemblyManifest deployment, ref Uri sourceUri, out TempFile tempFile, IDownloadNotification notification, DownloadOptions options) { Logger.AddMethodCall("FollowDeploymentProviderUri called."); tempFile = (TempFile)null; bool flag1 = false; Zone fromUrl1 = Zone.CreateFromUrl(sourceUri.AbsoluteUri); bool flag2 = false; if (fromUrl1.SecurityZone != SecurityZone.MyComputer) { Logger.AddInternalState("Deployment manifest zone is not local machine. Zone = " + (object)fromUrl1.SecurityZone); flag2 = true; } else { Logger.AddInternalState("Deployment manifest zone is local machine. Zone = " + (object)fromUrl1.SecurityZone); DependentAssembly dependentAssembly = deployment.MainDependentAssembly; if (dependentAssembly == null || dependentAssembly.Codebase == null) { throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_NoAppInDeploymentManifest")); } Uri uri = new Uri(sourceUri, dependentAssembly.Codebase); Zone fromUrl2 = Zone.CreateFromUrl(uri.AbsoluteUri); if (fromUrl2.SecurityZone == SecurityZone.MyComputer) { Logger.AddInternalState("Application manifest zone is local machine. Zone = " + (object)fromUrl2.SecurityZone); if (!System.IO.File.Exists(uri.LocalPath)) { Logger.AddInternalState(uri.LocalPath + " does not exist in local machine."); flag2 = true; } } } if (flag2) { Uri providerCodebaseUri = deployment.Deployment.ProviderCodebaseUri; Logger.SetDeploymentProviderUrl(providerCodebaseUri); Logger.AddInternalState("providerUri=" + (object)providerCodebaseUri + ",sourceUri=" + (object)sourceUri); if (!PolicyKeys.SkipDeploymentProvider() && providerCodebaseUri != (Uri)null && !providerCodebaseUri.Equals((object)sourceUri)) { ServerInformation serverInformation; AssemblyManifest deployment1; try { deployment1 = DownloadManager.DownloadDeploymentManifestDirect(subStore, ref providerCodebaseUri, out tempFile, notification, options, out serverInformation); } catch (InvalidDeploymentException ex) { if (ex.SubType == ExceptionTypes.Manifest || ex.SubType == ExceptionTypes.ManifestLoad || (ex.SubType == ExceptionTypes.ManifestParse || ex.SubType == ExceptionTypes.ManifestSemanticValidation)) { throw new InvalidDeploymentException(ExceptionTypes.Manifest, Resources.GetString("Ex_InvalidProviderManifest"), (Exception)ex); } throw; } Logger.SetDeploymentProviderServerInformation(serverInformation); SubscriptionState subscriptionState = subStore.GetSubscriptionState(deployment); if (!subStore.GetSubscriptionState(deployment1).SubscriptionId.Equals((object)subscriptionState.SubscriptionId)) { throw new InvalidDeploymentException(ExceptionTypes.SubscriptionSemanticValidation, Resources.GetString("Ex_ProviderNotInSubscription")); } Logger.AddInternalState("Deployment provider followed: " + (object)providerCodebaseUri); deployment = deployment1; sourceUri = providerCodebaseUri; flag1 = true; } } if (!flag1) { Logger.AddInternalState("Deployment provider not followed."); } return(flag1); }
public static AssemblyManifest DownloadApplicationManifest(AssemblyManifest deploymentManifest, string targetDir, Uri deploymentUri, IDownloadNotification notification, DownloadOptions options, out Uri appSourceUri, out string appManifestPath) { Logger.AddMethodCall("DownloadApplicationManifest called."); DependentAssembly dependentAssembly = deploymentManifest.MainDependentAssembly; if (dependentAssembly == null || dependentAssembly.Codebase == null) { throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_NoAppInDeploymentManifest")); } appSourceUri = new Uri(deploymentUri, dependentAssembly.Codebase); Zone fromUrl1 = Zone.CreateFromUrl(deploymentUri.AbsoluteUri); Zone fromUrl2 = Zone.CreateFromUrl(appSourceUri.AbsoluteUri); if (!fromUrl1.Equals((object)fromUrl2)) { Logger.AddInternalState("Deployment and application does not have matching security zones. deploymentZone=" + (object)fromUrl1 + ",applicationZone=" + (object)fromUrl2); throw new InvalidDeploymentException(ExceptionTypes.Zone, Resources.GetString("Ex_DeployAppZoneMismatch")); } appManifestPath = Path.Combine(targetDir, dependentAssembly.Identity.Name + ".manifest"); ServerInformation serverInformation; AssemblyManifest assemblyManifest = DownloadManager.DownloadManifest(ref appSourceUri, appManifestPath, notification, options, AssemblyManifest.ManifestType.Application, out serverInformation); Logger.SetApplicationUrl(appSourceUri); Logger.SetApplicationServerInformation(serverInformation); Zone fromUrl3 = Zone.CreateFromUrl(appSourceUri.AbsoluteUri); if (!fromUrl1.Equals((object)fromUrl3)) { Logger.AddInternalState("Deployment and application does not have matching security zones. deploymentZone=" + (object)fromUrl1 + ",applicationZone=" + (object)fromUrl3); throw new InvalidDeploymentException(ExceptionTypes.Zone, Resources.GetString("Ex_DeployAppZoneMismatch")); } if (assemblyManifest.Identity.Equals((object)deploymentManifest.Identity)) { throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("Ex_DepSameDeploymentAndApplicationIdentity"), new object[1] { (object)assemblyManifest.Identity.ToString() })); } if (!assemblyManifest.Identity.Matches(dependentAssembly.Identity, assemblyManifest.Application)) { throw new InvalidDeploymentException(ExceptionTypes.SubscriptionSemanticValidation, Resources.GetString("Ex_RefDefMismatch")); } if (!PolicyKeys.SkipApplicationDependencyHashCheck()) { try { ComponentVerifier.VerifyFileHash(appManifestPath, dependentAssembly.HashCollection); } catch (InvalidDeploymentException ex) { if (ex.SubType == ExceptionTypes.HashValidation) { throw new InvalidDeploymentException(ExceptionTypes.HashValidation, Resources.GetString("Ex_AppManInvalidHash"), (Exception)ex); } throw; } } if (assemblyManifest.RequestedExecutionLevel != null) { Logger.AddInternalState("Application manifest has RequestedExecutionLevel specified. Check requested privileges."); DownloadManager.VerifyRequestedPrivilegesSupport(assemblyManifest.RequestedExecutionLevel); } return(assemblyManifest); }
public static void VerifyPlatformDependencies(AssemblyManifest appManifest, AssemblyManifest deployManifest, string tempDir) { Logger.AddMethodCall("VerifyPlatformDependencies called."); string str1 = (string)null; Uri supportUrl1 = deployManifest.Description.SupportUri; bool flag1 = false; DependentOS dependentOs = appManifest.DependentOS; if (dependentOs != null) { PlatformDetector.OSDependency osd = new PlatformDetector.OSDependency((uint)dependentOs.MajorVersion, (uint)dependentOs.MinorVersion, (uint)dependentOs.BuildNumber, (ushort)dependentOs.ServicePackMajor, (ushort)dependentOs.ServicePackMinor, (string)null, (string)null); if (!PlatformDetector.VerifyOSDependency(ref osd)) { StringBuilder stringBuilder = new StringBuilder(); string str2 = ((int)dependentOs.MajorVersion).ToString() + "." + (object)dependentOs.MinorVersion + "." + (object)dependentOs.BuildNumber + "." + (object)dependentOs.ServicePackMajor + (object)dependentOs.ServicePackMinor; stringBuilder.AppendFormat(Resources.GetString("PlatformMicrosoftWindowsOperatingSystem"), (object)str2); string str3 = stringBuilder.ToString(); if (dependentOs.SupportUrl != (Uri)null) { supportUrl1 = dependentOs.SupportUrl; } throw new DependentPlatformMissingException(string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("ErrorMessage_PlatformDetectionFailed"), new object[1] { (object)str3 }), supportUrl1); } } if (PlatformDetector.IsWin8orLater() && !appManifest.EntryPoints[0].HostInBrowser) { flag1 = true; } Version clrVersion = Constants.V2CLRVersion; string clrVersionString = clrVersion.ToString(3); string processorArchitecture = appManifest.Identity.ProcessorArchitecture; Uri supportUrl2 = supportUrl1; if (appManifest.CLRDependentAssembly != null) { clrVersion = appManifest.CLRDependentAssembly.Identity.Version; clrVersionString = clrVersion.ToString(3); processorArchitecture = appManifest.CLRDependentAssembly.Identity.ProcessorArchitecture; if (appManifest.CLRDependentAssembly.SupportUrl != (Uri)null) { supportUrl2 = appManifest.CLRDependentAssembly.SupportUrl; } if (appManifest.CLRDependentAssembly.Description != null) { str1 = appManifest.CLRDependentAssembly.Description; } } if (deployManifest.CompatibleFrameworks != null) { bool flag2 = false; for (int index = 0; index < deployManifest.CompatibleFrameworks.Frameworks.Count; ++index) { if (PlatformDetector.CheckCompatibleFramework(deployManifest.CompatibleFrameworks.Frameworks[index], ref clrVersion, ref clrVersionString, processorArchitecture)) { flag2 = true; break; } } if (!flag2) { Uri supportUrl3 = !(deployManifest.CompatibleFrameworks.SupportUrl != (Uri)null) ? supportUrl2 : deployManifest.CompatibleFrameworks.SupportUrl; if (flag1) { return; } throw new CompatibleFrameworkMissingException(string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("ErrorMessage_CompatiblePlatformDetectionFailed"), new object[1] { (object)PlatformDetector.FormatFrameworkString(deployManifest.CompatibleFrameworks.Frameworks[0]) }), supportUrl3, deployManifest.CompatibleFrameworks); } } else { if (clrVersion >= Constants.V4CLRVersion) { throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_SemanticallyInvalidDeploymentManifest"), (Exception) new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_DepMissingCompatibleFrameworks"))); } if (!NativeMethods.VerifyCLRVersionInfo(clrVersion, processorArchitecture)) { StringBuilder stringBuilder = new StringBuilder(); if (str1 == null) { stringBuilder.AppendFormat(Resources.GetString("PlatformMicrosoftCommonLanguageRuntime"), (object)clrVersionString); str1 = stringBuilder.ToString(); } Uri supportUrl3 = supportUrl2; if (flag1) { return; } throw new SupportedRuntimeMissingException(string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("ErrorMessage_PlatformDetectionFailed"), new object[1] { (object)str1 }), supportUrl3, clrVersionString); } } Logger.AddPhaseInformation(Resources.GetString("CompatibleRuntimeFound"), new object[1] { (object)clrVersionString }); bool flag3 = false; if (clrVersion < Constants.V4CLRVersion) { flag3 = true; } NativeMethods.CCorRuntimeHost RuntimeHost = (NativeMethods.CCorRuntimeHost)null; try { NativeMethods.IAssemblyCache assemblyCacheInterface = NativeMethods.GetAssemblyCacheInterface(clrVersionString, flag3, out RuntimeHost); if (assemblyCacheInterface == null || flag3 && RuntimeHost == null) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendFormat(Resources.GetString("PlatformMicrosoftCommonLanguageRuntime"), (object)clrVersionString); throw new DependentPlatformMissingException(string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("ErrorMessage_PlatformDetectionFailed"), new object[1] { (object)stringBuilder.ToString() }), supportUrl2); } bool flag2 = false; bool flag4 = false; if (flag3 && !PolicyKeys.SkipSKUDetection()) { foreach (DependentAssembly dependentAssembly in appManifest.DependentAssemblies) { if (dependentAssembly.IsPreRequisite && PlatformDetector.IsNetFX35SP1ClientSignatureAsm(dependentAssembly.Identity)) { flag2 = true; } if (dependentAssembly.IsPreRequisite && PlatformDetector.IsNetFX35SP1FullSignatureAsm(dependentAssembly.Identity)) { flag4 = true; } } if (PlatformDetector.GetPlatformNetFx35SKU(assemblyCacheInterface, flag3, RuntimeHost, tempDir) == PlatformDetector.NetFX35SP1SKU.Client35SP1 && !flag2 && !flag4) { throw new DependentPlatformMissingException(string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("ErrorMessage_PlatformDetectionFailed"), new object[1] { (object)".NET Framework 3.5 SP1" })); } } foreach (DependentAssembly dependentAssembly in appManifest.DependentAssemblies) { if (dependentAssembly.IsPreRequisite && !PlatformDetector.IsCLRDependencyText(dependentAssembly.Identity.Name)) { if (!flag3 && (PlatformDetector.IsNetFX35SP1ClientSignatureAsm(dependentAssembly.Identity) || PlatformDetector.IsNetFX35SP1FullSignatureAsm(dependentAssembly.Identity) || "framework".Equals(dependentAssembly.Group, StringComparison.OrdinalIgnoreCase))) { Logger.AddPhaseInformation(Resources.GetString("SkippingSentinalDependentAssembly"), new object[1] { (object)dependentAssembly.Identity.ToString() }); } else if (!PlatformDetector.VerifyGACDependency(assemblyCacheInterface, flag3, RuntimeHost, dependentAssembly.Identity, tempDir)) { string description; if (dependentAssembly.Description != null) { description = dependentAssembly.Description; } else { ReferenceIdentity identity = dependentAssembly.Identity; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendFormat(Resources.GetString("PlatformDependentAssemblyVersion"), (object)identity.Name, (object)identity.Version); description = stringBuilder.ToString(); } if (dependentAssembly.SupportUrl != (Uri)null) { supportUrl1 = dependentAssembly.SupportUrl; } throw new DependentPlatformMissingException(string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("ErrorMessage_PlatformGACDetectionFailed"), new object[1] { (object)description }), supportUrl1); } } } } finally { if (RuntimeHost != null) { RuntimeHost.Dispose(); } } }
public static bool FollowDeploymentProviderUri(SubscriptionStore subStore, ref AssemblyManifest deployment, ref Uri sourceUri, out TempFile tempFile, IDownloadNotification notification, DownloadOptions options) { Logger.AddMethodCall("FollowDeploymentProviderUri called."); tempFile = null; bool flag = false; Zone zone = Zone.CreateFromUrl(sourceUri.AbsoluteUri); bool flag2 = false; if (zone.SecurityZone != SecurityZone.MyComputer) { Logger.AddInternalState("Deployment manifest zone is not local machine. Zone = " + zone.SecurityZone); flag2 = true; } else { Logger.AddInternalState("Deployment manifest zone is local machine. Zone = " + zone.SecurityZone); DependentAssembly mainDependentAssembly = deployment.MainDependentAssembly; if ((mainDependentAssembly == null) || (mainDependentAssembly.Codebase == null)) { throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_NoAppInDeploymentManifest")); } Uri uri = new Uri(sourceUri, mainDependentAssembly.Codebase); Zone zone2 = Zone.CreateFromUrl(uri.AbsoluteUri); if (zone2.SecurityZone == SecurityZone.MyComputer) { Logger.AddInternalState("Application manifest zone is local machine. Zone = " + zone2.SecurityZone); if (!System.IO.File.Exists(uri.LocalPath)) { Logger.AddInternalState(uri.LocalPath + " does not exist in local machine."); flag2 = true; } } } if (flag2) { Uri providerCodebaseUri = deployment.Deployment.ProviderCodebaseUri; Logger.SetDeploymentProviderUrl(providerCodebaseUri); Logger.AddInternalState(string.Concat(new object[] { "providerUri=", providerCodebaseUri, ",sourceUri=", sourceUri })); if ((!PolicyKeys.SkipDeploymentProvider() && (providerCodebaseUri != null)) && !providerCodebaseUri.Equals(sourceUri)) { ServerInformation information; AssemblyManifest manifest = null; try { manifest = DownloadDeploymentManifestDirect(subStore, ref providerCodebaseUri, out tempFile, notification, options, out information); } catch (InvalidDeploymentException exception) { if (((exception.SubType != ExceptionTypes.Manifest) && (exception.SubType != ExceptionTypes.ManifestLoad)) && ((exception.SubType != ExceptionTypes.ManifestParse) && (exception.SubType != ExceptionTypes.ManifestSemanticValidation))) { throw; } throw new InvalidDeploymentException(ExceptionTypes.Manifest, Resources.GetString("Ex_InvalidProviderManifest"), exception); } Logger.SetDeploymentProviderServerInformation(information); SubscriptionState subscriptionState = subStore.GetSubscriptionState(deployment); if (!subStore.GetSubscriptionState(manifest).SubscriptionId.Equals(subscriptionState.SubscriptionId)) { throw new InvalidDeploymentException(ExceptionTypes.SubscriptionSemanticValidation, Resources.GetString("Ex_ProviderNotInSubscription")); } Logger.AddInternalState("Deployment provider followed: " + providerCodebaseUri); deployment = manifest; sourceUri = providerCodebaseUri; flag = true; } } if (!flag) { Logger.AddInternalState("Deployment provider not followed."); } return(flag); }
public static void VerifyPlatformDependencies(AssemblyManifest appManifest, AssemblyManifest deployManifest, string tempDir) { Logger.AddMethodCall("VerifyPlatformDependencies called."); string description = null; Uri supportUri = deployManifest.Description.SupportUri; DependentOS dependentOS = appManifest.DependentOS; if (dependentOS != null) { OSDependency osd = new OSDependency(dependentOS.MajorVersion, dependentOS.MinorVersion, dependentOS.BuildNumber, dependentOS.ServicePackMajor, dependentOS.ServicePackMinor, null, null); if (!VerifyOSDependency(ref osd)) { StringBuilder builder = new StringBuilder(); string str2 = string.Concat(new object[] { dependentOS.MajorVersion, ".", dependentOS.MinorVersion, ".", dependentOS.BuildNumber, ".", dependentOS.ServicePackMajor, dependentOS.ServicePackMinor }); builder.AppendFormat(Resources.GetString("PlatformMicrosoftWindowsOperatingSystem"), str2); description = builder.ToString(); if (dependentOS.SupportUrl != null) { supportUri = dependentOS.SupportUrl; } throw new DependentPlatformMissingException(string.Format(CultureInfo.CurrentUICulture, Resources.GetString("ErrorMessage_PlatformDetectionFailed"), new object[] { description }), supportUri); } } Version v = Constants.V2CLRVersion; string str3 = v.ToString(3); string processorArchitecture = appManifest.Identity.ProcessorArchitecture; Uri supportUrl = supportUri; if (appManifest.CLRDependentAssembly != null) { v = appManifest.CLRDependentAssembly.Identity.Version; str3 = v.ToString(3); processorArchitecture = appManifest.CLRDependentAssembly.Identity.ProcessorArchitecture; if (appManifest.CLRDependentAssembly.SupportUrl != null) { supportUrl = appManifest.CLRDependentAssembly.SupportUrl; } if (appManifest.CLRDependentAssembly.Description != null) { description = appManifest.CLRDependentAssembly.Description; } } if (deployManifest.CompatibleFrameworks == null) { if (v >= Constants.V4CLRVersion) { throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_SemanticallyInvalidDeploymentManifest"), new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_DepMissingCompatibleFrameworks"))); } if (!VerifyCLRVersionInfo(v, processorArchitecture)) { StringBuilder builder2 = new StringBuilder(); if (description == null) { builder2.AppendFormat(Resources.GetString("PlatformMicrosoftCommonLanguageRuntime"), str3); description = builder2.ToString(); } supportUri = supportUrl; throw new SupportedRuntimeMissingException(string.Format(CultureInfo.CurrentUICulture, Resources.GetString("ErrorMessage_PlatformDetectionFailed"), new object[] { description }), supportUri, str3); } } else { bool flag = false; for (int i = 0; i < deployManifest.CompatibleFrameworks.Frameworks.Count; i++) { if (CheckCompatibleFramework(deployManifest.CompatibleFrameworks.Frameworks[i], ref v, ref str3, processorArchitecture)) { flag = true; break; } } if (!flag) { if (deployManifest.CompatibleFrameworks.SupportUrl != null) { supportUri = deployManifest.CompatibleFrameworks.SupportUrl; } else { supportUri = supportUrl; } throw new CompatibleFrameworkMissingException(string.Format(CultureInfo.CurrentUICulture, Resources.GetString("ErrorMessage_CompatiblePlatformDetectionFailed"), new object[] { FormatFrameworkString(deployManifest.CompatibleFrameworks.Frameworks[0]) }), supportUri, deployManifest.CompatibleFrameworks); } } Logger.AddPhaseInformation(Resources.GetString("CompatibleRuntimeFound"), new object[] { str3 }); bool fetchRuntimeHost = false; if (v < Constants.V4CLRVersion) { fetchRuntimeHost = true; } using (System.Deployment.Application.NativeMethods.CCorRuntimeHost host = null) { System.Deployment.Application.NativeMethods.IAssemblyCache assemblyCache = System.Deployment.Application.NativeMethods.GetAssemblyCacheInterface(str3, fetchRuntimeHost, out host); if ((assemblyCache == null) || (fetchRuntimeHost && (host == null))) { StringBuilder builder3 = new StringBuilder(); builder3.AppendFormat(Resources.GetString("PlatformMicrosoftCommonLanguageRuntime"), str3); description = builder3.ToString(); supportUri = supportUrl; throw new DependentPlatformMissingException(string.Format(CultureInfo.CurrentUICulture, Resources.GetString("ErrorMessage_PlatformDetectionFailed"), new object[] { description }), supportUri); } bool flag3 = false; bool flag4 = false; if (fetchRuntimeHost && !PolicyKeys.SkipSKUDetection()) { foreach (DependentAssembly assembly in appManifest.DependentAssemblies) { if (assembly.IsPreRequisite && IsNetFX35SP1ClientSignatureAsm(assembly.Identity)) { flag3 = true; } if (assembly.IsPreRequisite && IsNetFX35SP1FullSignatureAsm(assembly.Identity)) { flag4 = true; } } if (((GetPlatformNetFx35SKU(assemblyCache, fetchRuntimeHost, host, tempDir) == NetFX35SP1SKU.Client35SP1) && !flag3) && !flag4) { description = ".NET Framework 3.5 SP1"; throw new DependentPlatformMissingException(string.Format(CultureInfo.CurrentUICulture, Resources.GetString("ErrorMessage_PlatformDetectionFailed"), new object[] { description })); } } foreach (DependentAssembly assembly2 in appManifest.DependentAssemblies) { if (assembly2.IsPreRequisite && !IsCLRDependencyText(assembly2.Identity.Name)) { if (!fetchRuntimeHost && ((IsNetFX35SP1ClientSignatureAsm(assembly2.Identity) || IsNetFX35SP1FullSignatureAsm(assembly2.Identity)) || "framework".Equals(assembly2.Group, StringComparison.OrdinalIgnoreCase))) { Logger.AddPhaseInformation(Resources.GetString("SkippingSentinalDependentAssembly"), new object[] { assembly2.Identity.ToString() }); } else if (!VerifyGACDependency(assemblyCache, fetchRuntimeHost, host, assembly2.Identity, tempDir)) { if (assembly2.Description != null) { description = assembly2.Description; } else { ReferenceIdentity identity = assembly2.Identity; StringBuilder builder4 = new StringBuilder(); builder4.AppendFormat(Resources.GetString("PlatformDependentAssemblyVersion"), identity.Name, identity.Version); description = builder4.ToString(); } if (assembly2.SupportUrl != null) { supportUri = assembly2.SupportUrl; } throw new DependentPlatformMissingException(string.Format(CultureInfo.CurrentUICulture, Resources.GetString("ErrorMessage_PlatformGACDetectionFailed"), new object[] { description }), supportUri); } } } } }
public static bool RequireHashInManifests() { return(PolicyKeys.CheckDeploymentBoolString("RequireHashInManifests", true, false)); }
public static bool ProduceDetailedExecutionSectionInLog() { return((int)PolicyKeys.GetLogVerbosityLevel() > 0); }