Пример #1
0
        private void DoAntDeployProcess(string projectPath, ProjectParam param)
        {
            var md5             = CodingHelper.MD5(projectPath);
            var path            = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            var projectPram     = JsonConvert.SerializeObject(param);
            var projectPramPath = Path.Combine(path, md5 + "_param.json");

            File.WriteAllText(projectPramPath, projectPram, Encoding.UTF8);

            var assembly          = Assembly.GetExecutingAssembly();
            var codeBase          = assembly.Location;
            var codeBaseDirectory = Path.GetDirectoryName(codeBase);
            var ant = Path.Combine(codeBaseDirectory, "AntDeployApp.exe");

            using (var process = new Process())
            {
                process.StartInfo.FileName        = ant;
                process.StartInfo.Arguments       = $"\"{projectPramPath}\"";
                process.StartInfo.CreateNoWindow  = false;
                process.StartInfo.WindowStyle     = ProcessWindowStyle.Normal;
                process.StartInfo.UseShellExecute = false;
                process.StartInfo.Verb            = "runas";

                process.Start();

                process.WaitForExit();
            }
        }
Пример #2
0
        public static string GetPluginConfigPath(string projectName = null)
        {
            try
            {
                var path       = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                var folderName = Path.Combine(path, "AntDeploy");
                if (!string.IsNullOrEmpty(folderName))
                {
                    if (!Directory.Exists(folderName))
                    {
                        Directory.CreateDirectory(folderName);
                    }

                    return(Path.Combine(folderName, string.IsNullOrEmpty(projectName)? "AntDeploy.json": CodingHelper.MD5(projectName) + ".json"));
                }
                return(string.Empty);
            }
            catch (Exception)
            {
                return(string.Empty);
            }
        }