//private static string GitKey(string path, string key) //{ // return key + "_" + GitHelper.GetCurrentBranch(path); //} private static string Unique(ISolutionProjectModel projectView, string key) { var result = key + "_" + projectView.SolutionFileName; return(result); //return projectView.IsGitSourceControlled ? GitKey(projectView.ItemPath, result) : result; }
private void RunPreBuildAction(ISolutionProjectModel solution, IServiceSettings settings) { if (solution.SolutionFileName.ToLower().Contains(SolutionNames.PlannerEmbedded.ToLower())) { CPFileHelper.KillProcess("CP-Suite"); } if (solution.SolutionFileName.ToLower().Contains(SolutionNames.ServerEmbedded.ToLower())) { CPFileHelper.KillProcess("CP-Server"); } var cpSettings = settings.GetSettingsFromProvider <CPSettings>(solution); if (cpSettings.DeleteTypeLibs) { if (solution.ItemPath.Contains(SolutionNames.Common)) { DeleteTypeLibs(solution); } } if (cpSettings.RegisterCom) { if (solution.ItemPath.Contains(SolutionNames.ControlCenter)) { RegisterLicProtectorEasyGo(solution.ItemPath); } } if (solution.IsDelphiProject) { RemoveReadOnly(Path.ChangeExtension(solution.ItemPath, ".res"), Path.ChangeExtension(solution.ItemPath, ".ridl"), Path.ChangeExtension(solution.ItemPath, ".tlb")); } }
private void OnTestError(ISolutionProjectModel projectViewModel, MsTestCommand command, string errors, bool cancelOnFailures) { lock (lockObj) { if (projectViewModel.CurrentOperation != null && !string.IsNullOrEmpty(errors)) { projectViewModel.CurrentOperation.ColorBrush = Brushes.DarkRed; } if (!string.IsNullOrEmpty(errors)) { foreach (MsTestError error in MsTestError.Parse(errors)) { UnitTestInfo testInfo = command.UnitTests.First(info => info.TestMethodName == error.TestName); string fileName = error.TestName; if (testInfo.ProjectFileItem != null && testInfo.ProjectFileItem.GetFile().Exists) { fileName = testInfo.ProjectFileItem.GetFile().FullName; } Output.WriteError($"{error.TestName}={error.ErrorMessage}", fileName, testInfo.Line, testInfo.Column, null, TaskCategory.User, testInfo.Project.FullPath, File.Exists(fileName)); } Output.WriteLine(errors); if (cancelOnFailures) { serviceProvider.Get <MainViewModel>().CompleteCancelCommand.Execute(null); } } } }
private static string FindPlatform(IDictionary <string, string> buildProps, ISolutionProjectModel projectViewModel) { string platform; if (buildProps.ContainsKey("Platform")) { if (buildProps["Platform"] == "x64") { platform = "Win64"; } else if (buildProps["Platform"] == "x86") { platform = "Win32"; } else { platform = buildProps["Platform"]; } } else { var project = projectViewModel.GetSolutionProjects().FirstOrDefault(); platform = project?.GetPropertyValue("Platform"); } return(platform ?? (Environment.Is64BitOperatingSystem ? "Win64" : "Win32")); }
private async Task RestorePackagesForSolutionAsync(ISolutionProjectModel projectViewModel, IServiceSettings settings, CancellationToken cancellationToken) { if (!IsCancelled(projectViewModel, cancellationToken)) { NugetServiceSettings nugetServiceSettings = settings.GetSettingsFromProvider <NugetServiceSettings>(projectViewModel); using (new PauseCheckedActionScope(() => projectViewModel.CurrentOperation = Operations.NugetRestore, () => projectViewModel.CurrentOperation = Operations.None, cancellationToken)) { var externalActionService = serviceProvider.Get <ExternalActionService>(); await externalActionService.RunExternalPreActions(projectViewModel, this, cancellationToken : cancellationToken); if (nugetServiceSettings.NugetAction == NugetAction.Restore || nugetServiceSettings.NugetAction == NugetAction.InstallAndRestore) { await NugetRestoreAsync(projectViewModel, settings, cancellationToken); } if (nugetServiceSettings.NugetAction == NugetAction.Install || nugetServiceSettings.NugetAction == NugetAction.InstallAndRestore) { await NugetInstallAsync(projectViewModel, settings, cancellationToken); } if (nugetServiceSettings.NugetAction == NugetAction.Reinstall) { await NugetReinstallAsync(projectViewModel, settings, cancellationToken); } await externalActionService.RunExternalPostActions(projectViewModel, this, true, cancellationToken : cancellationToken); statusService.IncrementStep(); } } }
private string GetBatchScript(ISolutionProjectModel solutionProject, IServiceSettings settings) { if (solutionProject.ParentWorkingFolder == null) { var context = CheckoutAndBuild2Package.GetGlobalService <TfsContext>(); if (context.IsGitSourceControlled(solutionProject.ItemPath)) { string _s = Path.GetPathRoot(solutionProject.SolutionFolder).Replace("\\", string.Empty) + Environment.NewLine; _s += $"cd \"{solutionProject.SolutionFolder}\"" + Environment.NewLine; //_s += "git checkout master"; // TODO Mal richtig für git auschecken und branch ermitteln _s += "git pull"; return(_s); } return(string.Empty); } CheckTFExe(); CheckoutServiceSettings serviceSettings = settings.GetSettingsFromProvider <CheckoutServiceSettings>(solutionProject); var path = GetItemPath(solutionProject, serviceSettings, false); string s = Path.GetPathRoot(solutionProject.ParentWorkingFolder.LocalItem).Replace("\\", string.Empty); s += Environment.NewLine + $"cd \"{solutionProject.ParentWorkingFolder.LocalItem}\"" + Environment.NewLine; s += $"\"{tfExe}\" get \"{path}\" /recursive {GetFlags(serviceSettings)} "; return(s); }
public async Task <GetStatus> CheckoutSolutionAsync(ISolutionProjectModel projectViewModel, IServiceSettings settings = null, VersionSpec versionSpec = null, CancellationToken cancellationToken = default(CancellationToken)) { await cancellationToken.WaitWhenPaused(); if (settings == null) { settings = settingsService.GetMainServiceSettings(); } if (versionSpec == null) { versionSpec = settingsService.Get(SettingsKeys.VersionSpecKey, VersionSpec.Latest); } if (!IsCancelled(projectViewModel, cancellationToken)) { try { using (new PauseCheckedActionScope(() => projectViewModel.CurrentOperation = Operations.Checkout, () => projectViewModel.CurrentOperation = Operations.None, cancellationToken)) { var externalActionService = serviceProvider.Get <ExternalActionService>(); await externalActionService.RunExternalPreActions(projectViewModel, this, settings, cancellationToken); GetStatus status = await Task.Run(() => GetLatestVersionAsync(projectViewModel, settings, versionSpec, cancellationToken), cancellationToken); await externalActionService.RunExternalPostActions(projectViewModel, this, status, settings, cancellationToken); return(status); } } finally { statusService.IncrementStep(); } } return(null); }
public async Task RunExternalPostActions(ISolutionProjectModel model, IOperationService service, object result, IServiceSettings settings = null, CancellationToken cancellationToken = default(CancellationToken)) { if (cancellationToken.IsCancellationRequested) { return; } if (settings == null) { settings = settingsService.GetMainServiceSettings(); } await Task.WhenAll( RunPostServiceScriptFileForProjectAsync(service, model, result, settings, cancellationToken), Task.Run(() => { foreach (ICustomAction externalAction in CheckoutAndBuild2Package.GetExportedValues <ICustomAction>()) { if (cancellationToken.IsCancellationRequested) { break; } externalAction.RunPostAction(service, model, result, settings); } }, cancellationToken)); }
public object GenerateSettingsObjectForInspector(ISolutionProjectModel solutionProject = null, params object[] objectsToMerge) { var propertiesForInspector = new CustomClass("Properties", objectsToMerge); var settingsProviderClasses = CheckoutAndBuild2Package.GetExportedValues <ISettingsProviderClass>(); foreach (ISettingsProviderClass settingsProviderClass in settingsProviderClasses) { var res = GetSettingsFromProvider(settingsProviderClass.GetType(), solutionProject); IEnumerable <PropertyInfo> settableProperties; if (solutionProject != null) { settableProperties = res.GetSettableProperties(SettingsAvailability.ProjectSpecific, SettingsAvailability.GlobalWithProjectSpecificOverride); } else { settableProperties = res.GetSettableProperties(SettingsAvailability.Global, SettingsAvailability.GlobalWithProjectSpecificOverride); } foreach (var propertyInfo in settableProperties) { SettingsKey settingsKey = SettingsExtensions.GetSettingsKey(propertyInfo, res, solutionProject); var value = Get(settingsKey, propertyInfo.PropertyType, propertyInfo.GetValue(res)); propertiesForInspector.AddProperty(propertyInfo, value, o => Set(o.GetType(), settingsKey, o)); } } return(propertiesForInspector); }
private void RunPostBuildAction(ISolutionProjectModel solutionFile, BuildResult result, IServiceSettings settings) { if (solutionFile.ItemPath.Contains(SolutionNames.CPServer)) { var target = new DirectoryInfo(Path.Combine(ExecsDir(solutionFile), Const.AppServerDirName, Const.ModulesDirName, Const.PlannerModuleDir, "manbackup")); if (!target.Exists) { target.Create(); } } var cpSettings = settings.GetSettingsFromProvider <CPSettings>(solutionFile); if (result.OverallResult == BuildResultCode.Success) { // kopiert wenn delphi kompiliert wurde alles aus dem delhi bin zum modules verzeichnis wo es benötigt wird. CopyFromBuildResultDirAsync(solutionFile).Wait(); } if (cpSettings.AutoBackup) { TryRestoreBackups(solutionFile).Wait(); } AutoUndo(solutionFile); }
public static string EnsureAbsolutePath(this ISolutionProjectModel projectViewModel, string relativeOrAbsoluteFilePath) { if (File.Exists(relativeOrAbsoluteFilePath) || relativeOrAbsoluteFilePath.Contains(":\\")) { return(relativeOrAbsoluteFilePath); } return(Check.TryCatch <string, Exception>(() => FileHelper.GetAbsolutePath(relativeOrAbsoluteFilePath, projectViewModel.SolutionFolder))); }
private async Task NugetReinstallAsync(ISolutionProjectModel projectViewModel, IServiceSettings settings, CancellationToken cancellationToken) { var builder = new StringBuilder() .AppendLine($"Set-Location -Path \"{projectViewModel.SolutionFolder}\" ") .AppendLine("Update-Package -Reinstall"); await ScriptHelper.ExecutePowershellScriptAsync(builder.ToString(), null, cancellationToken); }
private async Task <GetStatus> GetLatestVersionAsync(ISolutionProjectModel projectViewModel, IServiceSettings settings, VersionSpec versionSpec, CancellationToken cancellationToken = default(CancellationToken)) { ItemSpec itemSpec = new ItemSpec(projectViewModel.SolutionFolder, RecursionType.Full); await cancellationToken.WaitWhenPaused(); return(await GetLatestVersionAsync(itemSpec, versionSpec, settings, projectViewModel, cancellationToken)); }
private string DevDir(ISolutionProjectModel solutionFile) { if (!solutionFile.IsDelphiProject) { return(Path.Combine(new DirectoryInfo(solutionFile.SolutionFolder).Parent.Parent.FullName)); } return(Path.Combine(new DirectoryInfo(solutionFile.SolutionFolder).Parent.Parent.Parent.FullName)); }
public void Cancel(ISolutionProjectModel projectViewModel) { if (cancelledSolutions == null) { cancelledSolutions = new ConcurrentBag <ISolutionProjectModel>(); } cancelledSolutions.Add(projectViewModel); }
public bool?ShouldIncludedByDefault(ISolutionProjectModel solution) { if (solution.IsDelphiProject) { return(solution.SolutionFileName == "CPlannerEmbedded.dproj" || solution.SolutionFileName == "CPServerEmbedded.dproj"); } return(solution.SolutionFileName.StartsWith("CP.")); }
private IEnumerable <string> GetToBackupSources(ISolutionProjectModel solutionFile, string[] toBackup) { foreach (var dirName in toBackup) { yield return(Path.Combine(ExecsDir(solutionFile), dirName)); yield return(Path.Combine(TestsDir(solutionFile), dirName)); } }
public BuildErrorsViewModel(IEnumerable <ErrorTask> tasks, IOperationService requestedOperation, ISolutionProjectModel project, IServiceProvider serviceProvider) : base(serviceProvider) { Errors = new ObservableCollection <ErrorTask>(tasks.ToList()); Title = string.Format("{1} Error for '{0}'", project.SolutionFileName, requestedOperation.OperationName); Message = string.Format("{0} errors for '{1}' occured", Errors.Count, project.SolutionFileName); RequestedOperation = requestedOperation; Project = project; Image = Images.BuildErrorList_7237.ToImageSource(); }
private object GetErrorsViewModel(ISolutionProjectModel project, BuildResult buildResult) { var res = new BuildErrorsViewModel(Output.FindErrorTasks(project), this, project, serviceProvider); if (buildResult.Exception != null) { res.Message = buildResult.Exception.Message; } return(res); }
private string GetBatchScript(ISolutionProjectModel model, IServiceSettings settings) { NugetServiceSettings nugetServiceSettings = settings.GetSettingsFromProvider <NugetServiceSettings>(model); return(new StringBuilder() .AppendLineWhen($"\"{NugetExe(model, settings)}\" restore \"{model.ItemPath}\"", s => nugetServiceSettings.NugetAction == NugetAction.Restore || nugetServiceSettings.NugetAction == NugetAction.InstallAndRestore) .AppendLinesWhen(Directory.EnumerateFiles(model.SolutionFolder, "packages.config", SearchOption.AllDirectories) .Select(s => new FileInfo(s)) .Select(file => $"\"{NugetExe(model, settings)}\" install \"{file.FullName}\" -OutputDirectory \"{file.Directory.Parent.FullName}\\packages\""), s => nugetServiceSettings.NugetAction == NugetAction.Install || nugetServiceSettings.NugetAction == NugetAction.InstallAndRestore).ToString()); }
public static IEnumerable <string> GetOutputDirectories(this ISolutionProjectModel solution, bool includeTestOutputs, bool includeNotExisting) { var dirs = new List <string>(); foreach (string dir in solution.GetSolutionProjects().Where(project => includeTestOutputs || !project.IsTestProject()).Select(project => Path.Combine(Path.GetDirectoryName(project.FullPath), project.GetOutputPath())).Where(dir => !string.IsNullOrEmpty(dir) && !dirs.Contains(dir) && (includeNotExisting || Directory.Exists(dir)))) { dirs.Add(dir); } return(dirs); }
public static Solution ToSolution(this ISolutionProjectModel model) { if (cache.ContainsKey(model.ItemPath)) { return(cache[model.ItemPath]); } var res = new Solution(model.ItemPath); cache.AddOrUpdate(model.ItemPath, res); return(res); }
private IDictionary <string, string> GetProjectSpecificBuildProperties(ISolutionProjectModel projectViewModel, IServiceSettings settings) { var res = serviceProvider.Get <ExternalActionService>().GetDefaultBuildProperties(projectViewModel, settings) ?? new Dictionary <string, string>(); var buildProperties = projectViewModel.BuildProperties; if (buildProperties != null && buildProperties.Any()) { return(res.MergeWith(buildProperties)); } return(res); }
public IDictionary <string, string> GetDefaultBuildProperties(ISolutionProjectModel project, IServiceSettings settings) { if (settings.GetSettingsFromProvider <CPSettings>().SetupDelphiMagic) { if (project.SolutionFileName.ToLower().Contains(SolutionNames.PlannerEmbedded.ToLower())) { return(GetPlannerEmbeddedBuildProperties(project)); } } return(new Dictionary <string, string>()); }
public static IEnumerable <ErrorTask> FindErrorTasks(ISolutionProjectModel project) { var errors = new List <ErrorTask>(); foreach (var projectPath in project.GetSolutionProjects().Select(p => p.FullPath).Concat(project.ToSolution().Projects.Select(solutionProject => solutionProject.ProjectName).Distinct())) { errors.AddRange(FindErrorTasks(null, projectPath)); } return(errors); }
public string NugetExe(ISolutionProjectModel solution, IServiceSettings settings) { var nugetPath = settings.GetSettingsFromProvider <NugetServiceSettings>(solution).NugetExeLocation; var result = !string.IsNullOrEmpty(nugetPath) && File.Exists(nugetPath) ? nugetPath : Path.Combine(solution.SolutionFolder, ".nuget", "nuget.exe"); if (!File.Exists(result)) { result = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetCallingAssembly().Location), "Resources", "nuget35.exe"); //"nuget35.exe" //"nuget28.exe" } return(result); }
private string GetPowershellScript(ISolutionProjectModel solutionProject, IServiceSettings settings) { StringBuilder builder = new StringBuilder(); foreach (Project project in solutionProject.GetUnitTestProjects()) { var unitTestInfos = project.GetTestMethods().ToArray(); var command = GetTestCommand(solutionProject, settings, unitTestInfos, true); builder.AppendLine($"\"{command.MsTestProcess.MsTestPath}\" {command}"); } return(builder.ToString()); }
private string[] GetBuildTargets(ISolutionProjectModel projectViewModel) { var buildTargets = projectViewModel.BuildTargets ?? new List <string>(); var res = buildTargets.Where(s => !string.IsNullOrEmpty(s)).ToArray(); if (res.Length == 0) { res = new[] { "Build" } } ; return(res); }
private void AutoUndo(ISolutionProjectModel solutionFile) { if (solutionFile.ItemPath.Contains(SolutionNames.PlannerEmbedded) || solutionFile.ItemPath.Contains(SolutionNames.PlannerEmbedded)) { UndoIfChanged(solutionFile.SolutionFolder, "*.res"); } if (solutionFile.ItemPath.Contains(SolutionNames.CPServer)) { UndoIfChanged(solutionFile.SolutionFolder, "*.Generated.cs"); } }
private string GetBatchScript(ISolutionProjectModel solutionProject, IServiceSettings settings) { StringBuilder builder = new StringBuilder(); foreach (Project project in solutionProject.GetUnitTestProjects()) { var unitTestInfos = project.GetTestMethods().ToArray(); //SetOrUpdateSettingsFile(projectViewModel, settings, unitTestInfos); var command = GetTestCommand(solutionProject, settings, unitTestInfos, true); builder.AppendLine($"Invoke-Expression \"{command.MsTestProcess.MsTestPath}\" {command}"); } return(builder.ToString()); }