public static Dictionary <string, string> GetConfigVersion(string configDir)
        {
            Dictionary <string, string> retVal = new Dictionary <string, string>();
            List <string> configFilesToHash    = GetFileNamesInVersionDef(configDir);

            foreach (string name in configFilesToHash)
            {
                if (!name.Equals(ConfigPackagerHelper.CurrentVersionFileName, StringComparison.CurrentCultureIgnoreCase) &&
                    !name.Equals(ConfigPackagerHelper.ParentVersionFileName, StringComparison.CurrentCultureIgnoreCase) &&
                    !name.Equals(ConfigPackagerHelper.VersionDefinitionFileName, StringComparison.CurrentCultureIgnoreCase))
                {
                    retVal.Add(name, PackagerHelper.GetMD5HashOfFile(configDir + "\\" + name));
                }
            }

            return(retVal);

            /*
             * Dictionary<string, string> retVal = new Dictionary<string, string>();
             *
             *  List<string> configFileNames = ListFiles(configDir);
             *  configFileNames.Sort();
             *  foreach (string name in configFileNames)
             *  {
             *      if (!name.Equals(currentVersionFileName, StringComparison.CurrentCultureIgnoreCase) && !name.Equals(parentVersionFileName, StringComparison.CurrentCultureIgnoreCase))
             *          retVal.Add(name, GetMD5HashOfFile(configDir + "\\" + name));
             *  }
             *  return retVal;*/
        }
        private static List <string> GetVersionDef(string configDir)
        {
            List <string> retVal = new List <string>();

            try
            {
                string versionDefinition = PackagerHelper.ReadFile(configDir + "\\" + ConfigPackagerHelper.VersionDefinitionFileName);
                if (!string.IsNullOrEmpty(versionDefinition))
                {
                    retVal = versionDefinition.Split(';').ToList();
                    retVal.Sort();
                }
            }
            catch (Exception e)
            {
                Utils.configLog("E", e.Message + " .GetVersionDef " + configDir);
            }

            return(retVal);
        }
        private static List <string> GetFileNamesInVersionDef(string configDir)
        {
            List <string> filesInVersion    = Constants.DefaultConfigVersionDefinition.ToList();
            List <string> filesInConfigDir  = PackagerHelper.ListFiles(configDir);
            List <string> configFilesToHash = filesInVersion.ToList();

            try
            {
                filesInVersion = GetVersionDef(configDir);
                filesInConfigDir.Sort();
                configFilesToHash = filesInConfigDir.Intersect(filesInVersion.ToList()).ToList();
            }
            catch (Exception e)
            {
                Utils.configLog("E", e.Message + " .GetConfigVersion");
            }

            configFilesToHash.Sort();
            return(configFilesToHash);
        }
        public static bool Package(string binRootDir, string binName, bool singleBin, string binType, string packType, string repoDir, ref string[] filePaths, NLog.Logger logger = null)
        {
            bool success = true;
            //get the binary directory
            string binDir = singleBin ? binRootDir : binRootDir + "\\" + binName;

            if (!Directory.Exists(binDir))
            {
                string error = string.Format("{0} directory {1} does not exist. Is there a mismatch in {0} name and its location?", packType, binDir);
                DisplayError(error, logger);
                success = false;
                goto Exit;
            }

            //get the zip dir
            string zipDir = repoDir;

            string[] parts = binName.Split('.');

            foreach (var part in parts)
            {
                zipDir += "\\" + part;
            }

            // Use HomeOSUpdateVersion from App.Config

            string file = binDir + "\\" + binName + "." + binType + ".config";
            string homeosUpdateVersion = Utils.GetHomeOSUpdateVersion(file);

            if (homeosUpdateVersion == UnknownHomeOSUpdateVersionValue)
            {
                string error = string.Format("Warning didn't find {0} version in {1}, defaulting to {2}", packType, file, homeosUpdateVersion);
                DisplayError(error, logger);
            }

            zipDir += "\\" + homeosUpdateVersion;
            Directory.CreateDirectory(zipDir);

            //get the name of the zip file and pack it
            string zipFile  = zipDir + "\\" + binName + ".zip";
            string hashFile = zipDir + "\\" + binName + ".md5";

            bool result = PackagerHelper.PackZip(binDir, zipFile);

            if (!result)
            {
                string error = string.Format("Failed to pack zip for {0}. Quitting", binName);
                DisplayError(error);
                success = false;
                goto Exit;
            }

            string md5hash = PackagerHelper.GetMD5HashOfFile(zipFile);

            if (string.IsNullOrWhiteSpace(md5hash))
            {
                string error = string.Format("Failed to generated MD5 hash for file {0}. Quitting", zipFile);
                DisplayError(error);
                success = false;
                goto Exit;
            }

            try
            {
                File.WriteAllText(hashFile, md5hash);
            }
            catch (Exception)
            {
                string error = string.Format("Failed to write hash file {0}. Quitting", hashFile);
                DisplayError(error);
                success = false;
                goto Exit;
            }

            Array.Resize(ref filePaths, 2);
            filePaths[0] = zipFile;
            filePaths[1] = hashFile;
            string info = string.Format("Prepared {0} package: {1}.\n", packType, zipFile);

            DisplayInfo(info, logger);

Exit:
            return(success);
        }