コード例 #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("请稍候,不要关闭程序...");


            #region 读取配置

            string curFolder      = Environment.CurrentDirectory;
            var    configJsonText = FileUtil.Load(curFolder + "\\config.json");
            JToken configJToken   = JToken.Parse(configJsonText);

            DirectoryInfo curDirInfo = new DirectoryInfo(curFolder);
            string        root       = curDirInfo.Parent.FullName;//工程目录
            if (configJToken["root"] != null)
            {
                root = configJToken["root"].Value <string>();//配置的root路径
            }
            Program.ProjectRootPath = root;

            string resourcePath = root + @"\Egret\resource";//resource路径
            resourcePath        += "\\";
            Program.ResourcePath = resourcePath;

            string webResourcePath = root;
            if (configJToken["webResourcePath"] != null)
            {
                webResourcePath += configJToken["webResourcePath"].Value <string>();
                webResourcePath += "\\";
            }
            Program.WebResourcePath = webResourcePath;
            //是否忽略本地中的WebAvatar文件夹
            if (configJToken["ignoreWeb"] != null)
            {
                Program.IgnoreWeb = configJToken["ignoreWeb"].Value <bool>();
            }
            string version = "";
            if (configJToken["version"] != null)
            {
                version = configJToken["version"].Value <string>();
            }
            Program.Version = version;                                                    //版本号
            string confVersionFolder = configJToken["versionFolder"].Value <string>();    //版本文件夹名gangsterRes
            Program.VersionFolder = confVersionFolder + Program.Version.Replace(".", ""); //gangsterRes001

            if (configJToken["generate"] != null)
            {
                AssetOperation.isGenerate = configJToken["generate"].Value <bool>();;
            }
            if (configJToken["uploading"] != null)
            {
                AssetOperation.isUploading = configJToken["uploading"].Value <bool>();
            }
            if (configJToken["uploadingOuterNet"] != null)
            {
                AssetOperation.isUploadingOuterNet = configJToken["uploadingOuterNet"].Value <bool>();
            }

            Program.LockOuterNet = configJToken["lockOuterNet"].Value <bool>();

            #endregion


            #region 生成本地default.res.json

            Program.AddVersion = false;

            //不加版本号后缀
            VersionUtils.UseVersionSuffix = false;
            var generateLocal = configJToken["generatelocal"].Value <bool>();

            bool tempIgnoreWeb = Program.IgnoreWeb;
            Program.IgnoreWeb = true;
            //先在Tools文件夹生成一个
            FolderGenerate.Init();
            if (generateLocal)
            {
                string tooldefaultResJson = curFolder + "\\" + configJToken["defaultresjson"].Value <string>();
                GenerateUtil.GenerateLocal(configJToken, resourcePath, tooldefaultResJson);
            }

            Program.IgnoreWeb = tempIgnoreWeb;
            //生成本地使用的
            FolderGenerate.Init();
            if (generateLocal)
            {
                string defaultResJson = resourcePath + configJToken["defaultresjson"].Value <string>();
                GenerateUtil.GenerateLocal(configJToken, resourcePath, defaultResJson);
            }

            #endregion


            #region 更改的资源

            //Program.IgnoreWeb = true;//不忽略,就是生成网络资源
            //Program.AddVersion = true;
            //VersionUtils.UseVersionSuffix = true;//加版本号后缀
            //FolderGenerate.Init();

            //if( AssetOperation.isGenerate ) {
            //    AssetOperation.MainOperation( root, configJToken );
            //}

            #endregion


            #region 生成patch,将更改的文件复制到根目录一个文件夹

            //是否生成patch更改的资源文件夹
            var IsGeneratePathDir = configJToken["generatePathDir"].Value <bool>();
            if (IsGeneratePathDir)
            {
                PatchTool.PatchOperation.MainPatch(configJToken);
            }

            #endregion


            #region 生成网络res.json

            var generateWeb = configJToken["generateWeb"].Value <bool>();
            if (generateWeb)
            {
                string resName = configJToken["gangsterresjson"].Value <string>();
                resName = resName.Replace("[version]", Program.Version);
                string gangsterResJson = webResourcePath + resName;
                GenerateUtil.GenerateWeb(configJToken, webResourcePath, gangsterResJson);
                Program.Gangster_0_0_0_Path    = gangsterResJson;
                Program.Gangster0_0_0_res_json = resName;
            }

            #endregion


            #region   ftp

            FTPUtils.InitFTP(configJToken);
            MainUploading.MainUpload();

            #endregion


            if (needStop)
            {
                Console.ReadKey();
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("请稍候,不要关闭程序...");

            //GenerateTool文件夹
            string generateToolFolder = Environment.CurrentDirectory;
            var    configJsonText     = FileUtil.Load(generateToolFolder + "\\config.json");
            JToken configJToken       = JToken.Parse(configJsonText);

            DirectoryInfo generateToolInfo = new DirectoryInfo(generateToolFolder);
            string        root             = generateToolInfo.Parent.Parent.FullName;//工程目录


            #region 读取配置

            if (configJToken["root"] != null)
            {
                root = configJToken["root"].Value <string>(); //配置的root路径
            }
            string resourcePath = root + @"\Egret\resource";  //resource路径
            resourcePath += "\\";

            string webResourcePath = resourcePath;
            if (configJToken["webResourcePath"] != null)
            {
                webResourcePath  = root + configJToken["webResourcePath"].Value <string>();
                webResourcePath += "\\";
            }
            if (configJToken["ignoreWeb"] != null)
            {
                Program.IgnoreWeb = configJToken["ignoreWeb"].Value <bool>();
            }
            string version = "";
            if (configJToken["version"] != null)
            {
                version = configJToken["version"].Value <string>();
            }
            Program.Version       = version.Replace(".", "");
            Program.VersionFolder = configJToken["versionFolder"].Value <string>();

            //if( configJToken["svnPath"] != null ) {
            //    SVNVersion.InitSVNClient( configJToken["svnPath"].Value<string>() );
            //}

            #endregion


            #region 生成本地default.res.json

            //不加版本号后缀
            VersionUtils.UseVersionSuffix = false;
            FolderGenerate.Init();
            var generateLocal = configJToken["generatelocal"].Value <bool>();
            if (generateLocal)
            {
                string defaultResJson = resourcePath + configJToken["defaultresjson"].Value <string>();
                GenerateUtil.GenerateLocal(configJToken, resourcePath, defaultResJson);
            }

            #endregion


            #region 记录更改待上传的资源

            if (configJToken["uploading"] != null)
            {
                var uploading = configJToken["uploading"].Value <bool>();
                UploadingTool.MainUploading.isUploading = uploading;
            }
            if (UploadingTool.MainUploading.isUploading)
            {
                //生成改变的资源组
                UploadingTool.MainUploading.MainProgram(root, configJToken);
            }

            #endregion


            #region 生成网络res.json

            Program.IgnoreWeb = false;//不忽略,就是生成网络资源

            //加版本号后缀
            VersionUtils.UseVersionSuffix = true;
            FolderGenerate.Init();
            var generateWeb = configJToken["generateWeb"].Value <bool>();
            if (generateWeb)
            {
                string resName = configJToken["gangsterresjson"].Value <string>();
                resName = resName.Replace("[version]", version);
                string gangsterResJson = webResourcePath + resName;
                GenerateUtil.GenerateWeb(configJToken, webResourcePath, gangsterResJson);
            }

            #endregion


            #region   ftp

            UploadingTool.FTPUtils.InitFTP(configJToken);
            UploadingTool.MainUploading.Uploading(resourcePath);

            #endregion


            //SVNVersion.DeinitSVNClient();

            if (needStop)
            {
                Console.ReadKey();
            }
        }