*.将打包功能移植到RyProject.cs。
This commit is contained in:
1 parent
59677e1a85
commit
d32f91ab95
11 files changed
+983
-952
No files matched your search
@@ -2,8 +2,11 @@
|
||||
using ryCommonDb;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml;
|
||||
|
||||
namespace 开发辅助工具.Manager
|
||||
@@ -30,7 +33,13 @@ namespace 开发辅助工具.Manager
|
||||
/// <summary>
|
||||
/// 是否修改输出路径
|
||||
/// </summary>
|
||||
public bool ChangedOutputPath { get; set; } =true;
|
||||
public bool ChangedOutputPath { get; set; } =true;
|
||||
public delegate void StringEventHandler(object sender, string e);
|
||||
/// <summary>
|
||||
/// 状态变化时激发
|
||||
/// </summary>
|
||||
[Description("状态变化时激发")]
|
||||
public event StringEventHandler OnStateChanged;
|
||||
public RyProject()
|
||||
{
|
||||
UpdateSetting();
|
||||
@@ -398,6 +407,121 @@ namespace 开发辅助工具.Manager
|
||||
}
|
||||
ryCommon.RyFiles.WriteAllText(AssemblyInfo_path, text, Encoding.UTF8);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 等待进程执行完毕
|
||||
/// </summary>
|
||||
/// <param name="cmd_text"></param>
|
||||
/// <returns></returns>
|
||||
public string Read_Prog(string exe, string cmd_text)
|
||||
{
|
||||
String cmd = exe;
|
||||
Process p = new Process
|
||||
{
|
||||
StartInfo = new System.Diagnostics.ProcessStartInfo
|
||||
{
|
||||
FileName = cmd,//设定程序名
|
||||
Arguments = cmd_text,
|
||||
UseShellExecute = false, //关闭shell的使用
|
||||
RedirectStandardInput = true, //重定向标准输入
|
||||
RedirectStandardOutput = true, //重定向标准输出
|
||||
RedirectStandardError = false, //重定向错误输出
|
||||
CreateNoWindow = true//设置不显示窗口
|
||||
}
|
||||
};
|
||||
p.Start();
|
||||
string result = p.StandardOutput.ReadToEnd();
|
||||
p.WaitForExit(20000);
|
||||
p.Close();
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 进行打包
|
||||
/// </summary>
|
||||
/// <param name="project_folder">项目根目录</param>
|
||||
public void Pack(string project_folder)
|
||||
{
|
||||
var com_mode = "Debug";
|
||||
DataProvider mydb = new DataProvider();
|
||||
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
|
||||
if (db.ConnDb(Itrycn_Db.User_SQLConn) == 1)
|
||||
{
|
||||
var ds = db.ReadData("select * from Settings where name='Setting'");
|
||||
if (mydb.HaveData(ds))
|
||||
{
|
||||
var row = mydb.GetData(ds);
|
||||
ryCommon.Storage mStor = new ryCommon.Storage(row["value"].ToString());
|
||||
mStor.SelectNodeBySet();
|
||||
var ReactorPath = mStor.GetAttrValue("ReactorPath");
|
||||
var WinRARPath = mStor.GetAttrValue("WinRARPath");
|
||||
if (WinRARPath == "")
|
||||
{
|
||||
if (System.IO.File.Exists(@"C:\Program Files\WinRAR\WinRAR.exe"))
|
||||
{
|
||||
WinRARPath = @"C:\Program Files\WinRAR\WinRAR.exe";
|
||||
}
|
||||
}
|
||||
var bf_folder = project_folder;
|
||||
if (bf_folder != "")
|
||||
{
|
||||
ryCommon.Ini ini = new ryCommon.Ini(bf_folder + "\\查看项目.ryp");
|
||||
var eng_name = ini.ReadIni("project", "engname");
|
||||
var proglang = ini.ReadIni("project", "proglang");
|
||||
var ouput_folder = bf_folder + "\\Bin\\" + com_mode + "\\" + eng_name;
|
||||
var file_ver = "";
|
||||
if (System.IO.File.Exists(ouput_folder + "\\" + eng_name + ".exe"))
|
||||
{
|
||||
FileVersionInfo fileVerInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo(ouput_folder + "\\" + eng_name + ".exe");
|
||||
file_ver = fileVerInfo.ProductVersion;
|
||||
}
|
||||
if (proglang == "c#")
|
||||
{
|
||||
ShowState("正在进行混淆...");
|
||||
if (System.IO.File.Exists(bf_folder + "\\Bin\\混淆_" + com_mode + ".nrproj"))
|
||||
{
|
||||
var cmd = Read_Prog(ReactorPath, "-project \"" + bf_folder + "\\Bin\\混淆_" + com_mode + ".nrproj\"");
|
||||
MessageBox.Show(cmd, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
ShowState("正在清理不重要的缓存...");
|
||||
ryCommon.RyFiles.DeleteFile(ouput_folder + "\\Secure\\*.pdb");
|
||||
ShowState("复制混淆文件到底包目录...");
|
||||
ryCommon.RyFiles.CopyFile(ouput_folder + "\\Secure\\*", bf_folder + "\\Publish\\OriginalFiles\\");
|
||||
#region 复制自定义规则文件到底包目录
|
||||
ShowState("复制自定义规则文件到底包目录...");
|
||||
var Publish = ryCommon.RyFiles.ReadAllLines(bf_folder + "\\Publish\\Publish.set");
|
||||
for (int m = 0; m < Publish.Length; m++)
|
||||
{
|
||||
var line = Publish[m].Trim();
|
||||
if (line == "" || line.IndexOf("#") == 0) { continue; }
|
||||
if (line.IndexOfEx("del:") == 0)
|
||||
{
|
||||
ryCommon.RyFiles.DeleteFile(bf_folder + "\\Publish\\OriginalFiles\\" + line.Substring(4));
|
||||
}
|
||||
else if (line.IndexOfEx("copy:") == 0)
|
||||
{
|
||||
var from_to = line.Substring(5).Replace("->", "|").Split('|');
|
||||
if (from_to.Length == 2)
|
||||
{
|
||||
var from_path = from_to[0];
|
||||
var to_path = from_to[1];
|
||||
ryCommon.RyFiles.CopyFile(ouput_folder + "\\" + from_path, bf_folder + "\\Publish\\OriginalFiles\\" + to_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
ShowState("正在打包...");
|
||||
var cmd2 = Read_Prog(WinRARPath, "-r -ep1 a \"" + bf_folder + "\\Publish\\Green\\" + eng_name + ".zip\" \"" + bf_folder + "\\Publish\\OriginalFiles\\\"");
|
||||
RyFiles.CopyFile(bf_folder + "\\Publish\\Green\\" + eng_name + ".zip", bf_folder + "\\Publish\\Green\\HistoryVer\\" + eng_name + "_" + file_ver + ".zip");
|
||||
ShowState("打包完成...");
|
||||
}
|
||||
}
|
||||
}
|
||||
db.Free();
|
||||
void ShowState(string text)
|
||||
{
|
||||
OnStateChanged?.Invoke(this,text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user