Пример #1
0
        public void Validate()
        {
            BuildLogMessage buildMessage = new BuildLogMessage();

            if (type == CustomActionType.ExeCommand)
            {
                if (String.IsNullOrEmpty(sourcePath))
                {
                    buildMessage         = new BuildLogMessage();
                    buildMessage.Message = String.Format("No executable(exe) in target system is specified for the custom action: {0}.", name);
                    buildMessage.Type    = LogType.ERROR;
                    buildMessage.Module  = Modules.CustomActions;
                    BuildLogger.Add(buildMessage);
                }
                if (String.IsNullOrEmpty(function))
                {
                    buildMessage         = new BuildLogMessage();
                    buildMessage.Message = String.Format("No argument specified for the custom action: {0}.", name);
                    buildMessage.Type    = LogType.Warning;
                    buildMessage.Module  = Modules.CustomActions;
                    BuildLogger.Add(buildMessage);
                }
            }
            else
            {
                if (this.browsable)
                {
                    if (scriptable)
                    {
                        if (String.IsNullOrEmpty(sourcePath) && String.IsNullOrEmpty(script))
                        {
                            buildMessage         = new BuildLogMessage();
                            buildMessage.Message = String.Format("Neither {0} file specified nor any script found in the editor (Custom Action: {1}).", type.ToString(), name);
                            buildMessage.Type    = LogType.ERROR;
                            buildMessage.Module  = Modules.CustomActions;
                            BuildLogger.Add(buildMessage);
                        }
                    }
                    else if (String.IsNullOrEmpty(sourcePath))
                    {
                        buildMessage         = new BuildLogMessage();
                        buildMessage.Message = String.Format("File path of the custom action :{0} is empty.", name);
                        buildMessage.Type    = LogType.ERROR;
                        buildMessage.Module  = Modules.CustomActions;
                        BuildLogger.Add(buildMessage);
                    }
                }
                if (browsable && String.IsNullOrEmpty(function))
                {
                    buildMessage         = new BuildLogMessage();
                    buildMessage.Message = String.Format("{0} of custom action: {1} is empty.", functionLabel, name);
                    buildMessage.Type    = LogType.ERROR;
                    buildMessage.Module  = Modules.CustomActions;
                    BuildLogger.Add(buildMessage);
                }
            }
        }
Пример #2
0
        void INvnControl.Validate()
        {
            List <BuildLogMessage> logMessages = Validator.ValidateTree(tvRegistries, false, Modules.Registries);

            BuildLogger.Add(logMessages);
            // validate each registry values
            foreach (TreeNode rootNode in tvRegistries.Nodes)
            {
                foreach (TreeNode keyNode in rootNode.Nodes)
                {
                    ValidateRegistryValues(keyNode);
                }
            }
        }
Пример #3
0
        void INvnControl.Validate()
        {
            List <BuildLogMessage> tempMessages = new List <BuildLogMessage>();

            tempMessages = Validator.ValidateTree(tvComponents, true, Modules.Components);
            BuildLogger.Add(tempMessages);
            tempMessages = Validator.ValidateTree(tvShortcuts, false, Modules.Components);
            BuildLogger.Add(tempMessages);
            tempMessages = Validator.ValidateTree(tvSystemFolder, false, Modules.Components);
            BuildLogger.Add(tempMessages);

            // check component exists for the shortcut node
            foreach (TreeNode rootNode in tvShortcuts.Nodes)
            {
                CheckComponentNodeExists(rootNode);
            }
        }
Пример #4
0
        void INvnControl.Validate()
        {
            List <string> extensions           = new List <string>();
            List <string> selectedApplications = new List <string>();

            foreach (DataGridViewRow row in dgrExtensions.Rows)
            {
                string application = (string)row.Cells[applicationColumn.Name].Value;
                string description = (string)row.Cells[DescriptionColumn.Name].Value;
                string extension   = (string)row.Cells[extensionColumn.Name].Value;
                // check for mandatory fields
                List <BuildLogMessage> logMessages = Validator.IsNullOrEmpty(
                    new string[] { application, extension }, new string[] { "Application Name", "File association extension" }, LogType.ERROR, Modules.FileAssociation);
                if (logMessages != null)
                {
                    BuildLogger.Add(logMessages);
                }
                // application name doesn't end with '.exe'
                if (application != null && application.EndsWith(".exe") == false)
                {
                    BuildLogMessage buildMessage = new BuildLogMessage();
                    buildMessage.Message = "Application selected for the file association:" + extension + " does not end with .exe. Are you sure it is an executable ?";
                    buildMessage.Type    = LogType.Warning;
                    buildMessage.Module  = Modules.FileAssociation;
                    BuildLogger.Add(buildMessage);// add to the list
                }
                //error if application selected for file association not in components tree
                if (row.Tag != null && ((TreeNode)row.Tag).TreeView == null)
                {
                    BuildLogMessage buildMessage = new BuildLogMessage();
                    buildMessage.Message = "Application selected for the file association:" + extension + " not found in components tree. Please check whether the application with name: " + application + " exists.";
                    buildMessage.Type    = LogType.ERROR;
                    buildMessage.Module  = Modules.FileAssociation;
                    BuildLogger.Add(buildMessage);// add to the list
                }
            }
            //check repeating names
            List <BuildLogMessage> messages = Validator.ValidateRepeatingItems(extensions, "Extension {0} found more than once. Are you sure you want to handle same extension by different applications.", LogType.Warning, Modules.FileAssociation);

            if (messages != null)
            {
                BuildLogger.Add(messages);
            }
        }
Пример #5
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);
     }
 }
Пример #6
0
        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);
            }
        }
Пример #7
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
        }
Пример #8
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
                }
            }
        }