Esempio n. 1
0
 private void CheckComponentNodeExists(TreeNode node)
 {
     if (node.Tag != null) /*Normally NULL for root nodes*/
     {
         ComponentNode componentNode = (ComponentNode)node.Tag;
         if (componentNode.SecondaryTreeNode != null && componentNode.SecondaryTreeNode.TreeView == null)
         {
             BuildLogMessage buildMessage = new BuildLogMessage();
             buildMessage.Message = String.Format("Source file of shortcut file: {0} is not found in components tree. Please check whether the component tree structure is maintained.", node.FullPath);
             buildMessage.Type    = LogType.ERROR;
             buildMessage.Module  = Modules.Components;
             BuildLogger.Add(buildMessage);
         }
     }
     foreach (TreeNode childNode in node.Nodes)
     {
         CheckComponentNodeExists(childNode);
     }
 }
Esempio n. 2
0
        void INvnControl.Validate()
        {
            List <BuildLogMessage> tempMessages = new List <BuildLogMessage>();
            BuildLogMessage        logMessage   = null;

            // version number
            logMessage = Validator.ValidateVersionNumber(Version.Text);
            if (logMessage != null)
            {
                BuildLogger.Add(logMessage);
            }
            // check license file exists
            if (String.IsNullOrEmpty(LicenseFile.Text) || System.IO.File.Exists(LicenseFile.Text) == false)
            {
                BuildLogMessage licenseFileMessage = new BuildLogMessage();
                licenseFileMessage.Message = "License file not found";
                licenseFileMessage.Type    = LogType.ERROR;
                licenseFileMessage.Module  = Modules.ProductInformation;
                BuildLogger.Add(licenseFileMessage);// add to the list
            }
            // check Icon file
            if (String.IsNullOrEmpty(IconFile.Text) || System.IO.File.Exists(IconFile.Text) == false)
            {
                BuildLogMessage iconFileMessage = new BuildLogMessage();
                iconFileMessage.Message = "Icon file is not selected. Installer will set default icon for this product.";
                iconFileMessage.Type    = LogType.Warning;
                iconFileMessage.Module  = Modules.ProductInformation;
                BuildLogger.Add(iconFileMessage);// add to the list
            }
            logMessage = Validator.IsNullOrEmpty(Output.Text, "Output file(MSI)", LogType.ERROR, Modules.ProductInformation);
            if (logMessage != null)
            {
                BuildLogger.Add(logMessage);
            }
            //check minimum installer version for empty, integer
            logMessage = Validator.IsNullOrEmpty(txtMajorVersion.Text, "Value 'Major' of minimum installer version", LogType.ERROR, Modules.ProductInformation);
            if (logMessage != null)
            {
                BuildLogger.Add(logMessage);
            }
            if (Common.IsInteger(txtMajorVersion.Text) == false || Common.IsInteger(txtMinorVersion.Text) == false)
            {
                BuildLogMessage iconFileMessage = new BuildLogMessage();
                iconFileMessage.Message = "Value set for minimum installer version is not in valid format.";
                iconFileMessage.Type    = LogType.ERROR;
                iconFileMessage.Module  = Modules.ProductInformation;
                BuildLogger.Add(iconFileMessage);// add to the list
            }
            // validate URLs
            logMessage = Validator.ValidateUrl("Manufacturer Url", ManufacturerUrl.Text, Modules.ProductInformation);
            if (logMessage != null)
            {
                BuildLogger.Add(logMessage);
            }
            logMessage = Validator.ValidateUrl("Support Url", SupportUrl.Text, Modules.ProductInformation);
            if (logMessage != null)
            {
                BuildLogger.Add(logMessage);
            }
            // check for null or empty
            tempMessages = Validator.IsNullOrEmpty(
                new string[] { ProductCode.Text, UpgradeCode.Text, PackageId.Text, ProductName.Text, Title.Text, Version.Text, Author.Text, Manufacturer.Text },
                new string[] { "Product code", "Upgrade code", "Package Id", "Product name", "Title", "Version", "Author", "Manufacturer" },
                LogType.ERROR, Modules.ProductInformation);
            BuildLogger.Add(tempMessages);
            // check for acceptible chars
            tempMessages = Validator.ContainsInvalidChar(
                new string[] { ProductName.Text, Title.Text, Version.Text, Author.Text, Manufacturer.Text },
                new string[] { "Product name", "Title", "Version", "Author", "Manufacturer" },
                LogType.ERROR, Modules.ProductInformation);
            BuildLogger.Add(tempMessages);
            // check for property length
            tempMessages = Validator.ValidatePropertyLength(
                new string[] { ProductName.Text, Title.Text, Author.Text, Manufacturer.Text },
                new string[] { "Product name", "Title", "Author", "Manufacturer" },
                LogType.ERROR, Modules.ProductInformation);
            BuildLogger.Add(tempMessages);
            // check for description length
            tempMessages = Validator.ValidateDescriptionLength(
                new string[] { Description.Text, Comments.Text },
                new string[] { "Description", "Comments" },
                LogType.Warning, Modules.ProductInformation);
            BuildLogger.Add(tempMessages);
            // validate IDs
            logMessage = Validator.ValidateGuid(ProductCode.Text, "Product code");
            if (logMessage != null)
            {
                BuildLogger.Add(logMessage);
            }
            logMessage = Validator.ValidateGuid(UpgradeCode.Text, "Upgrade code");
            if (logMessage != null)
            {
                BuildLogger.Add(logMessage);
            }

            #region Features
            tempMessages = Validator.ValidateTree(tvFeatures, false, Modules.ProductInformation);
            BuildLogger.Add(tempMessages);

            if (tvFeatures.Nodes.Count == 0)
            {
                BuildLogMessage featureNotDefined = new BuildLogMessage();
                featureNotDefined.Message = "No Feature defined";
                featureNotDefined.Type    = LogType.ERROR;
                featureNotDefined.Module  = Modules.ProductInformation;
                BuildLogger.Add(featureNotDefined);
            }
            #endregion
        }
        private void ValidateRegistryValues(TreeNode keyNode)
        {
            List <RegistryValue> values       = (List <RegistryValue>)keyNode.Tag;
            BuildLogMessage      buildMessage = new BuildLogMessage();

            if (values == null || values.Count == 0)
            {
                //warning - key exists but no value
                buildMessage         = new BuildLogMessage();
                buildMessage.Message = "Registry key node found with no values under it. " + keyNode.FullPath;
                buildMessage.Type    = LogType.Warning;
                buildMessage.Module  = Modules.Registries;
                BuildLogger.Add(buildMessage);
            }
            if (values != null)
            {
                //error: repeating value names
                foreach (RegistryValue value in values)
                {
                    foreach (RegistryValue val in values)
                    {
                        if (val.Id != value.Id && value.Name == val.Name)
                        {
                            buildMessage         = new BuildLogMessage();
                            buildMessage.Message = "Multiple registry values with same name found under " + keyNode.FullPath;
                            buildMessage.Type    = LogType.ERROR;
                            buildMessage.Module  = Modules.Registries;
                            BuildLogger.Add(buildMessage);
                        }
                    }
                }

                foreach (RegistryValue value in values)
                {
                    //feature assigned to each value it
                    if (value.Feature == null || String.IsNullOrEmpty(value.Feature.Name))
                    {
                        buildMessage         = new BuildLogMessage();
                        buildMessage.Message = "No feature assigned to the registry value " + value.Name + " under " + keyNode.FullPath;
                        buildMessage.Type    = LogType.Warning;
                        buildMessage.Module  = Modules.Registries;
                        BuildLogger.Add(buildMessage);
                    }
                    //feature assigned but not available in feature tree (deleted somehow)
                    if (value.Feature != null && Common.FeatureExists(value.Feature.Id) == false)
                    {
                        buildMessage         = new BuildLogMessage();
                        buildMessage.Message = "Feature " + value.Feature.Name + " assigned  to the registry value: " + value.Name + " under " + keyNode.FullPath + " is not found in the feature tree.";
                        buildMessage.Type    = LogType.ERROR;
                        buildMessage.Module  = Modules.Registries;
                        BuildLogger.Add(buildMessage);
                    }

                    //warning - Registry value exists but no value assigned to it. default value used
                    if (value is RegistrySingleValue)
                    {
                        string singleValue = ((RegistrySingleValue)value).Value;
                        if (String.IsNullOrEmpty(singleValue))
                        {
                            buildMessage         = new BuildLogMessage();
                            buildMessage.Message = "No value assigned to the registry value: " + value.Name + " under " + keyNode.FullPath + ". Default value is assigned.";
                            buildMessage.Type    = LogType.Warning;
                            buildMessage.Module  = Modules.Registries;
                            BuildLogger.Add(buildMessage);
                        }
                        if (String.IsNullOrEmpty(singleValue) == false)
                        {
                            List <BuildLogMessage> logMessages = RegistryValueLimit(singleValue, keyNode, value);
                            if (logMessages.Count > 0)
                            {
                                BuildLogger.Add(logMessages);
                            }
                        }
                    }
                    else if (value is RegistryMultipleValue)
                    {
                        string[] multiValues = ((RegistryMultipleValue)value).Value;
                        if (multiValues.Length == 0)
                        {
                            string singleValue = ((RegistrySingleValue)value).Value;
                            buildMessage         = new BuildLogMessage();
                            buildMessage.Message = "No value assigned to the registry value: " + value.Name + " under " + keyNode.FullPath + ". Default value is assigned.";
                            buildMessage.Type    = LogType.Warning;
                            buildMessage.Module  = Modules.Registries;
                            BuildLogger.Add(buildMessage);
                        }
                        foreach (string singleValue in multiValues)
                        {
                            List <BuildLogMessage> logMessages = RegistryValueLimit(singleValue, keyNode, value);
                            if (logMessages.Count > 0)
                            {
                                BuildLogger.Add(logMessages);
                            }
                        }
                    }
                }
            }

            foreach (TreeNode childNode in keyNode.Nodes)
            {
                ValidateRegistryValues(childNode);
            }
        }
Esempio n. 4
0
        void INvnControl.Validate()
        {
            if (String.IsNullOrEmpty(txtUiAppPath.Text) == false && lstSelectedFiles.Items.Count != 0)
            {
                // Check whether files selected
                if (lstSelectedFiles.Items.Count == 0)
                {
                    BuildLogMessage message = new BuildLogMessage();
                    message.Message = "Custom UI application and its supporting files are not selected.";
                    message.Type    = LogType.ERROR;
                    message.Module  = Modules.CustomUIApplication;
                    BuildLogger.Add(message);// add to the list
                }
                // Check whether application with <MsiFileName>.exe exists
                bool   appExists = false, msiDllExits = false;
                string outputFilename = Path.GetFileNameWithoutExtension(ControlsManager.ProductInformation.Output.Text) + ".exe";
                foreach (NameValue nameValue in selectedItems)
                {
                    if (nameValue.Name == outputFilename)
                    {
                        appExists = true;
                    }
                    else if (nameValue.Name == "NvnInstaller.MsiDotNet.dll")
                    {
                        msiDllExits = true;
                    }
                }
                if (appExists == false)
                {
                    BuildLogMessage message = new BuildLogMessage();
                    message.Message = "No application with name " + outputFilename + " found. Custom UI appliction with name " + outputFilename + " is expected.";
                    message.Type    = LogType.ERROR;
                    message.Module  = Modules.CustomUIApplication;
                    BuildLogger.Add(message);// add to the list
                }

                if (msiDllExits == false)
                {
                    BuildLogMessage message = new BuildLogMessage();
                    message.Message = "NvnInstaller.MsiDotNet.dll is not found. It is needed for all custom UI application developed using NvnInstaller.";
                    message.Type    = LogType.ERROR;
                    message.Module  = Modules.CustomUIApplication;
                    BuildLogger.Add(message);// add to the list
                }
                // check bootstrapper is downloaded
                if (cmbPrerequisites.Items.Count < 2)
                {
                    BuildLogMessage message = new BuildLogMessage();
                    message.Message = "Nvn Installer needs at least .Net Framework 2.0 bootstrapper installed to build custom UI application. Please visit Nvn Installer website.";
                    message.Type    = LogType.ERROR;
                    message.Module  = Modules.CustomUIApplication;
                    BuildLogger.Add(message);// add to the list
                }

                // check bootstrapper is selected
                if (cmbPrerequisites.SelectedIndex < 1)
                {
                    BuildLogMessage message = new BuildLogMessage();
                    message.Message = "No prerequisite selected. Select relevent .Net Framework used for custom UI application.";
                    message.Type    = LogType.ERROR;
                    message.Module  = Modules.CustomUIApplication;
                    BuildLogger.Add(message);// add to the list
                }
            }
        }