private void CreateEXE(TestTarget exe, string arch, List <string> autopkgFiles) { if (arch == "msil") { CreateMSILBinary(exe, Resources.MSILAppTemplate, ".exe", arch, @" /out:""{0}"" /target:exe /delaysign+ /keyfile:""{1}"" ""{2}""", autopkgFiles); } else { CreateBinary(exe, Resources.AppTemplate, ".exe", arch, @" ""{0}"" ""/Fe{1}"" /DISOLATION_AWARE_ENABLED=1 /TC /Y- ", autopkgFiles); } }
private void CreateDLL(TestTarget dll, string arch, List <string> autopkgFiles) { if (arch == "msil") { CreateMSILBinary(dll, Resources.MSILSharedLibTemplate, ".dll", arch, @" /out:""{0}"" /target:library /delaysign+ /keyfile:""{1}"" ""{2}""", autopkgFiles); } else { CreateBinary(dll, Resources.SharedLibTemplate, ".dll", arch, @" ""{0}"" ""/Fe{1}"" /DISOLATION_AWARE_ENABLED=1 /LD /TC /Y- ", autopkgFiles); } }
private static TestTarget Add(List <TestTarget> list, string name, string version) { var t = new TestTarget { Name = name, Version = version }; foreach (var item in list) { if (item == t) { return(item); } } list.Add(t); return(t); }
public void CreateMSILBinary(TestTarget binary, string binaryTemplate, string extension, string arch, string commandLine, List<string> autopkgFiles) { var outputPath = Path.Combine(this.tempFolder, arch); if (binary.Built) return; foreach (var dep in binary.Dependencies) { CreateDLL(dep, arch, autopkgFiles); } if (binary.Ignore) return; //Console.WriteLine("Building Binary [{0}-{1}]", binary.Name, binary.Version); //var importLibrary = new StringBuilder(); var callLibrary = new StringBuilder(); foreach (var dll in binary.Dependencies) { //importLibrary.Append(LibraryReferenceTemplate.Replace("[$LIBNAME]", dll.Name).Replace("[$LIBVERSION]", dll.Version).Replace("[$PUBLICKEYTOKEN]", publicKeyToken).Replace("[$ARCH]", arch)); callLibrary.Append(Resources.MSILLibraryFunctionCallTemplate.Replace("[$LIBNAME]", dll.Name).Replace("[$LIBVERSION]", dll.Version)); } var tempFolder = Path.Combine(Path.GetTempPath(), binary.Name + "-" + binary.Version); Directory.CreateDirectory(tempFolder); var outputBinaryFolder = Path.Combine(outputPath, binary.Name + "-" + binary.Version); Directory.CreateDirectory(outputBinaryFolder); Environment.CurrentDirectory = outputBinaryFolder; foreach (var dll in binary.Dependencies) { var currentRef = Path.Combine(Path.GetTempPath(), dll.Name + "-" + dll.Version); commandLine = @"{0} /reference:""{1}""".format(commandLine, Path.Combine(currentRef, dll.Name + ".dll")); } var binaryText = binaryTemplate.Replace("[$LIBNAME]", binary.Name).Replace("[$LIBVERSION]", binary.Version).Replace("[$CALL_LIBRARY]", callLibrary.ToString()).Replace("[$PUBLICKEYTOKEN]", publicKeyToken).Replace("[$ARCH]", arch); var tempCSFile = Path.Combine(tempFolder, binary.Name + ".cs"); File.WriteAllText(tempCSFile, binaryText); // compile it var outputBinary = Path.Combine(outputBinaryFolder, binary.Name + extension); if (csc_msil.Exec(commandLine, outputBinary, pkPath, tempCSFile) != 0) throw new Exception(csc_msil.StandardOut); binary.Built = true; //TODO: create autopkg }
private void CreateEXE(TestTarget exe, string arch, List<string> autopkgFiles) { if (arch == "msil") { CreateMSILBinary(exe, Resources.MSILAppTemplate, ".exe", arch, @" /out:""{0}"" /target:exe /delaysign+ /keyfile:""{1}"" ""{2}""", autopkgFiles); } else { CreateBinary(exe, Resources.AppTemplate, ".exe", arch, @" ""{0}"" ""/Fe{1}"" /DISOLATION_AWARE_ENABLED=1 /TC /Y- ", autopkgFiles); } }
private void CreateDLL(TestTarget dll, string arch, List<string> autopkgFiles) { if (arch == "msil") { CreateMSILBinary(dll, Resources.MSILSharedLibTemplate, ".dll", arch, @" /out:""{0}"" /target:library /delaysign+ /keyfile:""{1}"" ""{2}""", autopkgFiles); } else { CreateBinary(dll, Resources.SharedLibTemplate, ".dll", arch, @" ""{0}"" ""/Fe{1}"" /DISOLATION_AWARE_ENABLED=1 /LD /TC /Y- ", autopkgFiles); } }
private void CreateBinary(TestTarget binary, string binaryTemplate, string extension, string arch, string commandLine, List<string> autopkgFiles) { var outputPath = Path.Combine(this.tempFolder, arch); if (binary.Built) return; foreach (var dep in binary.Dependencies) { CreateDLL(dep, arch, autopkgFiles); } if (binary.Ignore) return; //Console.WriteLine("Building Binary [{0}-{1}]", binary.Name, binary.Version); var importLibrary = new StringBuilder(); var callLibrary = new StringBuilder(); foreach (var dll in binary.Dependencies) { importLibrary.Append(Resources.LibraryReferenceTemplate.Replace("[$LIBNAME]", dll.Name).Replace("[$LIBVERSION]", dll.Version).Replace("[$PUBLICKEYTOKEN]", publicKeyToken).Replace("[$ARCH]", arch)); callLibrary.Append(Resources.LibraryFunctionCallTemplate.Replace("[$LIBNAME]", dll.Name).Replace("[$LIBVERSION]", dll.Version).Replace("[$PUBLICKEYTOKEN]", publicKeyToken).Replace("[$ARCH]", arch)); } var tempFolder = Path.Combine(Path.GetTempPath(), binary.Name + "-" + binary.Version); Directory.CreateDirectory(tempFolder); var outputBinaryFolder = Path.Combine(outputPath, binary.Name + "-" + binary.Version); Directory.CreateDirectory(outputBinaryFolder); Environment.CurrentDirectory = outputBinaryFolder; foreach (var dll in binary.Dependencies) { var defFile = Resources.ModuleDefinitionFileTemplate + "print_" + dll.Name; File.WriteAllText(Path.Combine(tempFolder, dll.Name + ".def"), defFile); if (lib.Exec("/out:{0} /def:{1} /machine:{2}", Path.Combine(tempFolder, dll.Name + ".lib"), Path.Combine(tempFolder, dll.Name + ".def"), arch == "x86" ? arch : "x64") != 0) throw new Exception(lib.StandardOut); commandLine = @"{0} /link ""{1}""".format(commandLine, Path.Combine(tempFolder, dll.Name + ".lib")); } // make C file var binaryText = binaryTemplate.Replace("[$LIBNAME]", binary.Name).Replace("[$LIBVERSION]", binary.Version).Replace("[$IMPORT_LIBRARY]", importLibrary.ToString()).Replace("[$CALL_LIBRARY]", callLibrary.ToString()).Replace("[$PUBLICKEYTOKEN]", publicKeyToken).Replace("[$ARCH]", arch); var tempCFile = Path.Combine(tempFolder, binary.Name + ".c"); File.WriteAllText(tempCFile, binaryText); // compile it var outputBinary = Path.Combine(outputBinaryFolder, binary.Name + extension); if (cl.Exec(commandLine, tempCFile, outputBinary) != 0) throw new Exception(cl.StandardOut); binary.Built = true; //TODO create the autopkg file var propSheet = new PropertySheet(); //propSheet.Keys }
private static TestTarget Add(List<TestTarget> list, string name, string version) { var t = new TestTarget { Name = name, Version = version }; foreach (var item in list) { if (item == t) return item; } list.Add(t); return t; }
public void CreateMSILBinary(TestTarget binary, string binaryTemplate, string extension, string arch, string commandLine, List <string> autopkgFiles) { var outputPath = Path.Combine(this.tempFolder, arch); if (binary.Built) { return; } foreach (var dep in binary.Dependencies) { CreateDLL(dep, arch, autopkgFiles); } if (binary.Ignore) { return; } //Console.WriteLine("Building Binary [{0}-{1}]", binary.Name, binary.Version); //var importLibrary = new StringBuilder(); var callLibrary = new StringBuilder(); foreach (var dll in binary.Dependencies) { //importLibrary.Append(LibraryReferenceTemplate.Replace("[$LIBNAME]", dll.Name).Replace("[$LIBVERSION]", dll.Version).Replace("[$PUBLICKEYTOKEN]", publicKeyToken).Replace("[$ARCH]", arch)); callLibrary.Append(Resources.MSILLibraryFunctionCallTemplate.Replace("[$LIBNAME]", dll.Name).Replace("[$LIBVERSION]", dll.Version)); } var tempFolder = Path.Combine(Path.GetTempPath(), binary.Name + "-" + binary.Version); Directory.CreateDirectory(tempFolder); var outputBinaryFolder = Path.Combine(outputPath, binary.Name + "-" + binary.Version); Directory.CreateDirectory(outputBinaryFolder); Environment.CurrentDirectory = outputBinaryFolder; foreach (var dll in binary.Dependencies) { var currentRef = Path.Combine(Path.GetTempPath(), dll.Name + "-" + dll.Version); commandLine = @"{0} /reference:""{1}""".format(commandLine, Path.Combine(currentRef, dll.Name + ".dll")); } var binaryText = binaryTemplate.Replace("[$LIBNAME]", binary.Name).Replace("[$LIBVERSION]", binary.Version).Replace("[$CALL_LIBRARY]", callLibrary.ToString()).Replace("[$PUBLICKEYTOKEN]", publicKeyToken).Replace("[$ARCH]", arch); var tempCSFile = Path.Combine(tempFolder, binary.Name + ".cs"); File.WriteAllText(tempCSFile, binaryText); // compile it var outputBinary = Path.Combine(outputBinaryFolder, binary.Name + extension); if (csc_msil.Exec(commandLine, outputBinary, pkPath, tempCSFile) != 0) { throw new Exception(csc_msil.StandardOut); } binary.Built = true; //TODO: create autopkg }
private void CreateBinary(TestTarget binary, string binaryTemplate, string extension, string arch, string commandLine, List <string> autopkgFiles) { var outputPath = Path.Combine(this.tempFolder, arch); if (binary.Built) { return; } foreach (var dep in binary.Dependencies) { CreateDLL(dep, arch, autopkgFiles); } if (binary.Ignore) { return; } //Console.WriteLine("Building Binary [{0}-{1}]", binary.Name, binary.Version); var importLibrary = new StringBuilder(); var callLibrary = new StringBuilder(); foreach (var dll in binary.Dependencies) { importLibrary.Append(Resources.LibraryReferenceTemplate.Replace("[$LIBNAME]", dll.Name).Replace("[$LIBVERSION]", dll.Version).Replace("[$PUBLICKEYTOKEN]", publicKeyToken).Replace("[$ARCH]", arch)); callLibrary.Append(Resources.LibraryFunctionCallTemplate.Replace("[$LIBNAME]", dll.Name).Replace("[$LIBVERSION]", dll.Version).Replace("[$PUBLICKEYTOKEN]", publicKeyToken).Replace("[$ARCH]", arch)); } var tempFolder = Path.Combine(Path.GetTempPath(), binary.Name + "-" + binary.Version); Directory.CreateDirectory(tempFolder); var outputBinaryFolder = Path.Combine(outputPath, binary.Name + "-" + binary.Version); Directory.CreateDirectory(outputBinaryFolder); Environment.CurrentDirectory = outputBinaryFolder; foreach (var dll in binary.Dependencies) { var defFile = Resources.ModuleDefinitionFileTemplate + "print_" + dll.Name; File.WriteAllText(Path.Combine(tempFolder, dll.Name + ".def"), defFile); if (lib.Exec("/out:{0} /def:{1} /machine:{2}", Path.Combine(tempFolder, dll.Name + ".lib"), Path.Combine(tempFolder, dll.Name + ".def"), arch == "x86" ? arch : "x64") != 0) { throw new Exception(lib.StandardOut); } commandLine = @"{0} /link ""{1}""".format(commandLine, Path.Combine(tempFolder, dll.Name + ".lib")); } // make C file var binaryText = binaryTemplate.Replace("[$LIBNAME]", binary.Name).Replace("[$LIBVERSION]", binary.Version).Replace("[$IMPORT_LIBRARY]", importLibrary.ToString()).Replace("[$CALL_LIBRARY]", callLibrary.ToString()).Replace("[$PUBLICKEYTOKEN]", publicKeyToken).Replace("[$ARCH]", arch); var tempCFile = Path.Combine(tempFolder, binary.Name + ".c"); File.WriteAllText(tempCFile, binaryText); // compile it var outputBinary = Path.Combine(outputBinaryFolder, binary.Name + extension); if (cl.Exec(commandLine, tempCFile, outputBinary) != 0) { throw new Exception(cl.StandardOut); } binary.Built = true; //TODO create the autopkg file var propSheet = new PropertySheet(); //propSheet.Keys }