private void initProjectJson() { var config = new ProjectJsonConfig(); config.Init(); config.studioVersion = Common.GetProgramVersion(); config.name = ProjectName; config.description = ProjectDescription; config.main = "Main.xaml"; //Packages目录下的nupkg包遍历,然后保存到依赖包对象里 var repo = PackageRepositoryFactory.Default.CreateRepository(System.Environment.CurrentDirectory + @"\Packages"); var nupkgs = repo.GetPackages(); foreach (var item in nupkgs) { if (Regex.IsMatch(item.Id, "RPA.*.Activities", RegexOptions.IgnoreCase)) { var ver = item.Version.ToString(); config.dependencies[item.Id] = $"[{ver}]"; } } if (ProjectType == enProjectType.Process) { config.projectType = "Workflow"; } string json = JsonConvert.SerializeObject(config, Newtonsoft.Json.Formatting.Indented); using (FileStream fs = new FileStream(ProjectPath + @"\" + ProjectName + @"\project.json", FileMode.Create)) { //写入 using (StreamWriter sw = new StreamWriter(fs)) { sw.Write(json); } } }
public void SaveProjectJsonConfig(ProjectJsonConfig json_cfg) { string output = Newtonsoft.Json.JsonConvert.SerializeObject(json_cfg, Newtonsoft.Json.Formatting.Indented); File.WriteAllText(CurrentProjectJsonFile, output); }