Example #1
0
        static void Main(string[] args)
        {
            int nArgs = args.Length;

            if (nArgs == 0)
            {
                Console.WriteLine("============== How to use this tool? ===========");
                Console.Write(@"
Generates installer spec XML file to be used to create installer and digital 
signature based on a given folder.

InstallerSpec.exe [binfolder] [xmlfilepath] [corefile]

  binfolder     The folder in which all binaries reside. The search will 
                enumerate this folder as well as all sub-folders.

  xmlfilepath   The path to the output XML file path

  corefile      The core file name such as DynamoCore or DynamoRevitDS etc. 
                to detect the version of the installer.
");

                return;
            }
            var binpath = args[0];

            if (!Directory.Exists(binpath))
            {
                Console.WriteLine("===================== Error =====================");
                Console.WriteLine("Wrong bin folder path");
                return;
            }
            var filePath = @"InstallSpec.xml";

            if (nArgs > 1)
            {
                filePath = args[1];
            }

            var corefile = nArgs > 2 ? args[2] : string.Empty;

            var installspec = DynamoInstallSpec.CreateFromPath(binpath, corefile);

            installspec.Save(filePath);

            var binariestosigntxt = Path.Combine(Path.GetDirectoryName(filePath), @"binariestosign.txt");

            using (var writer = new StreamWriter(binariestosigntxt))
            {
                foreach (var item in installspec.Modules)
                {
                    if (item.DigitalSignature)
                    {
                        writer.WriteLine(Path.GetFullPath(Path.Combine(binpath, item.FilePath)));
                    }
                }
                writer.Flush();
            }
        }
Example #2
0
        public static DynamoInstallSpec CreateFromPath(string binPath, string corefile)
        {
            var spec = new DynamoInstallSpec()
            {
                DynamoVersion = DynamoCoreVersion.FromPath(binPath, corefile)
            };

            var dir = new DirectoryInfo(spec.DynamoVersion.BaseDirectory);
            spec.Modules = spec.GetModules(dir).ToList();
            return spec;
        }
Example #3
0
        public static DynamoInstallSpec CreateFromPath(string binPath, string corefile, IEnumerable<string> additionalFilePaths)
        {
            var spec = new DynamoInstallSpec()
            {
                DynamoVersion = DynamoCoreVersion.FromPath(binPath, corefile)
            };

            var dir = new DirectoryInfo(spec.DynamoVersion.BaseDirectory);
            spec.Modules = spec.GetModules(dir).ToList();
            spec.Modules.AddRange(spec.GetModules(additionalFilePaths));
            return spec;
        }
Example #4
0
        public static DynamoInstallSpec CreateFromPath(string binPath)
        {
            var spec = new DynamoInstallSpec()
            {
                DynamoVersion = DynamoCoreVersion.FromPath(binPath)
            };

            var dir = new DirectoryInfo(spec.DynamoVersion.BaseDirectory);

            spec.Modules = spec.GetModules(dir).ToList();
            return(spec);
        }
Example #5
0
        public static DynamoInstallSpec CreateFromPath(string binPath, string corefile, IEnumerable <string> additionalFilePaths)
        {
            var spec = new DynamoInstallSpec()
            {
                DynamoVersion = DynamoCoreVersion.FromPath(binPath, corefile)
            };

            var dir = new DirectoryInfo(spec.DynamoVersion.BaseDirectory);

            spec.Modules = spec.GetModules(dir).ToList();
            spec.Modules.AddRange(spec.GetModules(additionalFilePaths));
            return(spec);
        }
Example #6
0
        static void Main(string[] args)
        {
            int nArgs = args.Length;

            if (nArgs == 0)
            {
                Console.WriteLine("============== How to use this tool? ===========");
                Console.Write(@"
Generates installer spec XML file to be used to create installer and digital 
signature based on a given folder.

InstallerSpec.exe [binfolder] [xmlfilepath]

  binfolder     The folder in which all binaries reside. The search will 
                enumerate this folder as well as all sub-folders.

  xmlfilepath   The path to the output XML file path
");

                return;
            }
            var binpath = args[0];

            if (!Directory.Exists(binpath))
            {
                Console.WriteLine("===================== Error =====================");
                Console.WriteLine("Wrong bin folder path");
                return;
            }
            var filePath = @"InstallSpec.xml";

            if (nArgs > 1)
            {
                filePath = args[1];
            }

            var installspec = DynamoInstallSpec.CreateFromPath(binpath);

            installspec.Save(filePath);
        }
Example #7
0
        static void Main(string[] args)
        {
            int nArgs = args.Length;

            if (nArgs == 0)
            {
                Console.WriteLine("============== How to use this tool? ===========");
                Console.Write(@"
Generates installer spec XML file to be used to create installer and digital 
signature based on a given folder.

InstallerSpec.exe binfolder [xmlfilepath] [corefile] [/f:files.txt]

  binfolder     The folder in which all binaries reside. The search will 
                enumerate this folder as well as all sub-folders.

  xmlfilepath   The path to the output XML file path

  corefile      The core file name such as DynamoCore or DynamoRevitDS etc. 
                to detect the version of the installer.

  /f:files.txt  An optional text file containing paths to additional binary 
                files that need to be signed. Each file in this text file 
                should be on one line.
");

                return;
            }
            var binpath = args[0];

            if (!Directory.Exists(binpath))
            {
                Console.WriteLine("===================== Error =====================");
                Console.WriteLine("Wrong bin folder path");
                return;
            }
            var filePath = @"InstallSpec.xml";

            if (nArgs > 1)
            {
                filePath = args[1];
            }

            var corefile = string.Empty;
            var fileList = new List <string>();

            var index = 2;

            while (index < nArgs)
            {
                var value = args[index++];
                if (value.StartsWith("/f:"))
                {
                    var textFilePath = value.Substring(3);
                    if (File.Exists(textFilePath))
                    {
                        try
                        {
                            using (var streamReader = File.OpenText(textFilePath))
                            {
                                while (!streamReader.EndOfStream)
                                {
                                    // WARNING: The following codes are written with the assumption that
                                    // files with listed names are residing under "binpath", but this may
                                    // not be true in the future. Rewrite this logic and make "textFilePath"
                                    // contains fully qualified paths instead of doing the prefix here.
                                    //
                                    var fileNameWithoutPath = streamReader.ReadLine().Trim();
                                    //this is a comment, ignore this line
                                    if (fileNameWithoutPath.StartsWith("##") || string.IsNullOrWhiteSpace(fileNameWithoutPath))
                                    {
                                        continue;
                                    }
                                    var fileNameWithPath = Path.Combine(binpath, fileNameWithoutPath);
                                    if (!string.IsNullOrEmpty(fileNameWithPath))
                                    {
                                        Console.WriteLine($"adding {fileNameWithPath} to filesToSign list while parsing {textFilePath}");
                                        fileList.Add(fileNameWithPath);
                                    }
                                }
                            }
                        }
                        catch
                        {
                        }
                    }
                    else
                    {
                        throw new FileNotFoundException($"could not find {textFilePath} but it was passed as an argument to installerSpec.exe");
                    }
                }
                else
                {
                    corefile = value; // Without "/f" flag, it's a file name.
                }
            }

            var installspec = DynamoInstallSpec.CreateFromPath(binpath, corefile, fileList);

            installspec.Save(filePath);

            var binariestosigntxt = Path.Combine(Path.GetDirectoryName(filePath), @"binariestosign.txt");

            using (var writer = new StreamWriter(binariestosigntxt))
            {
                foreach (var item in installspec.Modules)
                {
                    if (item.DigitalSignature)
                    {
                        writer.WriteLine(Path.GetFullPath(Path.Combine(binpath, item.FilePath)));
                    }
                }
                writer.Flush();
            }
        }