Пример #1
0
        public static SteamConfig FromFilePath(string path)
        {
            try
            {
                if (!File.Exists(path))
                {
                    throw new Exception($"Cannot find file at path {path}");
                }

                var dict  = new Dictionary <string, string>();
                var lines = File.ReadAllLines(path);
                var sb    = new StringBuilder();
                foreach (var line in lines)
                {
                    sb.AppendLine(line);
                    var split = line.Split('=');
                    if (split.Length >= 2)
                    {
                        dict.Add(split[0], split[1]);
                    }
                }

                var s = new SteamConfig(dict);
                return(s);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            try
            {
                var config           = SteamConfig.FromFilePath(args[0]);
                var steamBuildScript = Path.GetFullPath(config.BuildScript);
                var sdkPath          = config.SDKPath;
                var username         = config.Login;
                var password         = config.Password;

                if (!Directory.Exists(sdkPath))
                {
                    throw new Exception($"SteamSDK {sdkPath} not found");
                }

                var steamCmdPath = Path.Combine(sdkPath, "tools/ContentBuilder/builder/steamcmd.exe");
                if (!File.Exists(steamCmdPath))
                {
                    throw new Exception($"SteamCMD {steamCmdPath} not found");
                }

                CopyContentToRelativeBuildScript(config);

                var uploaderProcess = new Process();
                uploaderProcess.StartInfo.FileName         = steamCmdPath;
                uploaderProcess.StartInfo.WorkingDirectory =
                    Path.GetDirectoryName(Path.GetDirectoryName(steamCmdPath));
                uploaderProcess.StartInfo.Arguments =
                    string.Format(SteamCmdArgFormat, username, password, steamBuildScript);


                uploaderProcess.StartInfo.UseShellExecute        = false;
                uploaderProcess.StartInfo.RedirectStandardOutput = true;
                uploaderProcess.OutputDataReceived += (sender, msg) =>
                {
                    if (msg != null)
                    {
                        Console.WriteLine(msg.Data);
                    }
                };

                uploaderProcess.Start();
                Console.WriteLine("Executing SteamCMD \"{0}\"...", steamCmdPath);

                uploaderProcess.BeginOutputReadLine();
                uploaderProcess.WaitForExit();
                uploaderProcess.Close();
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Пример #3
0
        private static void CopyContentToRelativeBuildScript(SteamConfig config)
        {
            if (!Directory.Exists(config.BuildPath))
            {
                throw new Exception($"Target path {config.BuildPath} does not exist. Did you forget to build?");
            }

            var contentFolderPath = Path.GetFullPath(config.BuildScript + config.BuildContentRelativeToBuildScript);

            if (Directory.Exists(contentFolderPath))
            {
                Directory.Delete(contentFolderPath, true);
            }

            CopyDirectory(config.BuildPath, contentFolderPath);
            Console.WriteLine($"Build files copied from {config.BuildPath} to {contentFolderPath}.");
        }