public BindDatabaseCommand(IBindContext context, IEnumerable <IWindowsInstallerBackendBinderExtension> backendExtension, IEnumerable <SubStorage> subStorages, string cubeFile)
        {
            this.ServiceProvider = context.ServiceProvider;

            this.Messaging = context.ServiceProvider.GetService <IMessaging>();

            this.WindowsInstallerBackendHelper = context.ServiceProvider.GetService <IWindowsInstallerBackendHelper>();

            this.PathResolver = this.ServiceProvider.GetService <IPathResolver>();

            this.CabbingThreadCount      = context.CabbingThreadCount;
            this.CabCachePath            = context.CabCachePath;
            this.DefaultCompressionLevel = context.DefaultCompressionLevel;
            this.DelayedFields           = context.DelayedFields;
            this.ExpectedEmbeddedFiles   = context.ExpectedEmbeddedFiles;
            this.FileSystemManager       = new FileSystemManager(context.FileSystemExtensions);
            this.Intermediate            = context.IntermediateRepresentation;
            this.IntermediateFolder      = context.IntermediateFolder;
            this.OutputPath       = context.OutputPath;
            this.OutputPdbPath    = context.PdbPath;
            this.PdbType          = context.PdbType;
            this.ResolvedCodepage = context.ResolvedCodepage;
            this.ResolvedSummaryInformationCodepage = context.ResolvedSummaryInformationCodepage;
            this.ResolvedLcid   = context.ResolvedLcid;
            this.SuppressLayout = context.SuppressLayout;

            this.SubStorages = subStorages;

            this.SuppressValidation = context.SuppressValidation;
            this.Ices           = context.Ices;
            this.SuppressedIces = context.SuppressIces;
            this.CubeFiles      = String.IsNullOrEmpty(cubeFile) ? null : new[] { cubeFile };

            this.BackendExtensions = backendExtension;
        }
Example #2
0
        public IBindResult Bind(IBindContext context)
        {
            // Prebind.
            //
            foreach (var extension in context.Extensions)
            {
                extension.PreBind(context);
            }

            // Bind.
            //
            this.WriteBuildInfoSymbol(context.IntermediateRepresentation, context.OutputPath, context.PdbPath);

            var bindResult = this.BackendBind(context);

            if (bindResult != null)
            {
                // Postbind.
                //
                foreach (var extension in context.Extensions)
                {
                    extension.PostBind(bindResult);
                }
            }

            return(bindResult);
        }
Example #3
0
        public IBindResult Bind(IBindContext context)
        {
            var extensionManager = context.ServiceProvider.GetService <IExtensionManager>();

            var backendExtensions = extensionManager.GetServices <IBurnBackendExtension>();

            foreach (var extension in backendExtensions)
            {
                extension.PreBackendBind(context);
            }

            var command = new BindBundleCommand(context, backendExtensions);

            command.Execute();

            var result = context.ServiceProvider.GetService <IBindResult>();

            result.FileTransfers = command.FileTransfers;
            result.TrackedFiles  = command.TrackedFiles;
            result.Wixout        = command.Wixout;

            foreach (var extension in backendExtensions)
            {
                extension.PostBackendBind(result);
            }

            return(result);
        }
Example #4
0
        public BindDatabaseCommand(IBindContext context, IEnumerable <IWindowsInstallerBackendBinderExtension> backendExtension, IEnumerable <SubStorage> subStorages, Validator validator)
        {
            this.ServiceProvider = context.ServiceProvider;

            this.Messaging = context.ServiceProvider.GetService <IMessaging>();

            this.BackendHelper = context.ServiceProvider.GetService <IBackendHelper>();
            this.WindowsInstallerBackendHelper = context.ServiceProvider.GetService <IWindowsInstallerBackendHelper>();

            this.PathResolver = this.ServiceProvider.GetService <IPathResolver>();

            this.CabbingThreadCount      = context.CabbingThreadCount;
            this.CabCachePath            = context.CabCachePath;
            this.Codepage                = context.Codepage;
            this.DefaultCompressionLevel = context.DefaultCompressionLevel;
            this.DelayedFields           = context.DelayedFields;
            this.ExpectedEmbeddedFiles   = context.ExpectedEmbeddedFiles;
            this.FileSystemManager       = new FileSystemManager(context.FileSystemExtensions);
            this.Intermediate            = context.IntermediateRepresentation;
            this.IntermediateFolder      = context.IntermediateFolder;
            this.OutputPath              = context.OutputPath;
            this.OutputPdbPath           = context.PdbPath;
            this.PdbType        = context.PdbType;
            this.SuppressLayout = context.SuppressLayout;

            this.SubStorages = subStorages;
            this.Validator   = validator;

            this.BackendExtensions = backendExtension;
        }
        public IBindResult Bind(IBindContext context)
        {
            var extensionManager = context.ServiceProvider.GetService <IExtensionManager>();

            var backendExtensions = extensionManager.GetServices <IWindowsInstallerBackendBinderExtension>();

            foreach (var extension in backendExtensions)
            {
                extension.PreBackendBind(context);
            }

            var validator = Validator.CreateFromContext(context, "mergemod.cub");

            IBindResult result = null;

            try
            {
                var command = new BindDatabaseCommand(context, backendExtensions, validator);
                result = command.Execute();

                foreach (var extension in backendExtensions)
                {
                    extension.PostBackendBind(result);
                }

                return(result);
            }
            catch
            {
                result?.Dispose();
                throw;
            }
        }
Example #6
0
        public IBindResult Bind(IBindContext context)
        {
            var extensionManager = context.ServiceProvider.GetService <IExtensionManager>();

            var backendExtensions = extensionManager.GetServices <IWindowsInstallerBackendBinderExtension>();

            foreach (var extension in backendExtensions)
            {
                extension.PreBackendBind(context);
            }

            IBindResult result  = null;
            var         dispose = true;

            try
            {
                var command = new BindDatabaseCommand(context, backendExtensions, "darice.cub");
                result = command.Execute();

                foreach (var extension in backendExtensions)
                {
                    extension.PostBackendBind(result);
                }

                dispose = false;
                return(result);
            }
            finally
            {
                if (dispose)
                {
                    result?.Dispose();
                }
            }
        }
        public BindResult Bind(IBindContext context)
        {
            var extensionManager = context.ServiceProvider.GetService <IExtensionManager>();

            var backendExtensions = extensionManager.Create <IWindowsInstallerBackendBinderExtension>();

            foreach (var extension in backendExtensions)
            {
                extension.PreBackendBind(context);
            }

            var validator = Validator.CreateFromContext(context, "mergemod.cub");

            var command = new BindDatabaseCommand(context, backendExtensions, validator);

            command.Execute();

            var result = new BindResult {
                FileTransfers = command.FileTransfers, TrackedFiles = command.TrackedFiles
            };

            foreach (var extension in backendExtensions)
            {
                extension.PostBackendBind(result, command.Pdb);
            }

            if (!String.IsNullOrEmpty(context.OutputPdbPath))
            {
                command.Pdb?.Save(context.OutputPdbPath);
            }

            return(result);
        }
        /// <summary>
        /// Called before database binding occurs.
        /// </summary>
        public override void PreBackendBind(IBindContext context)
        {
            base.PreBackendBind(context);

            this.backendHelper = base.BackendHelper;

            this.workingFolder = CalculateWorkingFolder(context.IntermediateFolder);
        }
        /// <summary>
        /// See <see cref="IWindowsInstallerBackendBinderExtension.PreBackendBind(IBindContext)"/>
        /// </summary>
        public virtual void PreBackendBind(IBindContext context)
        {
            this.Context = context;

            this.Messaging = context.ServiceProvider.GetService <IMessaging>();

            this.BackendHelper = context.ServiceProvider.GetService <IWindowsInstallerBackendHelper>();
        }
Example #10
0
        public BindBundleCommand(IBindContext context)
        {
            //this.TableDefinitions = WindowsInstallerStandard.GetTableDefinitions();

            this.DelayedFields         = context.DelayedFields;
            this.ExpectedEmbeddedFiles = context.ExpectedEmbeddedFiles;

            var extensionManager = context.ServiceProvider.GetService <IExtensionManager>();

            this.BackendExtensions = extensionManager.Create <IBurnBackendExtension>();
        }
Example #11
0
        public IBindResult Bind(IBindContext context)
        {
            var messaging = context.ServiceProvider.GetService <IMessaging>();

            var backendHelper = context.ServiceProvider.GetService <IBackendHelper>();

            var extensionManager = context.ServiceProvider.GetService <IExtensionManager>();

            var backendExtensions = extensionManager.GetServices <IWindowsInstallerBackendBinderExtension>();

            foreach (var extension in backendExtensions)
            {
                extension.PreBackendBind(context);
            }

            // Create transforms named in patch transforms.
            IEnumerable <PatchTransform> patchTransforms;
            {
                var command = new CreatePatchTransformsCommand(messaging, backendHelper, context.IntermediateRepresentation, context.IntermediateFolder);
                patchTransforms = command.Execute();
            }

            // Enhance the intermediate by attaching the created patch transforms.
            IEnumerable <SubStorage> subStorages;
            {
                var command = new AttachPatchTransformsCommand(messaging, backendHelper, context.IntermediateRepresentation, patchTransforms);
                subStorages = command.Execute();
            }

            // Create WindowsInstallerData with patch metdata and transforms as sub-storages
            // Create MSP from WindowsInstallerData
            IBindResult result = null;

            try
            {
                var command = new BindDatabaseCommand(context, backendExtensions, subStorages, null);
                result = command.Execute();

                foreach (var extension in backendExtensions)
                {
                    extension.PostBackendBind(result);
                }

                return(result);
            }
            catch
            {
                result?.Dispose();
                throw;
            }
        }
Example #12
0
        public IBindResult Bind(IBindContext context)
        {
#if TODO_PATCHING
            var command = new BindTransformCommand();
            command.Extensions        = context.Extensions;
            command.TempFilesLocation = context.IntermediateFolder;
            command.Transform         = context.IntermediateRepresentation;
            command.OutputPath        = context.OutputPath;
            command.Execute();

            return(new BindResult(Array.Empty <FileTransfer>(), Array.Empty <string>()));
#endif
            throw new NotImplementedException();
        }
Example #13
0
        public BindResult Bind(IBindContext context)
        {
            BindBundleCommand command = new BindBundleCommand(context);

            //command.DefaultCompressionLevel = context.DefaultCompressionLevel;
            //command.Extensions = context.Extensions;
            //command.IntermediateFolder = context.IntermediateFolder;
            //command.Output = context.IntermediateRepresentation;
            //command.OutputPath = context.OutputPath;
            //command.PdbFile = context.OutputPdbPath;
            //command.WixVariableResolver = context.WixVariableResolver;
            command.Execute();

            return(new BindResult {
                FileTransfers = command.FileTransfers, ContentFilePaths = command.ContentFilePaths
            });
        }
Example #14
0
        public override async Task <Material> BindAsync(IBindContext context)
        {
            IDocument document = await OpenAsync(context).ConfigureAwait(false);

            Material material = new Material
            {
                SourceName = $classnameprefix$SupportedSource.SourceName
            };

            BindLinks(document, material);
            BindText(document, material);
            BindTitle(document, material);
            BindPublishedAt(document, material);
            BindAuthor(document, material);

            return(material);
        }
Example #15
0
        public bool TryCreateBackend(string outputType, string outputFile, IBindContext context, out IBackend backend)
        {
            if (String.IsNullOrEmpty(outputType))
            {
                outputType = Path.GetExtension(outputFile);
            }

            switch (outputType.ToLowerInvariant())
            {
            case "bundle":
            case ".exe":
                backend = new BundleBackend();
                return(true);
            }

            backend = null;
            return(false);
        }
Example #16
0
        public BindDatabaseCommand(IBindContext context, IEnumerable <IWindowsInstallerBackendExtension> backendExtension, Validator validator)
        {
            this.TableDefinitions = WindowsInstallerStandardInternal.GetTableDefinitions();

            this.CabbingThreadCount      = context.CabbingThreadCount;
            this.CabCachePath            = context.CabCachePath;
            this.Codepage                = context.Codepage;
            this.DefaultCompressionLevel = context.DefaultCompressionLevel;
            this.DelayedFields           = context.DelayedFields;
            this.ExpectedEmbeddedFiles   = context.ExpectedEmbeddedFiles;
            this.FileSystemExtensions    = context.FileSystemExtensions;
            this.Intermediate            = context.IntermediateRepresentation;
            this.Messaging               = context.Messaging;
            this.OutputPath              = context.OutputPath;
            this.IntermediateFolder      = context.IntermediateFolder;
            this.Validator               = validator;

            this.BackendExtensions = backendExtension;
        }
Example #17
0
        public BindBundleCommand(IBindContext context, IEnumerable <IBurnBackendExtension> backedExtensions)
        {
            this.ServiceProvider = context.ServiceProvider;

            this.Messaging = context.ServiceProvider.GetService <IMessaging>();

            this.BackendHelper             = context.ServiceProvider.GetService <IBackendHelper>();
            this.InternalBurnBackendHelper = context.ServiceProvider.GetService <IInternalBurnBackendHelper>();

            this.DefaultCompressionLevel = context.DefaultCompressionLevel;
            this.DelayedFields           = context.DelayedFields;
            this.ExpectedEmbeddedFiles   = context.ExpectedEmbeddedFiles;
            this.IntermediateFolder      = context.IntermediateFolder;
            this.Output        = context.IntermediateRepresentation;
            this.OutputPath    = context.OutputPath;
            this.OutputPdbPath = context.PdbPath;
            //this.VariableResolver = context.VariableResolver;

            this.BackendExtensions = backedExtensions;
        }
Example #18
0
        private IBindResult BackendBind(IBindContext context)
        {
            var extensionManager = context.ServiceProvider.GetService <IExtensionManager>();

            var backendFactories = extensionManager.GetServices <IBackendFactory>();

            var entrySection = context.IntermediateRepresentation.Sections.First();

            foreach (var factory in backendFactories)
            {
                if (factory.TryCreateBackend(entrySection.Type.ToString(), context.OutputPath, out var backend))
                {
                    var result = backend.Bind(context);
                    return(result);
                }
            }

            // TODO: messaging that a backend could not be found to bind the output type?

            return(null);
        }
        public bool TryCreateBackend(string outputType, string outputFile, IBindContext context, out IBackend backend)
        {
            if (String.IsNullOrEmpty(outputType))
            {
                outputType = Path.GetExtension(outputFile);
            }

            switch (outputType.ToLowerInvariant())
            {
            case "module":
            case ".msm":
                backend = new MsmBackend();
                return(true);

            case "msipackage":
            case "product":
            case ".msi":
                backend = new MsiBackend();
                return(true);

            case "patch":
            case ".msp":
                backend = new MspBackend();
                return(true);

            //case "patchcreation":
            //case ".pcp":
            //    return new PatchCreationBackend();

            case "transform":
            case ".mst":
                backend = new MstBackend();
                return(true);
            }

            backend = null;
            return(false);
        }
 public static void ToAssembly <T>(this IBindContext <T> self, Assembly assembly, Action <IScopeContext> scopeHandler = null)
 {
     foreach (var definedType in assembly.DefinedTypes)
     {
         if (!definedType.Implements(typeof(T)))
         {
             continue;
         }
         var           attrib = definedType.GetAttribute <ImplementationKeyAttribute>();
         IScopeContext scope;
         if (attrib != null)
         {
             scope = self.To(definedType, attrib.Name);
         }
         else
         {
             scope = self.To(definedType);
         }
         if (scopeHandler != null)
         {
             scopeHandler(scope);
         }
     }
 }
Example #21
0
        public static Validator CreateFromContext(IBindContext context, string cubeFilename)
        {
            Validator validator = null;
            var       messaging = context.ServiceProvider.GetService <IMessaging>();

            // Tell the binder about the validator if validation isn't suppressed
            if (!context.SuppressValidation)
            {
                validator = new Validator(messaging);
                validator.IntermediateFolder = Path.Combine(context.IntermediateFolder, "validate");

                // set the default cube file
                string thisPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                validator.AddCubeFile(Path.Combine(thisPath, cubeFilename));

                // Set the ICEs
                validator.ICEs = new SortedSet <string>(context.Ices);

                // Set the suppressed ICEs and disable ICEs that have equivalent-or-better checks in WiX.
                validator.SuppressedICEs = new SortedSet <string>(context.SuppressIces.Union(new[] { "ICE08", "ICE33", "ICE47", "ICE66" }));
            }

            return(validator);
        }
Example #22
0
 public BindResult Bind(IBindContext context)
 {
     throw new NotImplementedException();
 }
        public static void ToAssembly <T>(this IBindContext <T> self, string assemblyName, Action <IScopeContext> scopeHandler = null)
        {
            var assembly = Assembly.Load(assemblyName);

            self.ToAssembly(assembly, scopeHandler);
        }
Example #24
0
 public BindContext(IBindContext <T> bind, IDependencyResolver resolver)
 {
     _bind     = bind;
     _resolver = resolver;
 }
Example #25
0
 public BindDatabaseCommand(IBindContext context, IEnumerable <IWindowsInstallerBackendBinderExtension> backendExtension, Validator validator) : this(context, backendExtension, null, validator)
 {
 }
 public BindDatabaseCommand(IBindContext context, IEnumerable <IWindowsInstallerBackendBinderExtension> backendExtension, string cubeFile) : this(context, backendExtension, null, cubeFile)
 {
 }
Example #27
0
 /// <summary>
 /// Called at the beginning of bind.
 /// </summary>
 public virtual void PreBind(IBindContext context)
 {
     this.Context = context;
 }
 public static IScopeContext ToServiceProxy <T>(this IBindContext <T> bindContext, string baseUrl)
 {
     return(bindContext.ToConstructor(ProxyFactory.CreateProxy <T>(), s => new ServiceLocator(s).CreateRestClient <T>(baseUrl)));
 }