public BuildSolutionResult AddSolution(string name) { BuildSolutionResult s = new BuildSolutionResult(name); _solutions.Add(s); return(s); }
private void buildSolution(string slnFile) { if (_cancel) { return; } showInfo("Build solution starts for {0}", slnFile); LimnorSolution.ResetSolution(); BuildSolutionResult sln = _generic.AddSolution(slnFile); treeView1.Nodes.Add(sln.Node); SolutionNode slnNode = _main.LoadSolution(slnFile, false); if (slnNode != null) { ProjectNode[] projects = slnNode.GetProjectBuilderOrder(); if (projects.Length > 0) { string cfg = "Release"; StringCollection _compilerErrors = new StringCollection(); for (int i = 0; i < projects.Length; i++) { if (slnNode.IsProjectBuildIncluded(projects[i])) { buildProject(projects[i], cfg, sln); } if (_cancel) { break; } } if (_compilerErrors.Count > 0) { sln.AppendErrors(_compilerErrors); } } } else { sln.SetError("Solution cannot be loaded"); } sln.End(); Application.DoEvents(); }
public void Build(int sourceControlVersionId, int projectVersionId, Action <int> projectBuildStarted, Action <int, bool> projectBuildComplete) { AspNetDeployEntities entities = new AspNetDeployEntities(); SourceControlVersion sourceControlVersion = entities.SourceControlVersion.Include("SourceControl").First(scv => scv.Id == sourceControlVersionId); ProjectVersion projectVersion = entities.ProjectVersion.Include("Properties").First(pv => pv.Id == projectVersionId); string sourcesFolder = this.pathServices.GetSourceControlVersionPath(sourceControlVersion.SourceControl.Id, sourceControlVersion.Id); IBuildService buildService = buildServiceFactory.Create(projectVersion.ProjectType); BuildSolutionResult buildSolutionResult = buildService.Build( sourcesFolder, projectVersion, projectFileName => { ProjectVersion projectVersionBuild = entities.ProjectVersion .Where(p => p.SourceControlVersionId == sourceControlVersionId) .ToList() .FirstOrDefault(p => !p.IsDeleted && Path.Combine(sourcesFolder, p.ProjectFile).ToLowerInvariant() == projectFileName.ToLowerInvariant()); if (projectVersionBuild != null) { projectBuildStarted(projectVersionBuild.Id); } }, (projectFileName, success, message) => { ProjectVersion projectVersionBuild = entities.ProjectVersion .Where(p => p.SourceControlVersionId == sourceControlVersionId) .ToList() .FirstOrDefault(p => !p.IsDeleted && Path.Combine(sourcesFolder, p.ProjectFile).ToLowerInvariant() == projectFileName.ToLowerInvariant()); if (projectVersionBuild != null) { projectBuildComplete(projectVersionBuild.Id, success); } }, (projectFile, exception) => { this.loggingService.Log(new AspNetDeployException("Project build failed: " + projectFile, exception), null); }); }
private void buildProject(ProjectNode pn, string cfg, BuildSolutionResult sln) { if (_cancel) { return; } LimnorXmlCompiler builder = null; FrmObjectExplorer.RemoveDialogCaches(Guid.Empty, 0); showInfo(pn.Project.ProjectFile); _currentProject = sln.AddProject(pn.Project.ProjectFile); ProjectNodeData pnd = pn.PropertyObject as ProjectNodeData; try { builder = new LimnorXmlCompiler(pnd.ProjectFile, this); } catch (Exception err2) { _currentProject.SetError("Error creating ILimnorBuilder from [LimnorXmlCompiler]. {1} ", err2.Message); builder = null; } if (builder != null) { builder.SetProject(pnd.Project, cfg); if (builder.Execute()) { } else { _currentProject.SetError("Finished building [{0}]. Failed ===============", pnd.Project.ProjectFile); } } _currentProject.End(); Application.DoEvents(); }
static void Main(string[] args) { XDocument webConfig = XDocument.Load(@"H:\Documentoved\FiasOnline\FiasOnline.UI.API\bin\Release\netcoreapp2.0\publish\web.config"); if (webConfig.Descendants("aspNetCore").Any(dd => dd.Attribute("processPath")?.Value == "dotnet")) { } using (ServerManager serverManager = new ServerManager()) { //this.backupSiteConfigurationGuid = this.BackupRepository.StoreObject(site); ApplicationPool applicationPool = ApplicationPool(serverManager, "AspNetDeploy"); ApplicationPool applicationPool2 = ApplicationPool(serverManager, "ButtonBackend1"); } VisualStudio2013SolutionParser solutionParser = new VisualStudio2013SolutionParser(); IList <VisualStudioSolutionProject> projects = solutionParser.Parse(@"H:\Documentoved\FiasOnline\FiasOnline.sln"); foreach (VisualStudioSolutionProject project in projects) { Console.WriteLine(project.Name + " - " + project.Type + " - " + project.Guid + " - " + project.TypeGuid); } DotnetCoreBuildService buildService = new DotnetCoreBuildService(); ProjectVersion pv = new ProjectVersion() { Name = "Blah", ProjectType = ProjectType.Web | ProjectType.NetCore, ProjectFile = @"FiasOnline.UI.API\FiasOnline.UI.API.csproj", SolutionFile = @"H:\Documentoved\FiasOnline" }; buildService.Build(@"H:\Documentoved\FiasOnline", pv, s => { }, (s, b, arg3) => { }, (s, exception) => { }); if (File.Exists(@"H:\Documentoved\FiasOnline\blah.zip")) { File.Delete(@"H:\Documentoved\FiasOnline\blah.zip"); } DotNetCoreProjectPackager projectPackager = new DotNetCoreProjectPackager(); projectPackager.Package(@"H:\Documentoved\FiasOnline\FiasOnline.UI.API\FiasOnline.UI.API.csproj", @"H:\Documentoved\FiasOnline\blah.zip"); Console.WriteLine(projects.Count); //ThreadTaskRunner.ProcessTasks(); /* * VariableProcessorFactory variableProcessorFactory = new VariableProcessorFactory(); * ProjectTestRunnerFactory projectTestRunnerFactory = new ProjectTestRunnerFactory(new PathServices()); * * IVariableProcessor variableProcessor = variableProcessorFactory.Create(278, 9); * * AspNetDeployEntities entities = new AspNetDeployEntities(); * ProjectVersion projectVersion2 = entities.ProjectVersion.Include("SourceControlVersion").First( v => v.Id == 14746); * * * IProjectTestRunner projectTestRunner = projectTestRunnerFactory.Create(projectVersion2.ProjectType, variableProcessor); * * IList<TestResult> testResults = projectTestRunner.Run(projectVersion2); * */ VsTestParser parser = new VsTestParser(); IList <VsTestClassInfo> testClasses = parser.Parse(@"H:\Documentoved\DocumentovedUITests\AccountTests\bin\Debug\AccountTests.dll"); IList <TestResult> result = new List <TestResult>(); IDictionary <string, string> d = new ConcurrentDictionary <string, string>(); string c = null; Thread t = new Thread(() => { while (true) { Console.Clear(); Console.WriteLine(c); foreach (string dKey in d.Keys) { Console.WriteLine(" - " + dKey + " - " + d[dKey]); } Thread.Sleep(1000); } }); t.Start(); foreach (VsTestClassInfo testClass in testClasses) { c = testClass.Type.FullName; d.Clear(); Parallel.ForEach(testClass.TestMethods, new ParallelOptions { MaxDegreeOfParallelism = 5 }, testMethod => { d.Add(testMethod, "started"); VsTestRunner runner = new VsTestRunner(); VsTestRunResult vsTestRunResult = runner.Run(testClass.Type, testClass.InitializeMethod, testMethod, testClass.CleanupMethod); result.Add(new TestResult() { TestClassName = testClass.Type.FullName, TestName = testMethod, IsPass = vsTestRunResult.IsSuccess, Message = vsTestRunResult.Exception?.Message + ". " + vsTestRunResult.Exception?.InnerException?.Message }); d[testMethod] = vsTestRunResult.IsSuccess ? "done" : "fail"; }); } Console.WriteLine("DONE"); Console.ReadKey(); /* * GulpParser gulpParser = new GulpParser(@"H:\Documentoved\Resources"); * * gulpParser.LoadProjects(); * * GulpProjectPackager gulpProjectPackager = new GulpProjectPackager(); * * gulpProjectPackager.Package(@"H:\Documentoved\Resources\documentoved.gulpfile.js", @"H:\Documentoved\Resources\result.zip"); * * * return; */ /* * dynamic bindingConfig = JsonConvert.DeserializeObject("{ port:80, host:'abc.local'}"); * * using (ServerManager serverManager = new ServerManager()) * { * Site site = serverManager.Sites["Account Service Latest"]; * * foreach (Binding siteBinding in site.Bindings) * { * siteBinding.BindingInformation = (string.IsNullOrWhiteSpace((string)bindingConfig.IP) ? "" : (string)bindingConfig.IP) + ":" + (int)bindingConfig.port + ":" + (string)bindingConfig.host; * } * * serverManager.CommitChanges(); * } * * return; */ /* * * Machine machine = entities.Machine.First( m => m.Name == "Lake"); * * WCFSatelliteDeploymentAgent agent = new WCFSatelliteDeploymentAgent(null, machine.URL, machine.Login, machine.Password, new TimeSpan(0, 0, 0, 1), new TimeSpan(0, 0, 0, 1)); * * Console.WriteLine("Runnning"); * Console.WriteLine(agent.IsReady()); */ /* * * List<Machine> machines = entities.Machine.ToList(); * * machines.Where( m => !m.Name.Contains("FastVPS") && !m.Name.Contains("Snow")).ToList().AsParallel().ForAll(machine => * { * WCFSatelliteDeploymentAgent deploymentAgent = new WCFSatelliteDeploymentAgent(null, machine.URL, machine.Login, machine.Password, new TimeSpan(0, 0, 1)); * Console.WriteLine(machine.Id + " - " + machine.Name + " - " + deploymentAgent.IsReady()); * }); * * Console.WriteLine("-=====================-"); * * ISatelliteMonitor satelliteMonitor = new SatelliteMonitor(); * * List<Environment> environments = entities.Environment * .Include("Properties") * .Include("Machines.MachineRoles") * .ToList(); * * Dictionary<Machine, SatelliteState> dictionary = environments.SelectMany(e => e.Machines) * .Distinct() * .AsParallel() * .Select(m => new { m, alive = satelliteMonitor.IsAlive(m) }) * .ToDictionary(k => k.m, k => k.alive); * * DateTime start = DateTime.Now; * * Dictionary<Machine, IServerSummary> summaries = environments.SelectMany(e => e.Machines) * .Distinct() * .AsParallel() * .Select(m => new { m, summary = satelliteMonitor.GetServerSummary(m) }) * .ToDictionary(k => k.m, k => k.summary); * * DateTime end = DateTime.Now; * * Console.WriteLine((end-start).TotalSeconds); * * foreach (KeyValuePair<Machine, SatelliteState> serverSummary in dictionary) * { * Console.WriteLine(serverSummary.Key + " - " + serverSummary.Value); * } */ MSBuildBuildService buildBuildService = new MSBuildBuildService(new PathServices()); DateTime?startDate = null; ProjectVersion projectVersion = new ProjectVersion() { // ProjectFile = @"ZelbikeRace2Database\ZelbikeRace2Database.sqlproj", ProjectFile = @"Services.Accounts\Services.Accounts.csproj", SolutionFile = @"Documentoved.sln" }; Console.WriteLine("Starting"); BuildSolutionResult buildSolutionResult = buildBuildService.Build(@"C:\AspNetDeployWorkingFolderO\Sources\5\207", projectVersion, s => { if (startDate == null) { startDate = DateTime.Now; } Console.WriteLine(s + " - started"); }, (s, b, arg3) => { Console.WriteLine(s + " - " + b); }, (s, s1) => { // e.ProjectFile, e.File, e.Code, e.LineNumber, e.ColumnNumber, e.Message Console.WriteLine(s + "\n" + s1); Console.WriteLine(s1.Message + "\n" + s1); }); DateTime endDate = DateTime.Now; Console.WriteLine(buildSolutionResult.IsSuccess); Console.WriteLine((endDate - startDate.Value).TotalMilliseconds); /* * //string path = @"H:\Documentoved\Latest\Services.ImsPrimary\Databases.ImsPrimary.sqlproj"; * string path = @"H:\Documentoved\Latest\Services.ExceptionHandlingService\Services.Logging.csproj"; * * // SolutionFile solutionFile = SolutionFile.Parse(path); * * // ProjectRootElement element = ProjectRootElement.Open(@"H:\Documentoved\Latest\Services.ExceptionHandlingService\Services.Logging.csproj"); * * * Dictionary<string, string> globalProperty = new Dictionary<string, string> * { * {"Configuration", "Release"} * }; * * ProjectCollection projectCollection = new ProjectCollection(); * * BuildRequestData buildRequestData = new BuildRequestData(path, globalProperty, "14.0", new[] { "Rebuild" }, null); * * BuildParameters buildParameters = new BuildParameters(projectCollection); * buildParameters.MaxNodeCount = 1; * buildParameters.Loggers = new List<ILogger> * { * new ConsoleLogger() * }; * * * * * BuildResult buildResult = Microsoft.Build.Execution.BuildManager.DefaultBuildManager.Build(buildParameters, buildRequestData); * */ //Console.WriteLine("building " + buildResult.OverallResult); /* * * ObjectFactoryConfigurator.Configure(); * * Console.WriteLine("Testing satellites"); * * AspNetDeployEntities entities = new AspNetDeployEntities(); * * MSBuildBuildService service = new MSBuildBuildService(new NugetPackageManager(new PathServices())); * service.Build( * @"H:\AspNetDeployWorkingFolder\Sources\5\45\CodeBase.Documents.WebUI\CodeBase.Documents.WebUI.csproj", * s => Console.WriteLine("started: " + s), (s, b, arg3) => Console.WriteLine("done: " + arg3), (s, s1, arg3, arg4, arg5, arg6) => Console.WriteLine("Err: " + s));*/ /*foreach (Machine machine in entities.Machine) * { * Console.Write(machine.Name + "..."); * Console.WriteLine(Factory.GetInstance<ISatelliteMonitor>().IsAlive(machine)); * } * * Console.ReadKey(); * * RunScheduler();*/ WriteLine("Main thread complete"); Console.ReadKey(); }