Example #1
0
 static void Clean(string rid)
 {
     Dotnet.Clean("LibreLancer.sln");
     RmDir("./obj/projs-" + rid);
     RmDir("./obj/projs-sdk-" + rid);
     RmDir("./bin/librelancer-" + rid);
     RmDir("./bin/librelancer-sdk-" + rid);
 }
Example #2
0
        public static void PatchedPublish(string proj, string outputDirectory, string rid)
        {
            Directory.CreateDirectory(outputDirectory);
            string publishDir = Path.Combine(outputDirectory, "lib");
            //Publish
            var publishSettings = new DotnetPublishSettings
            {
                Configuration   = "Release",
                OutputDirectory = publishDir,
                SelfContained   = true,
                Runtime         = rid
            };

            Dotnet.Publish(proj, publishSettings);
            //Delete junk files
            DeleteFilesGlob(publishDir,
                            "*.pdb",
                            "createdump",
                            "SOS_README.md"
                            );
            //TODO: Fix this msbuild side
            if (rid == "win7-x86")
            {
                RmDir(Path.Combine(publishDir, "x64"));
            }
            if (rid == "win7-x64")
            {
                RmDir(Path.Combine(publishDir, "x86"));
            }
            //Move the AppHost
            var apphostName = Path.GetFileNameWithoutExtension(proj);
            var origName    = apphostName + ".dll";

            if (IsWindows)
            {
                apphostName += ".exe";
            }
            string appHostPath = Path.Combine(outputDirectory, apphostName);

            if (File.Exists(appHostPath))
            {
                File.Delete(appHostPath);
            }
            File.Move(Path.Combine(publishDir, apphostName), appHostPath);
            //Patch the AppHost
            var origPathBytes = Encoding.UTF8.GetBytes(origName + "\0");
            var libDir        = IsWindows ? "lib\\" : "lib/";
            var newPath       = libDir + origName;
            var newPathBytes  = Encoding.UTF8.GetBytes(newPath + "\0");
            var apphostExe    = File.ReadAllBytes(appHostPath);
            int offset        = FindBytes(apphostExe, origPathBytes);

            if (offset < 0)
            {
                throw new Exception("Could not patch apphost " + appHostPath);
            }
            for (int i = 0; i < newPathBytes.Length; i++)
            {
                apphostExe[offset + i] = newPathBytes[i];
            }
            File.WriteAllBytes(appHostPath, apphostExe);
        }