Example #1
0
        private UpdateCheckInfo DetermineUpdateCheckResult(ActivationDescription actDesc)
        {
            bool             updateAvailable        = false;
            Version          availableVersion       = null;
            bool             isUpdateRequired       = false;
            Version          minimumRequiredVersion = null;
            long             updateSize             = 0L;
            bool             bUpdateInPKTGroup      = false;
            AssemblyManifest deployManifest         = actDesc.DeployManifest;

            this._subState.Invalidate();
            Version version3 = this._subStore.CheckUpdateInManifest(this._subState, actDesc.DeploySourceUri, deployManifest, this._currentVersion, ref bUpdateInPKTGroup);

            if ((version3 != null) && !deployManifest.Identity.Equals(this._subState.ExcludedDeployment))
            {
                updateAvailable        = true;
                availableVersion       = version3;
                minimumRequiredVersion = deployManifest.Deployment.MinimumRequiredVersion;
                if ((minimumRequiredVersion != null) && (minimumRequiredVersion.CompareTo(this._currentVersion) > 0))
                {
                    isUpdateRequired = true;
                }
                ulong num2 = actDesc.AppManifest.CalculateDependenciesSize();
                if (num2 > 0x7fffffffffffffffL)
                {
                    updateSize = 0x7fffffffffffffffL;
                }
                else
                {
                    updateSize = (long)num2;
                }
                actDesc.IsUpdateInPKTGroup = bUpdateInPKTGroup;
            }
            return(new UpdateCheckInfo(updateAvailable, availableVersion, isUpdateRequired, minimumRequiredVersion, updateSize));
        }
Example #2
0
        public void CheckForDeploymentUpdate(SubscriptionState subState)
        {
            this.CheckInstalledAndShellVisible(subState);
            Uri      deploymentProviderUri = subState.DeploymentProviderUri;
            TempFile tempFile = (TempFile)null;

            try
            {
                AssemblyManifest   deployment = DownloadManager.DownloadDeploymentManifest(subState.SubscriptionStore, ref deploymentProviderUri, out tempFile);
                Version            version    = this.CheckUpdateInManifest(subState, deploymentProviderUri, deployment, subState.CurrentDeployment.Version);
                DefinitionIdentity deployId   = version != (Version)null ? deployment.Identity : (DefinitionIdentity)null;
                this.SetPendingDeployment(subState, deployId, DateTime.UtcNow);
                if (!(version != (Version)null) || !deployment.Identity.Equals((object)subState.PendingDeployment))
                {
                    return;
                }
                Logger.AddPhaseInformation(Resources.GetString("Upd_FoundUpdate"), (object)subState.SubscriptionId.ToString(), (object)deployment.Identity.Version.ToString(), (object)deploymentProviderUri.AbsoluteUri);
            }
            finally
            {
                if (tempFile != null)
                {
                    tempFile.Dispose();
                }
            }
        }
Example #3
0
        private UpdateCheckInfo DetermineUpdateCheckResult(ActivationDescription actDesc)
        {
            bool             updateAvailable        = false;
            Version          availableVersion       = (Version)null;
            bool             isUpdateRequired       = false;
            Version          minimumRequiredVersion = (Version)null;
            long             updateSize             = 0;
            bool             bUpdateInPKTGroup      = false;
            AssemblyManifest deployManifest         = actDesc.DeployManifest;

            this._subState.Invalidate();
            Version version = this._subStore.CheckUpdateInManifest(this._subState, actDesc.DeploySourceUri, deployManifest, this._currentVersion, ref bUpdateInPKTGroup);

            if (version != (Version)null && !deployManifest.Identity.Equals((object)this._subState.ExcludedDeployment))
            {
                updateAvailable        = true;
                availableVersion       = version;
                minimumRequiredVersion = deployManifest.Deployment.MinimumRequiredVersion;
                if (minimumRequiredVersion != (Version)null && minimumRequiredVersion.CompareTo(this._currentVersion) > 0)
                {
                    isUpdateRequired = true;
                }
                ulong dependenciesSize = actDesc.AppManifest.CalculateDependenciesSize();
                updateSize = dependenciesSize <= 9223372036854775807UL ? (long)dependenciesSize : long.MaxValue;
                actDesc.IsUpdateInPKTGroup = bUpdateInPKTGroup;
            }
            return(new UpdateCheckInfo(updateAvailable, availableVersion, isUpdateRequired, minimumRequiredVersion, updateSize));
        }
Example #4
0
        static AssemblyTranslator CreateTranslator(
            Configuration configuration, AssemblyManifest manifest, AssemblyCache assemblyCache
            )
        {
            TypeInfoProvider typeInfoProvider = null;

            Console.Error.WriteLine(
                "// Using .NET framework {0} in {1} GC mode. Tuned GC {2}.",
                Environment.Version.ToString(),
                System.Runtime.GCSettings.IsServerGC ? "server" : "workstation",
#if TARGETTING_FX_4_5
                configuration.TuneGarbageCollection.GetValueOrDefault(true) ? "enabled" : "disabled"
#else
                "disabled (must be built in .NET 4.5 mode)"
#endif
                );

            if (
                configuration.ReuseTypeInfoAcrossAssemblies.GetValueOrDefault(true) &&
                (CachedTypeInfoProvider != null)
                )
            {
                if (CachedTypeInfoProviderConfiguration.Assemblies.Equals(configuration.Assemblies))
                {
                    typeInfoProvider = CachedTypeInfoProvider;
                }
            }

            var translator = new AssemblyTranslator(
                configuration, typeInfoProvider, manifest, assemblyCache,
                onProxyAssemblyLoaded: (name, classification) =>
                Console.Error.WriteLine("// Loaded proxies from '{0}'", ShortenPath(name))
                );

            translator.Decompiling       += MakeProgressHandler("Decompiling ");
            translator.RunningTransforms += MakeProgressHandler("Translating ");
            translator.Writing           += MakeProgressHandler("Writing JS  ");

            translator.AssemblyLoaded += (fn, classification) =>
                                         Console.Error.WriteLine("// Loaded {0} ({1})", ShortenPath(fn), classification);
            translator.CouldNotLoadSymbols     += (fn, ex) => {
            };
            translator.CouldNotResolveAssembly += (fn, ex) =>
                                                  Console.Error.WriteLine("// Could not load module {0}: {1}", fn, ex.Message);
            translator.CouldNotDecompileMethod += (fn, ex) =>
                                                  Console.Error.WriteLine("// Could not decompile method {0}: {1}", fn, ex);

            if (typeInfoProvider == null)
            {
                if (CachedTypeInfoProvider != null)
                {
                    CachedTypeInfoProvider.Dispose();
                }

                CachedTypeInfoProvider = translator.GetTypeInfoProvider();
                CachedTypeInfoProviderConfiguration = configuration;
            }

            return(translator);
        }
Example #5
0
        private static void AddDependencies(FileDownloader downloader, AssemblyManifest deployManifest, AssemblyManifest appManifest, Uri sourceUriBase, string targetDirectory, string group)
        {
            long total = 0;

            System.Deployment.Application.Manifest.File[] filesInGroup = appManifest.GetFilesInGroup(group, true);
            DownloadManager.ReorderFilesForIconFile(appManifest, filesInGroup);
            foreach (System.Deployment.Application.Manifest.File file in filesInGroup)
            {
                Uri fileSourceUri = DownloadManager.MapFileSourceUri(deployManifest, sourceUriBase, file.Name);
                DownloadManager.AddFileToDownloader(downloader, deployManifest, appManifest, (object)file, fileSourceUri, targetDirectory, file.NameFS, file.HashCollection);
                total += (long)file.Size;
            }
            DependentAssembly[] assembliesInGroup = appManifest.GetPrivateAssembliesInGroup(group, true);
            foreach (DependentAssembly dependentAssembly in assembliesInGroup)
            {
                Uri fileSourceUri = DownloadManager.MapFileSourceUri(deployManifest, sourceUriBase, dependentAssembly.Codebase);
                DownloadManager.AddFileToDownloader(downloader, deployManifest, appManifest, (object)dependentAssembly, fileSourceUri, targetDirectory, dependentAssembly.CodebaseFS, dependentAssembly.HashCollection);
                total += (long)dependentAssembly.Size;
            }
            downloader.SetExpectedBytesTotal(total);
            if (filesInGroup.Length == 0 && assembliesInGroup.Length == 0)
            {
                throw new InvalidDeploymentException(string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("Ex_NoSuchDownloadGroup"), new object[1]
                {
                    (object)group
                }));
            }
        }
Example #6
0
        public static void DownloadDependencies(SubscriptionState subState, AssemblyManifest deployManifest, AssemblyManifest appManifest, Uri sourceUriBase, string targetDirectory, string group, IDownloadNotification notification, DownloadOptions options)
        {
            Logger.AddMethodCall("DownloadDependencies called.");
            Logger.AddInternalState("sourceUriBase=" + (object)sourceUriBase);
            Logger.AddInternalState("targetDirectory=" + targetDirectory);
            Logger.AddInternalState("group=" + group);
            Logger.AddInternalState("DownloadOptions=" + (object)options);
            FileDownloader downloader = FileDownloader.Create();

            downloader.Options = options;
            if (group == null)
            {
                downloader.CheckForSizeLimit(appManifest.CalculateDependenciesSize(), false);
            }
            DownloadManager.AddDependencies(downloader, deployManifest, appManifest, sourceUriBase, targetDirectory, group);
            downloader.DownloadModified += new FileDownloader.DownloadModifiedEventHandler(DownloadManager.ProcessDownloadedFile);
            if (notification != null)
            {
                downloader.AddNotification(notification);
            }
            try
            {
                downloader.Download(subState, DownloadManager.ClientCertificate);
                downloader.ComponentVerifier.VerifyComponents();
                DownloadManager.VerifyRequestedPrivilegesSupport(appManifest, targetDirectory);
            }
            finally
            {
                if (notification != null)
                {
                    downloader.RemoveNotification(notification);
                }
                downloader.DownloadModified -= new FileDownloader.DownloadModifiedEventHandler(DownloadManager.ProcessDownloadedFile);
            }
        }
Example #7
0
        private static void AddFileToDownloader(FileDownloader downloader, AssemblyManifest deployManifest, AssemblyManifest appManifest, object manifestElement, Uri fileSourceUri, string targetDirectory, string targetFileName, HashCollection hashCollection)
        {
            string targetFilePath = Path.Combine(targetDirectory, targetFileName);

            DownloadManager.DependencyDownloadCookie dependencyDownloadCookie = new DownloadManager.DependencyDownloadCookie(manifestElement, deployManifest, appManifest);
            downloader.AddFile(fileSourceUri, targetFilePath, (object)dependencyDownloadCookie, hashCollection);
        }
Example #8
0
        private static void UpdateArpEntry(SubscriptionState subState, ShellExposureInformation shellExposureInformation)
        {
            DefinitionIdentity subscriptionId            = subState.SubscriptionId;
            string             str                       = string.Format(CultureInfo.InvariantCulture, "rundll32.exe dfshim.dll,ShArpMaintain {0}", new object[] { subscriptionId.ToString() });
            string             str2                      = string.Format(CultureInfo.InvariantCulture, "dfshim.dll,2", new object[0]);
            AssemblyManifest   currentDeploymentManifest = subState.CurrentDeploymentManifest;
            Description        effectiveDescription      = subState.EffectiveDescription;

            using (RegistryKey key = UninstallRoot.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"))
            {
                using (RegistryKey key2 = key.CreateSubKey(GenerateArpKeyName(subscriptionId)))
                {
                    string[] strArray = new string[] {
                        "DisplayName", shellExposureInformation.ARPDisplayName, "DisplayIcon", str2, "DisplayVersion", currentDeploymentManifest.Identity.Version.ToString(), "Publisher", effectiveDescription.FilteredPublisher, "UninstallString", str, "HelpLink", effectiveDescription.SupportUrl, "UrlUpdateInfo", subState.DeploymentProviderUri.AbsoluteUri, "ShortcutFolderName", shellExposureInformation.AppVendor,
                        "ShortcutFileName", shellExposureInformation.AppProduct, "ShortcutSuiteName", shellExposureInformation.AppSuiteName, "SupportShortcutFileName", shellExposureInformation.AppSupportShortcut, "ShortcutAppId", shellExposureInformation.ShortcutAppId
                    };
                    Logger.AddInternalState("Updating ARP entry.");
                    for (int i = strArray.Length - 2; i >= 0; i -= 2)
                    {
                        string name = strArray[i];
                        string str4 = strArray[i + 1];
                        if (str4 != null)
                        {
                            key2.SetValue(name, str4);
                        }
                        else
                        {
                            key2.DeleteValue(name, false);
                        }
                    }
                }
            }
        }
        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);
        }
Example #10
0
 public static void RemoveShellExtensions(DefinitionIdentity subId, AssemblyManifest appManifest, string productName)
 {
     foreach (FileAssociation fileAssociation in appManifest.FileAssociations)
     {
         ShellExposure.RemoveFileAssociation(fileAssociation, subId, productName);
     }
     NativeMethods.SHChangeNotify(134217728, 0U, IntPtr.Zero, IntPtr.Zero);
 }
Example #11
0
        public void BasicWriteAssemblyManifestToPath()
        {
            Manifest m    = new AssemblyManifest();
            string   file = FileUtilities.GetTemporaryFile();

            ManifestWriter.WriteManifest(m, file);
            File.Delete(file);
        }
Example #12
0
 public static void RemoveShellExtensions(DefinitionIdentity subId, AssemblyManifest appManifest, string productName)
 {
     foreach (FileAssociation association in appManifest.FileAssociations)
     {
         RemoveFileAssociation(association, subId, productName);
     }
     System.Deployment.Application.NativeMethods.SHChangeNotify(0x8000000, 0, IntPtr.Zero, IntPtr.Zero);
 }
Example #13
0
 private void ProcessUpdateCheckResult(UpdateCheckInfo info, ActivationDescription actDesc)
 {
     if (this._subState.IsShellVisible)
     {
         AssemblyManifest   deployManifest = actDesc.DeployManifest;
         DefinitionIdentity deployId       = info.UpdateAvailable ? deployManifest.Identity : null;
         this._subStore.SetPendingDeployment(this._subState, deployId, DateTime.UtcNow);
     }
 }
Example #14
0
        public static AssemblyManifest BuildManifest(Assembly targetAssembly)
        {
            AssemblyManifest output = new AssemblyManifest(targetAssembly.FullName);

            List<ProcessorDefinition> processors = FindProcessors(targetAssembly);
            output.Processors.AddRange(processors);

            return output;
        }
 public DependentOS(System.Deployment.Internal.Isolation.Manifest.DependentOSMetadataEntry dependentOSMetadataEntry)
 {
     this._majorVersion     = dependentOSMetadataEntry.MajorVersion;
     this._minorVersion     = dependentOSMetadataEntry.MinorVersion;
     this._buildNumber      = dependentOSMetadataEntry.BuildNumber;
     this._servicePackMajor = dependentOSMetadataEntry.ServicePackMajor;
     this._servicePackMinor = dependentOSMetadataEntry.ServicePackMinor;
     this._supportUrl       = AssemblyManifest.UriFromMetadataEntry(dependentOSMetadataEntry.SupportUrl, "Ex_DependentOSSupportUrlNotValid");
 }
 public void CheckDeploymentSubscriptionState(SubscriptionState subState, AssemblyManifest deployment)
 {
     if (subState.IsInstalled)
     {
         CheckOnlineShellVisibleConflict(subState, deployment);
         CheckInstalledAndUpdateableConflict(subState, deployment);
         CheckMinimumRequiredVersion(subState, deployment);
     }
 }
Example #17
0
 private static void AddFilesInHashtable(Hashtable hashtable, AssemblyManifest applicationManifest, string applicationFolder)
 {
     Logger.AddMethodCall("AddFilesInHashtable called.");
     Logger.AddInternalState("applicationFolder=" + applicationFolder);
     foreach (System.Deployment.Application.Manifest.File file in applicationManifest.Files)
     {
         string str = Path.Combine(applicationFolder, file.NameFS);
         try
         {
             FileDownloader.AddSingleFileInHashtable(hashtable, file.HashCollection, str);
         }
         catch (IOException ex)
         {
             Logger.AddErrorInformation((Exception)ex, Resources.GetString("Ex_PatchDependencyFailed"), new object[1]
             {
                 (object)Path.GetFileName(str)
             });
             Logger.AddInternalState("Exception thrown : " + ex.GetType().ToString() + ":" + ex.Message);
         }
     }
     foreach (DependentAssembly dependentAssembly in applicationManifest.DependentAssemblies)
     {
         if (!dependentAssembly.IsPreRequisite)
         {
             string str = Path.Combine(applicationFolder, dependentAssembly.Codebase);
             try
             {
                 if (FileDownloader.AddSingleFileInHashtable(hashtable, dependentAssembly.HashCollection, str))
                 {
                     System.Deployment.Application.Manifest.File[] files = new AssemblyManifest(str).Files;
                     for (int index = 0; index < files.Length; ++index)
                     {
                         string location = Path.Combine(Path.GetDirectoryName(str), files[index].NameFS);
                         FileDownloader.AddSingleFileInHashtable(hashtable, files[index].HashCollection, location);
                     }
                 }
             }
             catch (InvalidDeploymentException ex)
             {
                 Logger.AddErrorInformation((Exception)ex, Resources.GetString("Ex_PatchDependencyFailed"), new object[1]
                 {
                     (object)Path.GetFileName(str)
                 });
                 Logger.AddInternalState("Exception thrown : " + ex.GetType().ToString() + ":" + ex.Message);
             }
             catch (IOException ex)
             {
                 Logger.AddErrorInformation((Exception)ex, Resources.GetString("Ex_PatchDependencyFailed"), new object[1]
                 {
                     (object)Path.GetFileName(str)
                 });
                 Logger.AddInternalState("Exception thrown : " + ex.GetType().ToString() + ":" + ex.Message);
             }
         }
     }
 }
 public Deployment(System.Deployment.Internal.Isolation.Manifest.DeploymentMetadataEntry deploymentMetadataEntry)
 {
     this._disallowUrlActivation = (deploymentMetadataEntry.DeploymentFlags & 0x80) != 0;
     this._install               = (deploymentMetadataEntry.DeploymentFlags & 0x20) != 0;
     this._trustURLParameters    = (deploymentMetadataEntry.DeploymentFlags & 0x40) != 0;
     this._mapFileExtensions     = (deploymentMetadataEntry.DeploymentFlags & 0x100) != 0;
     this._createDesktopShortcut = (deploymentMetadataEntry.DeploymentFlags & 0x200) != 0;
     this._update = new System.Deployment.Application.Manifest.DeploymentUpdate(deploymentMetadataEntry);
     this._minimumRequiredVersion = (deploymentMetadataEntry.MinimumRequiredVersion != null) ? new Version(deploymentMetadataEntry.MinimumRequiredVersion) : null;
     this._codebaseUri            = AssemblyManifest.UriFromMetadataEntry(deploymentMetadataEntry.DeploymentProviderCodebase, "Ex_DepProviderNotValid");
 }
Example #19
0
 public Deployment(DeploymentMetadataEntry deploymentMetadataEntry)
 {
     this._disallowUrlActivation = (deploymentMetadataEntry.DeploymentFlags & 128U) > 0U;
     this._install               = (deploymentMetadataEntry.DeploymentFlags & 32U) > 0U;
     this._trustURLParameters    = (deploymentMetadataEntry.DeploymentFlags & 64U) > 0U;
     this._mapFileExtensions     = (deploymentMetadataEntry.DeploymentFlags & 256U) > 0U;
     this._createDesktopShortcut = (deploymentMetadataEntry.DeploymentFlags & 512U) > 0U;
     this._update = new DeploymentUpdate(deploymentMetadataEntry);
     this._minimumRequiredVersion = deploymentMetadataEntry.MinimumRequiredVersion != null ? new Version(deploymentMetadataEntry.MinimumRequiredVersion) : (Version)null;
     this._codebaseUri            = AssemblyManifest.UriFromMetadataEntry(deploymentMetadataEntry.DeploymentProviderCodebase, "Ex_DepProviderNotValid");
 }
Example #20
0
        static AssemblyTranslator CreateTranslator(
            Configuration configuration, AssemblyManifest manifest, AssemblyCache assemblyCache
            )
        {
            TypeInfoProvider typeInfoProvider = null;

            if (
                configuration.ReuseTypeInfoAcrossAssemblies.GetValueOrDefault(true) &&
                (CachedTypeInfoProvider != null)
                )
            {
                if (CachedTypeInfoProviderConfiguration.Assemblies.Equals(configuration.Assemblies))
                {
                    typeInfoProvider = CachedTypeInfoProvider;
                }
            }

            var translator = new AssemblyTranslator(
                configuration, typeInfoProvider, manifest, assemblyCache,
                onProxyAssemblyLoaded: (name, classification) => {
                Console.Error.WriteLine("// Loaded proxies from '{0}'", ShortenPath(name));
            }
                );

            translator.Decompiling       += MakeProgressHandler("Decompiling ");
            translator.RunningTransforms += MakeProgressHandler("Translating ");
            translator.Writing           += MakeProgressHandler("Writing JS  ");

            translator.AssemblyLoaded += (fn, classification) => {
                Console.Error.WriteLine("// Loaded {0} ({1})", ShortenPath(fn), classification);
            };
            translator.CouldNotLoadSymbols     += (fn, ex) => {
            };
            translator.CouldNotResolveAssembly += (fn, ex) => {
                Console.Error.WriteLine("// Could not load module {0}: {1}", fn, ex.Message);
            };
            translator.CouldNotDecompileMethod += (fn, ex) => {
                Console.Error.WriteLine("// Could not decompile method {0}: {1}", fn, ex.Message);
            };

            if (typeInfoProvider == null)
            {
                if (CachedTypeInfoProvider != null)
                {
                    CachedTypeInfoProvider.Dispose();
                }

                CachedTypeInfoProvider = translator.GetTypeInfoProvider();
                CachedTypeInfoProviderConfiguration = configuration;
            }

            return(translator);
        }
 private static void ProcessDownloadedFile(object sender, DownloadEventArgs e)
 {
     if (e.Cookie != null)
     {
         string         fileName   = Path.GetFileName(e.FileLocalPath);
         FileDownloader downloader = (FileDownloader)sender;
         if ((e.FileResponseUri != null) && !e.FileResponseUri.Equals(e.FileSourceUri))
         {
             throw new InvalidDeploymentException(ExceptionTypes.AppFileLocationValidation, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_DownloadAppFileAsmRedirected"), new object[] { fileName }));
         }
         DependencyDownloadCookie cookie = (DependencyDownloadCookie)e.Cookie;
         if (cookie.ManifestElement is DependentAssembly)
         {
             DependentAssembly manifestElement  = (DependentAssembly)cookie.ManifestElement;
             AssemblyManifest  deployManifest   = cookie.DeployManifest;
             AssemblyManifest  appManifest      = cookie.AppManifest;
             AssemblyManifest  assemblyManifest = new AssemblyManifest(e.FileLocalPath);
             if (!assemblyManifest.Identity.Matches(manifestElement.Identity, true))
             {
                 throw new InvalidDeploymentException(ExceptionTypes.RefDefValidation, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_DownloadRefDefMismatch"), new object[] { fileName }));
             }
             if (assemblyManifest.Identity.Equals(deployManifest.Identity) || assemblyManifest.Identity.Equals(appManifest.Identity))
             {
                 throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_AppPrivAsmIdSameAsDeployOrApp"), new object[] { assemblyManifest.Identity.ToString() }));
             }
             System.Deployment.Application.Manifest.File[] files = assemblyManifest.Files;
             for (int i = 0; i < files.Length; i++)
             {
                 Uri fileSourceUri = MapFileSourceUri(deployManifest, e.FileSourceUri, files[i].Name);
                 if (!fileSourceUri.AbsoluteUri.Equals(e.FileSourceUri.AbsoluteUri, StringComparison.OrdinalIgnoreCase))
                 {
                     string directoryName = Path.GetDirectoryName(e.FileLocalPath);
                     AddFileToDownloader(downloader, deployManifest, appManifest, files[i], fileSourceUri, directoryName, files[i].NameFS, files[i].HashCollection);
                 }
             }
             downloader.ComponentVerifier.AddFileForVerification(e.FileLocalPath, manifestElement.HashCollection);
             if (assemblyManifest.Identity.PublicKeyToken == null)
             {
                 downloader.ComponentVerifier.AddSimplyNamedAssemblyForVerification(e.FileLocalPath, assemblyManifest);
             }
             else
             {
                 downloader.ComponentVerifier.AddStrongNameAssemblyForVerification(e.FileLocalPath, assemblyManifest);
             }
         }
         else if (cookie.ManifestElement is System.Deployment.Application.Manifest.File)
         {
             System.Deployment.Application.Manifest.File file = (System.Deployment.Application.Manifest.File)cookie.ManifestElement;
             downloader.ComponentVerifier.AddFileForVerification(e.FileLocalPath, file.HashCollection);
         }
     }
 }
        public static void VerifySimplyNamedAssembly(string filePath, AssemblyManifest assemblyManifest)
        {
            string fileName = Path.GetFileName(filePath);

            if (assemblyManifest.Identity.PublicKeyToken != null)
            {
                throw new InvalidDeploymentException(ExceptionTypes.Validation, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_SimplyNamedAsmWithPKT"), new object[] { fileName }));
            }
            if (((assemblyManifest.ManifestSourceFormat == ManifestSourceFormat.ID_1) && (assemblyManifest.ComplibIdentity != null)) && (assemblyManifest.ComplibIdentity.PublicKeyToken != null))
            {
                throw new InvalidDeploymentException(ExceptionTypes.IdentityMatchValidationForMixedModeAssembly, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_SimplyNamedAsmWithStrongNameComplib"), new object[] { fileName }));
            }
        }
        protected static void VerifyManifestComponentFiles(AssemblyManifest manifest, string componentPath, bool ignoreSelfReferentialFileHash)
        {
            string directoryName = Path.GetDirectoryName(componentPath);

            foreach (System.Deployment.Application.Manifest.File file in manifest.Files)
            {
                string strB = Path.Combine(directoryName, file.NameFS);
                if ((!ignoreSelfReferentialFileHash || (string.Compare(componentPath, strB, StringComparison.OrdinalIgnoreCase) != 0)) && System.IO.File.Exists(strB))
                {
                    VerifyFileHash(strB, file.HashCollection);
                }
            }
        }
Example #24
0
        public DependentAssembly(System.Deployment.Internal.Isolation.Manifest.AssemblyReferenceEntry assemblyReferenceEntry)
        {
            this._hashCollection = new System.Deployment.Application.HashCollection();
            System.Deployment.Internal.Isolation.Manifest.AssemblyReferenceDependentAssemblyEntry dependentAssembly = assemblyReferenceEntry.DependentAssembly;
            this._size     = dependentAssembly.Size;
            this._codebase = dependentAssembly.Codebase;
            this._group    = dependentAssembly.Group;
            bool flag = false;

            System.Deployment.Internal.Isolation.ISection hashElements = dependentAssembly.HashElements;
            uint celt = (hashElements != null) ? hashElements.Count : 0;

            if (celt > 0)
            {
                uint celtFetched = 0;
                System.Deployment.Internal.Isolation.Manifest.IHashElementEntry[] rgelt = new System.Deployment.Internal.Isolation.Manifest.IHashElementEntry[celt];
                System.Deployment.Internal.Isolation.IEnumUnknown unknown = (System.Deployment.Internal.Isolation.IEnumUnknown)hashElements._NewEnum;
                Marshal.ThrowExceptionForHR(unknown.Next(celt, rgelt, ref celtFetched));
                if (celtFetched != celt)
                {
                    throw new InvalidDeploymentException(ExceptionTypes.Manifest, Resources.GetString("Ex_IsoEnumFetchNotEqualToCount"));
                }
                for (uint i = 0; i < celt; i++)
                {
                    System.Deployment.Internal.Isolation.Manifest.HashElementEntry allData = rgelt[i].AllData;
                    if (allData.DigestValueSize > 0)
                    {
                        byte[] destination = new byte[allData.DigestValueSize];
                        Marshal.Copy(allData.DigestValue, destination, 0, (int)allData.DigestValueSize);
                        this._hashCollection.AddHash(destination, (System.Deployment.Internal.Isolation.Manifest.CMS_HASH_DIGESTMETHOD)allData.DigestMethod, (System.Deployment.Internal.Isolation.Manifest.CMS_HASH_TRANSFORM)allData.Transform);
                        flag = true;
                    }
                }
            }
            if (!flag && (dependentAssembly.HashValueSize > 0))
            {
                byte[] buffer2 = new byte[dependentAssembly.HashValueSize];
                Marshal.Copy(dependentAssembly.HashValue, buffer2, 0, (int)dependentAssembly.HashValueSize);
                this._hashCollection.AddHash(buffer2, (System.Deployment.Internal.Isolation.Manifest.CMS_HASH_DIGESTMETHOD)dependentAssembly.HashAlgorithm, System.Deployment.Internal.Isolation.Manifest.CMS_HASH_TRANSFORM.CMS_HASH_TRANSFORM_IDENTITY);
            }
            this._preRequisite = (dependentAssembly.Flags & 4) != 0;
            this._optional     = (assemblyReferenceEntry.Flags & 1) != 0;
            this._visible      = (dependentAssembly.Flags & 2) != 0;
            this._resourceFallbackCultureInternal = (dependentAssembly.Flags & 8) != 0;
            this._resourceFallbackCulture         = dependentAssembly.ResourceFallbackCulture;
            this._description = dependentAssembly.Description;
            this._supportUrl  = AssemblyManifest.UriFromMetadataEntry(dependentAssembly.SupportUrl, "Ex_DependencySupportUrlNotValid");
            System.Deployment.Internal.Isolation.IReferenceIdentity referenceIdentity = assemblyReferenceEntry.ReferenceIdentity;
            this._identity   = new System.Deployment.Application.ReferenceIdentity(referenceIdentity);
            this._codebaseFS = UriHelper.NormalizePathDirectorySeparators(this._codebase);
        }
 private static void CheckMinimumRequiredVersion(SubscriptionState subState, AssemblyManifest deployment)
 {
     if (subState.MinimumRequiredVersion != null)
     {
         if (deployment.Identity.Version < subState.MinimumRequiredVersion)
         {
             throw new DeploymentException(ExceptionTypes.SubscriptionState, Resources.GetString("Ex_DeploymentBelowMinimumRequiredVersion"));
         }
         if ((deployment.Deployment.MinimumRequiredVersion != null) && (deployment.Deployment.MinimumRequiredVersion < subState.MinimumRequiredVersion))
         {
             throw new DeploymentException(ExceptionTypes.SubscriptionState, Resources.GetString("Ex_DecreasingMinimumRequiredVersion"));
         }
     }
 }
 public void CheckCustomUXFlag(SubscriptionState subState, AssemblyManifest application)
 {
     if (subState.IsInstalled)
     {
         if (application.EntryPoints[0].CustomUX && (subState.appType != AppType.CustomUX))
         {
             throw new DeploymentException(Resources.GetString("Ex_CustomUXAlready"));
         }
         if (!application.EntryPoints[0].CustomUX && (subState.appType == AppType.CustomUX))
         {
             throw new DeploymentException(Resources.GetString("Ex_NotCustomUXAlready"));
         }
     }
 }
Example #27
0
 public void SetApplicationManifest(AssemblyManifest manifest, Uri manifestUri, string manifestPath)
 {
     base.AppManifest     = manifest;
     base.AppSourceUri    = manifestUri;
     base.AppManifestPath = manifestPath;
     if (base.AppManifest.EntryPoints[0].CustomHostSpecified)
     {
         base.appType = AppType.CustomHostSpecified;
     }
     if (base.AppManifest.EntryPoints[0].CustomUX)
     {
         base.appType = AppType.CustomUX;
     }
 }
        private static void AddFilesInHashtable(Hashtable hashtable, AssemblyManifest applicationManifest, string applicationFolder)
        {
            Logger.AddMethodCall("AddFilesInHashtable called.");
            Logger.AddInternalState("applicationFolder=" + applicationFolder);
            string location = null;

            foreach (System.Deployment.Application.Manifest.File file in applicationManifest.Files)
            {
                location = Path.Combine(applicationFolder, file.NameFS);
                try
                {
                    AddSingleFileInHashtable(hashtable, file.HashCollection, location);
                }
                catch (IOException exception)
                {
                    Logger.AddErrorInformation(exception, Resources.GetString("Ex_PatchDependencyFailed"), new object[] { Path.GetFileName(location) });
                    Logger.AddInternalState("Exception thrown : " + exception.GetType().ToString() + ":" + exception.Message);
                }
            }
            foreach (DependentAssembly assembly in applicationManifest.DependentAssemblies)
            {
                if (!assembly.IsPreRequisite)
                {
                    location = Path.Combine(applicationFolder, assembly.Codebase);
                    try
                    {
                        if (AddSingleFileInHashtable(hashtable, assembly.HashCollection, location))
                        {
                            AssemblyManifest manifest = new AssemblyManifest(location);
                            System.Deployment.Application.Manifest.File[] files = manifest.Files;
                            for (int i = 0; i < files.Length; i++)
                            {
                                string str2 = Path.Combine(Path.GetDirectoryName(location), files[i].NameFS);
                                AddSingleFileInHashtable(hashtable, files[i].HashCollection, str2);
                            }
                        }
                    }
                    catch (InvalidDeploymentException exception2)
                    {
                        Logger.AddErrorInformation(exception2, Resources.GetString("Ex_PatchDependencyFailed"), new object[] { Path.GetFileName(location) });
                        Logger.AddInternalState("Exception thrown : " + exception2.GetType().ToString() + ":" + exception2.Message);
                    }
                    catch (IOException exception3)
                    {
                        Logger.AddErrorInformation(exception3, Resources.GetString("Ex_PatchDependencyFailed"), new object[] { Path.GetFileName(location) });
                        Logger.AddInternalState("Exception thrown : " + exception3.GetType().ToString() + ":" + exception3.Message);
                    }
                }
            }
        }
Example #29
0
 public void SetApplicationManifest(AssemblyManifest manifest, Uri manifestUri, string manifestPath)
 {
     this.AppManifest     = manifest;
     this.AppSourceUri    = manifestUri;
     this.AppManifestPath = manifestPath;
     if (this.AppManifest.EntryPoints[0].CustomHostSpecified)
     {
         this.appType = AppType.CustomHostSpecified;
     }
     if (!this.AppManifest.EntryPoints[0].CustomUX)
     {
         return;
     }
     this.appType = AppType.CustomUX;
 }
Example #30
0
        internal static AssemblyManifest FromDocumentNoValidation(string localPath)
        {
            CodeMarker_Singleton.Instance.CodeMarker(7302);
            Logger.AddMethodCall("ManifestReader.FromDocumentNoValidation(" + 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))
                assemblyManifest = new AssemblyManifest(fileStream);
            CodeMarker_Singleton.Instance.CodeMarker(7303);
            return(assemblyManifest);
        }
Example #31
0
        public DependentAssembly(AssemblyReferenceEntry assemblyReferenceEntry)
        {
            AssemblyReferenceDependentAssemblyEntry dependentAssembly = assemblyReferenceEntry.DependentAssembly;

            this._size     = dependentAssembly.Size;
            this._codebase = dependentAssembly.Codebase;
            this._group    = dependentAssembly.Group;
            bool     flag         = false;
            ISection hashElements = dependentAssembly.HashElements;
            uint     celt         = hashElements != null ? hashElements.Count : 0U;

            if (celt > 0U)
            {
                uint celtFetched = 0;
                IHashElementEntry[] hashElementEntryArray = new IHashElementEntry[(int)celt];
                Marshal.ThrowExceptionForHR(((System.Deployment.Internal.Isolation.IEnumUnknown)hashElements._NewEnum).Next(celt, (object[])hashElementEntryArray, ref celtFetched));
                if ((int)celtFetched != (int)celt)
                {
                    throw new InvalidDeploymentException(ExceptionTypes.Manifest, Resources.GetString("Ex_IsoEnumFetchNotEqualToCount"));
                }
                for (uint index = 0; index < celt; ++index)
                {
                    HashElementEntry allData = hashElementEntryArray[(int)index].AllData;
                    if (allData.DigestValueSize > 0U)
                    {
                        byte[] numArray = new byte[(int)allData.DigestValueSize];
                        Marshal.Copy(allData.DigestValue, numArray, 0, (int)allData.DigestValueSize);
                        this._hashCollection.AddHash(numArray, (CMS_HASH_DIGESTMETHOD)allData.DigestMethod, (CMS_HASH_TRANSFORM)allData.Transform);
                        flag = true;
                    }
                }
            }
            if (!flag && dependentAssembly.HashValueSize > 0U)
            {
                byte[] numArray = new byte[(int)dependentAssembly.HashValueSize];
                Marshal.Copy(dependentAssembly.HashValue, numArray, 0, (int)dependentAssembly.HashValueSize);
                this._hashCollection.AddHash(numArray, (CMS_HASH_DIGESTMETHOD)dependentAssembly.HashAlgorithm, CMS_HASH_TRANSFORM.CMS_HASH_TRANSFORM_IDENTITY);
            }
            this._preRequisite = (dependentAssembly.Flags & 4U) > 0U;
            this._optional     = (assemblyReferenceEntry.Flags & 1U) > 0U;
            this._visible      = (dependentAssembly.Flags & 2U) > 0U;
            this._resourceFallbackCultureInternal = (dependentAssembly.Flags & 8U) > 0U;
            this._resourceFallbackCulture         = dependentAssembly.ResourceFallbackCulture;
            this._description = dependentAssembly.Description;
            this._supportUrl  = AssemblyManifest.UriFromMetadataEntry(dependentAssembly.SupportUrl, "Ex_DependencySupportUrlNotValid");
            this._identity    = new System.Deployment.Application.ReferenceIdentity(assemblyReferenceEntry.ReferenceIdentity);
            this._codebaseFS  = System.Deployment.Application.UriHelper.NormalizePathDirectorySeparators(this._codebase);
        }
Example #32
0
        static AssemblyTranslator CreateTranslator(
            Configuration configuration, AssemblyManifest manifest, AssemblyCache assemblyCache
        )
        {
            TypeInfoProvider typeInfoProvider = null;

            if (
                configuration.ReuseTypeInfoAcrossAssemblies.GetValueOrDefault(true) &&
                (CachedTypeInfoProvider != null)
            ) {
                if (CachedTypeInfoProviderConfiguration.Assemblies.Equals(configuration.Assemblies))
                    typeInfoProvider = CachedTypeInfoProvider;
            }

            var translator = new AssemblyTranslator(
                configuration, typeInfoProvider, manifest, assemblyCache,
                onProxyAssemblyLoaded: (name) => {
                    Console.Error.WriteLine("// Loaded proxies from '{0}'", ShortenPath(name));
                }
            );

            translator.Decompiling += MakeProgressHandler       ("Decompiling ");
            translator.RunningTransforms += MakeProgressHandler ("Translating ");
            translator.Writing += MakeProgressHandler           ("Writing JS  ");

            translator.AssemblyLoaded += (fn) => {
                Console.Error.WriteLine("// Loaded {0}", ShortenPath(fn));
            };
            translator.CouldNotLoadSymbols += (fn, ex) => {
            };
            translator.CouldNotResolveAssembly += (fn, ex) => {
                Console.Error.WriteLine("// Could not load module {0}: {1}", fn, ex.Message);
            };
            translator.CouldNotDecompileMethod += (fn, ex) => {
                Console.Error.WriteLine("// Could not decompile method {0}: {1}", fn, ex.Message);
            };

            if (typeInfoProvider == null) {
                if (CachedTypeInfoProvider != null)
                    CachedTypeInfoProvider.Dispose();

                CachedTypeInfoProvider = translator.GetTypeInfoProvider();
                CachedTypeInfoProviderConfiguration = configuration;
            }

            return translator;
        }
Example #33
0
        static AssemblyTranslator CreateTranslator(Configuration configuration, AssemblyManifest manifest, AssemblyCache assemblyCache)
        {
            var translator = new AssemblyTranslator(configuration, null, manifest, assemblyCache);

            translator.Decompiling += MakeProgressHandler("Decompiling   ");
            translator.Optimizing += MakeProgressHandler ("Optimizing    ");
            translator.Writing += MakeProgressHandler    ("Generating JS ");

            translator.AssemblyLoaded += (fn) => {
                Console.Error.WriteLine("// Loaded {0}", ShortenPath(fn));
            };
            translator.CouldNotLoadSymbols += (fn, ex) => {
            };
            translator.CouldNotResolveAssembly += (fn, ex) => {
                Console.Error.WriteLine("// Could not load module {0}: {1}", fn, ex.Message);
            };
            translator.CouldNotDecompileMethod += (fn, ex) => {
                Console.Error.WriteLine("// Could not decompile method {0}: {1}", fn, ex.Message);
            };

            return translator;
        }
Example #34
0
        static void Main(string[] arguments)
        {
            SolutionBuilder.SolutionBuilder.HandleCommandLine();

            var buildGroups = new List<BuildGroup>();
            var profiles = new Dictionary<string, IProfile>();
            var manifest = new AssemblyManifest();
            var assemblyCache = new AssemblyCache();

            var commandLineConfiguration = ParseCommandLine(arguments, buildGroups, profiles);

            if ((buildGroups.Count < 1) || (commandLineConfiguration == null)) {
                Console.Error.WriteLine("// No assemblies specified to translate. Exiting.");
            }

            int totalFailureCount = 0;

            foreach (var buildGroup in buildGroups) {
                var config = buildGroup.BaseConfiguration;
                var variables = buildGroup.BaseVariables;

                foreach (var filename in buildGroup.FilesToBuild) {
                    if (config.Assemblies.Ignored.Any(
                        (ignoreRegex) => Regex.IsMatch(filename, ignoreRegex, RegexOptions.IgnoreCase))
                    ) {
                        Console.Error.WriteLine("// Ignoring build result '{0}' based on configuration.", Path.GetFileName(filename));
                        continue;
                    }

                    var fileConfigPath = Path.Combine(
                        Path.GetDirectoryName(filename),
                        String.Format("{0}.jsilconfig", Path.GetFileName(filename))
                    );
                    var fileConfig = File.Exists(fileConfigPath)
                        ? new Configuration[] { LoadConfiguration(fileConfigPath), commandLineConfiguration }
                        : new Configuration[] { commandLineConfiguration };

                    var localConfig = MergeConfigurations(config, fileConfig);

                    var localProfile = buildGroup.Profile;
                    if (localConfig.Profile != null) {
                        if (profiles.ContainsKey(localConfig.Profile))
                            localProfile = profiles[localConfig.Profile];
                        else
                            throw new Exception(String.Format(
                                "No profile named '{0}' was found. Did you load the correct profile assembly?", localConfig.Profile
                            ));
                    }

                    localConfig = localProfile.GetConfiguration(localConfig);
                    var localVariables = localConfig.ApplyTo(variables);

                    var assemblyPath = Path.GetDirectoryName(Path.GetFullPath(filename));
                    localVariables["AssemblyDirectory"] = () => assemblyPath;

                    var newProxies = (from p in localConfig.Assemblies.Proxies
                                      let newP = MapPath(p, localVariables, true, true)
                                      where newP != null
                                      select newP).ToArray();

                    localConfig.Assemblies.Proxies.Clear();
                    localConfig.Assemblies.Proxies.AddRange(newProxies);

                    using (var translator = CreateTranslator(localConfig, manifest, assemblyCache)) {
                        var ignoredMethods = new List<KeyValuePair<string, string[]>>();
                        translator.IgnoredMethod += (methodName, variableNames) =>
                            ignoredMethods.Add(new KeyValuePair<string, string[]>(methodName, variableNames));

                        var outputs = buildGroup.Profile.Translate(localVariables, translator, localConfig, filename, localConfig.UseLocalProxies.GetValueOrDefault(true));
                        if (localConfig.OutputDirectory == null)
                            throw new Exception("No output directory was specified!");

                        var outputDir = MapPath(localConfig.OutputDirectory, localVariables, false);
                        CopiedOutputGatherer.EnsureDirectoryExists(outputDir);

                        Console.Error.WriteLine("// Saving output to '{0}'.", ShortenPath(outputDir) + Path.DirectorySeparatorChar);

                        // Ensures that the log file contains the name of the profile that was actually used.
                        localConfig.Profile = localProfile.GetType().Name;

                        if (ignoredMethods.Count > 0)
                            Console.Error.WriteLine("// {0} method(s) were ignored during translation. See the log for a list.", ignoredMethods.Count);

                        EmitLog(outputDir, localConfig, filename, outputs, ignoredMethods);

                        buildGroup.Profile.WriteOutputs(localVariables, outputs, outputDir, Path.GetFileName(filename) + ".");

                        totalFailureCount += translator.Failures.Count;
                    }
                }
            }

            if (Environment.UserInteractive && Debugger.IsAttached) {
                Console.Error.WriteLine("// Press the any key to continue.");
                Console.ReadKey();
            }

            Environment.ExitCode = totalFailureCount;
        }
Example #35
0
        static void Main(string[] arguments)
        {
            var buildGroups = new List<BuildGroup>();
            var profiles = new Dictionary<string, IProfile>();
            var manifest = new AssemblyManifest();
            var assemblyCache = new AssemblyCache();

            ParseCommandLine(arguments, buildGroups, profiles);

            if (buildGroups.Count < 1) {
                Console.Error.WriteLine("// No assemblies specified to translate. Exiting.");
                return;
            }

            foreach (var buildGroup in buildGroups) {
                var config = buildGroup.BaseConfiguration;
                if (config.ApplyDefaults.GetValueOrDefault(true))
                    config = MergeConfigurations(LoadConfiguration("defaults.jsilconfig"), config);

                foreach (var filename in buildGroup.FilesToBuild) {
                    // GC.Collect();

                    if (config.Assemblies.Ignored.Any(
                        (ignoreRegex) => Regex.IsMatch(filename, ignoreRegex, RegexOptions.IgnoreCase))
                    ) {
                        Console.Error.WriteLine("// Ignoring build result '{0}' based on configuration.", Path.GetFileName(filename));
                        continue;
                    }

                    var fileConfigPath = Path.Combine(
                        Path.GetDirectoryName(filename),
                        String.Format("{0}.jsilconfig", Path.GetFileName(filename))
                    );
                    var fileConfig = File.Exists(fileConfigPath)
                        ? new Configuration[] { LoadConfiguration(fileConfigPath) }
                        : new Configuration[] { };

                    var localConfig = MergeConfigurations(config, fileConfig);

                    var localProfile = buildGroup.Profile;
                    if (localConfig.Profile != null) {
                        if (profiles.ContainsKey(localConfig.Profile))
                            localProfile = profiles[localConfig.Profile];
                        else
                            throw new Exception(String.Format(
                                "No profile named '{0}' was found. Did you load the correct profile assembly?", localConfig.Profile
                            ));
                    }

                    localConfig = localProfile.GetConfiguration(localConfig);

                    var assemblyPath = Path.GetDirectoryName(Path.GetFullPath(filename));

                    var newProxies = (from p in localConfig.Assemblies.Proxies
                                      let newP = MapAssemblyPath(p, assemblyPath, true, true)
                                      where newP != null
                                      select newP).ToArray();

                    localConfig.Assemblies.Proxies.Clear();
                    localConfig.Assemblies.Proxies.AddRange(newProxies);

                    using (var translator = CreateTranslator(localConfig, manifest, assemblyCache)) {
                        var outputs = buildGroup.Profile.Translate(translator, localConfig, filename, localConfig.UseLocalProxies.GetValueOrDefault(true));
                        if (localConfig.OutputDirectory == null)
                            throw new Exception("No output directory was specified!");

                        var outputDir = MapAssemblyPath(localConfig.OutputDirectory, assemblyPath, false);

                        Console.Error.WriteLine("// Saving output to '{0}'.", ShortenPath(outputDir) + Path.DirectorySeparatorChar);

                        // Ensures that the log file contains the name of the profile that was actually used.
                        localConfig.Profile = localProfile.GetType().Name;

                        EmitLog(outputDir, localConfig, filename, outputs);

                        buildGroup.Profile.WriteOutputs(outputs, outputDir, Path.GetFileName(filename) + ".");
                    }
                }
            }
        }