private void Should_be_able_to_add_excluded_file_with_properties_to_project(string projectRelativePath) { var projectTool = TempCopyAndGetProject(projectRelativePath); var scanFilesInProjectFolderBefore = projectTool.ScanFilesInProjectFolder(); var compileFilesBefore = scanFilesInProjectFolderBefore .Where(f => f.IncludeType == "Compile") .Select(f => $"{f.IncludeType}:{f.Name}:{f.Properties.Get("prop1")}:{f.Properties.Get("prop2")}") .ToArray(); var newFilePath = PathExtensions.GetAbsolutePath(projectTool.FolderPath, $"SampleClass3NotIncludedInproject.cs"); var fileProperties = new Dictionary <string, string>() { { "prop1", "value1" }, { "prop2", "value2" } }; projectTool.AddFileToProject(newFilePath, "Compile", fileProperties); projectTool.Save(); var newProjectTool = new ProjectTool(projectTool.FilePath, new ConsoleDebugLogger(true)); var scanFilesInProjectFolderAfter = newProjectTool.ScanFilesInProjectFolder(); var compileFilesAfter = scanFilesInProjectFolderAfter .Where(f => f.IncludeType == "Compile") .Select(f => $"{f.IncludeType}:{f.Name}:{f.Properties.Get("prop1")}:{f.Properties.Get("prop2")}") .OrderBy(o => o) .Debug(new ConsoleDebugLogger(true)) .ToArray(); compileFilesAfter.Should().BeEquivalentTo( compileFilesBefore.Union(new string[] { "Compile:SampleClass3NotIncludedInproject.cs:value1:value2" }) .OrderBy(o => o) .Debug(new ConsoleDebugLogger(true)) .ToArray() ); }
public void RemoveFilesNotIncludedInProjects(SolutionTool solutionTool) { var projects = solutionTool.GetProjectsWithParents().ToArray(); foreach (var project in projects) { if (solutionTool.CompilableProjects.Contains(project.Type)) { var projectPath = PathExtensions.GetAbsolutePath(solutionTool.FolderPath, project.Path); var projectTool = new ProjectTool(projectPath, _logger); var fileReferences = projectTool.ScanFilesInProjectFolder(); var filesNotInProject = fileReferences.Where(f => f.OnDisk && !f.InProjectFile).ToArray(); var filesNotOnDisk = fileReferences.Where(f => !f.OnDisk && f.InProjectFile).ToArray(); if (filesNotOnDisk.Any() || filesNotInProject.Any()) { _logger.LogMessage($"Scanned files in {projectTool.Name}"); if (filesNotInProject.Any()) { _logger.LogMessage($"\tFiles NOT in {projectTool.Name}"); foreach (var fileReference in fileReferences.Where(f => f.OnDisk && !f.InProjectFile)) { _logger.LogMessage($"\t\t{fileReference.Name}"); System.IO.File.Delete(fileReference.Path); } } } } } }
private void Should_be_able_to_remove_file_without_properties_from_project(string projectRelativePath) { var projectTool = TempCopyAndGetProject(projectRelativePath); var scanFilesInProjectFolderBefore = projectTool.ScanFilesInProjectFolder(); var compileFilesBefore = scanFilesInProjectFolderBefore .Where(f => f.IncludeType == "Compile") .Select(f => $"{f.IncludeType}:{f.Name}:{f.Properties.Get("prop1")}:{f.Properties.Get("prop2")}") .ToArray(); var removeFilePath = PathExtensions.GetAbsolutePath(projectTool.FolderPath, $"SampleClass1IncludedInproject.cs"); projectTool.RemoveFileFromProject(removeFilePath); projectTool.Save(); var newProjectTool = new ProjectTool(projectTool.FilePath, new ConsoleDebugLogger(true)); var scanFilesInProjectFolderAfter = newProjectTool.ScanFilesInProjectFolder(); var compileFilesAfter = scanFilesInProjectFolderAfter .Where(f => f.IncludeType == "Compile") .Select(f => $"{f.IncludeType}:{f.Name}:{f.Properties.Get("prop1")}:{f.Properties.Get("prop2")}") .OrderBy(o => o) .ToArray() .Debug(new ConsoleDebugLogger(true)) ; compileFilesAfter.Should().BeEquivalentTo( compileFilesBefore.Except(new string[] { "Compile:SampleClass1IncludedInproject.cs::" }) .OrderBy(o => o) .ToArray() .Debug(new ConsoleDebugLogger(true)) ); }
public object Delete(Guid project_id, Guid tool_id, string stage) { try { string[] tool_type = _tool.Where(t => t.Id.Equals(tool_id)) .Select(t => t.ToolType).FirstOrDefault().Split(","); if (!tool_type.Any(tt => tt.Equals(stage))) { throw BadRequest("Unidentified stage!"); } ProjectTool project_tool = _projectTool.GetOne(pt => pt.ProjectId.Equals(project_id) && pt.ToolId.Equals(tool_id)); if (project_tool == null) { throw NotFound(); } if (!string.IsNullOrEmpty(project_tool.Stages)) { project_tool.Stages = project_tool.Stages.Replace("," + stage, "").Replace(stage + ",", "").Replace(stage, ""); if (string.IsNullOrEmpty(project_tool.Stages)) { project_tool.Stages = null; } } SaveChanges(); return(GetProjectTools(project_id)); } catch (Exception e) { throw e is RequestException ? e : _errorHandler.WriteLog("An error occurred while delete a project's tool!", e, DateTime.Now, "Server", "Service_ProjectTool_DeleteProjectTool"); } }
private void Should_be_able_to_add_file_to_project(string projectRelativePath) { var projectTool = TempCopyAndGetProject(projectRelativePath); var scanFilesInProjectFolderBefore = projectTool.ScanFilesInProjectFolder(); var compileFilesBefore = scanFilesInProjectFolderBefore .Where(f => f.IncludeType == "Compile") .Select(f => $"{f.IncludeType}:{f.Name}") .ToArray(); var newFilePath = PathExtensions.GetAbsolutePath(projectTool.FolderPath, $"newCompileFile.cs"); projectTool.AddFileToProject(newFilePath, "Compile"); projectTool.Save(); var newProjectTool = new ProjectTool(projectTool.FilePath, new ConsoleDebugLogger(true)); var scanFilesInProjectFolderAfter = newProjectTool.ScanFilesInProjectFolder(); var compileFilesAfter = scanFilesInProjectFolderAfter .Where(f => f.IncludeType == "Compile") .Select(f => $"{f.IncludeType}:{f.Name}") .OrderBy(o => o) .Debug(new ConsoleDebugLogger(true)) .ToArray(); compileFilesAfter.Should().BeEquivalentTo( // Admittedly this does nothing, as the file actually doesn't exist on disk for CPS projects. But the change to the project should be this (none) projectTool.IsCpsDocument ? compileFilesBefore : compileFilesBefore.Union(new string[] { "Compile:newCompileFile.cs" }) .OrderBy(o => o) .Debug(new ConsoleDebugLogger(true)) .ToArray() ); }
private ProjectTool GetProjectTool(string projectRelativePath) { var currentFolder = System.IO.Path.GetDirectoryName(new Uri(this.GetType().Assembly.CodeBase).LocalPath); var csProjAbsolutePath = PathExtensions.GetAbsolutePath(currentFolder, projectRelativePath); var projectTool = new ProjectTool(csProjAbsolutePath, new DebugLogger(true)); return(projectTool); }
private static Commands SetUpCommands() { var pat = ToolHelper.GetPersonalAccessToken(); var client = new Client(pat); var projectTool = new ProjectTool( client, AppSettings.AzureDevOpsOrganization, AppSettings.AzureDevOpsProject ); var projectId = (Guid)projectTool.GetId(AppSettings.AzureDevOpsProject).Result; var buildTool = new BuildDefinitionTool( client, AppSettings.AzureDevOpsOrganization, AppSettings.AzureDevOpsProject, projectId ); var releaseTool = new ReleaseDefinitionTool( client, AppSettings.AzureDevOpsOrganization, AppSettings.AzureDevOpsProject ); var repositoryTool = new RepositoryTool( client, AppSettings.AzureDevOpsOrganization, AppSettings.AzureDevOpsProject, projectId ); var taskTool = new TaskGroupTool( client, AppSettings.AzureDevOpsOrganization, AppSettings.AzureDevOpsProject ); var variableGroupTool = new VariableGroupTool( client, AppSettings.AzureDevOpsOrganization, AppSettings.AzureDevOpsProject ); var commands = new Commands( buildTool, releaseTool, projectTool, repositoryTool, taskTool, variableGroupTool); return(commands); }
public void Constructor_Succeeds() { var result = new ProjectTool( _clientMock.Object, TestHelper.RealOrganization, TestHelper.RealProject ); Assert.That(result, Is.Not.Null); }
public IActionResult AddTool(int toolId, int id) { var thisProject = _db.Projects.Include(projects => projects.Updates).Include(projects => projects.ProjectTools).Include(projects => projects.Sprints).FirstOrDefault(projects => projects.ProjectId == id); var newTool = _db.Tools.FirstOrDefault(tools => tools.ToolId == toolId); var newProjectTool = new ProjectTool(); newProjectTool.ProjectId = id; newProjectTool.ToolId = toolId; _db.ProjectTools.Add(newProjectTool); _db.SaveChanges(); return(RedirectToAction("Details")); }
public void SetAuth(Guid project_id, Guid tool_id, bool has_auth) { try { ProjectTool project_tool = _projectTool.GetOne(pt => pt.ProjectId.Equals(project_id) && pt.ToolId.Equals(tool_id)); SaveChanges(); } catch (Exception e) { throw e is RequestException ? e : _errorHandler.WriteLog("An error occurred!", e, DateTime.Now, "Server", "Service-ProjectTool-SetAuth"); } }
public void ScanAllReferencesInProjectFiles(SolutionTool solutionTool) { var projects = solutionTool.GetProjectsWithParents().ToArray(); var references = new List <ProjectReference>(); foreach (var project in projects) { if (solutionTool.CompilableProjects.Contains(project.Type)) { var projectPath = PathExtensions.GetAbsolutePath(solutionTool.FolderPath, project.Path); var projectTool = new ProjectTool(projectPath, _logger); references.AddRange(projectTool.ScanReferences()); _logger.LogMessage($"Scanned {projectTool.Name}"); } } foreach (var referenceName in references.GroupBy(r => r.Name).OrderBy(r => r.Key)) { var referenceVersions = referenceName.GroupBy(r => $"{r.PackageVersion?.ToString()}-{r.ReferenceType}"); //var referenceVersions = referenceName.GroupBy(r => $"{r.Version?.ToString()}/{r.PackageVersion?.ToString()}-{r.ReferenceType}"); if (referenceVersions.Count() > 1) { _logger.LogMessage($"\t{referenceName.Key}"); foreach (var referenceVersion in referenceVersions) { _logger.LogMessage($"\t\t{referenceVersion.Key}"); foreach (var reference in referenceVersion) { _logger.LogMessage( $"\t\t\t{reference.Source} - {reference.Version}/{reference.PackageVersion} {reference.ReferenceType} {reference.PackageName}"); } } } else { //_logger.LogMessage($"\t{referenceName.Key} - {referenceVersions.FirstOrDefault().Key} - {referenceName.Count()} references"); } } // Check different version of the same reference // Check different types of references with the same name }
private ProjectTool TempCopyAndGetProject(string projectRelativePath) { var currentFolder = System.IO.Path.GetDirectoryName(new Uri(this.GetType().Assembly.CodeBase).LocalPath); var csProjAbsolutePath = PathExtensions.GetAbsolutePath(currentFolder, projectRelativePath); var projectFolder = System.IO.Path.GetDirectoryName(csProjAbsolutePath); var projectTempCopyName = $"{System.IO.Path.GetRandomFileName()}.csproj"; var projectTempCopyPath = PathExtensions.GetAbsolutePath(projectFolder, projectTempCopyName); System.IO.File.Copy(csProjAbsolutePath, projectTempCopyPath); _temporaryProjectFileCopies.Add(projectTempCopyPath); var projectTool = new ProjectTool(projectTempCopyPath, new DebugLogger(true)); return(projectTool); }
public void CleanUpReferencesInProjectFile(SolutionTool solutionTool) { var projects = solutionTool.GetProjectsWithParents().ToArray(); foreach (var project in projects) { if (solutionTool.CompilableProjects.Contains(project.Type)) { var projectPath = PathExtensions.GetAbsolutePath(solutionTool.FolderPath, project.Path); var projectTool = new ProjectTool(projectPath, _logger); projectTool.CleanUpProject(); _logger.LogMessage($"Cleaned {projectTool.Name}"); projectTool.Save(); } } }
public static IEnumerable <FolderProjectItem> GetMatchingTargets(SolutionTool solutionTool, FolderTool folderTool, ILogger logger) { var matchingTargets = new List <FolderProjectItem>(); var projects = solutionTool.GetProjectsWithParents().ToArray(); var targetProjects = folderTool.GetProjects(); var targetProjectsLookup = targetProjects.ToDictionary(p => p.Name, p => p); foreach (var project in projects) { if (solutionTool.CompilableProjects.Contains(project.Type)) { var projectPath = PathExtensions.GetAbsolutePath(solutionTool.FolderPath, project.Path); var projectTool = new ProjectTool(projectPath, logger); foreach (var reference in projectTool.GetReferences()) { if (targetProjectsLookup.ContainsKey(reference.Name)) { var matchingProject = targetProjectsLookup[reference.Name]; var nugetPackagesConfigPath = PathExtensions.GetAbsolutePath(projectTool.FolderPath, "packages.config"); if (System.IO.File.Exists(nugetPackagesConfigPath)) { var nugetTool = new NugetTool(nugetPackagesConfigPath); var packages = nugetTool.GetNugetPackages(); var referencePackage = packages.FirstOrDefault(pkg => pkg.Name == reference.Name); if (referencePackage != null) { if (!matchingTargets.Contains(matchingProject)) { matchingTargets.Add(matchingProject); } } } } } } } return(matchingTargets); }
public void SetAccount(TokenProjectAccountM model) { try { ProjectTool project_tool = _projectTool.GetOne(pt => pt.ProjectId.Equals(model.ProjectId) && pt.ToolId.Equals(model.ToolId)); if (project_tool == null) { throw NotFound(); } project_tool.AccountId = model.AccountId; SaveChanges(); } catch (Exception e) { throw e is RequestException ? e : _errorHandler.WriteLog("An error occurred!", e, DateTime.Now, "Server", "Service-ProjectTool-SetAccount"); } }
private static RepositoryTool SetUpRealTool() { var pat = ToolHelper.GetPersonalAccessToken(); var client = new Client(pat); var projectTool = new ProjectTool( client, TestHelper.RealOrganization, TestHelper.RealProject); var projectId = Guid.Parse(projectTool.GetId(TestHelper.RealProject).Result.ToString()); var output = new RepositoryTool( client, TestHelper.RealOrganization, TestHelper.RealProject, projectId); return(output); }
public object Add(Guid project_id, Guid tool_id, string stage) { try { string[] tool_type = _tool.Where(t => t.Id.Equals(tool_id)) .Select(t => t.ToolType).FirstOrDefault().Split(","); if (!tool_type.Any(tt => tt.Equals(stage))) { throw BadRequest("Unidentified stage!"); } ProjectTool project_tool = _projectTool.GetOne(pt => pt.ProjectId.Equals(project_id) && pt.ToolId.Equals(tool_id)); if (project_tool == null) { project_tool = _projectTool.Add(new ProjectTool { ToolId = tool_id, ProjectId = project_id, Stages = stage }); } else { if (string.IsNullOrEmpty(project_tool.Stages)) { project_tool.Stages = stage; } else if (!project_tool.Stages.Contains(stage)) { project_tool.Stages += "," + stage; } } SaveChanges(); return(GetProjectTools(project_id)); } catch (Exception e) { throw e is RequestException ? e : _errorHandler.WriteLog("An error occurred!", e, DateTime.Now, "Server", "Service-ProjectTool-Add"); } }
public object Build( CSharp.Assembly moduleToBuild, out System.Boolean success) { var assemblyModule = moduleToBuild as Bam.Core.BaseModule; var node = assemblyModule.OwningNode; var target = node.Target; var options = assemblyModule.Options as CSharp.OptionCollection; var moduleName = node.ModuleName; string platformName; switch ((options as CSharp.IOptions).Platform) { case CSharp.EPlatform.AnyCpu: platformName = "AnyCPU"; break; case CSharp.EPlatform.X86: platformName = "x86"; break; case CSharp.EPlatform.X64: case CSharp.EPlatform.Itanium: platformName = "x64"; break; default: throw new Bam.Core.Exception("Unrecognized platform"); } ICSProject projectData = null; // TODO: want to remove this lock (this.solutionFile.ProjectDictionary) { if (this.solutionFile.ProjectDictionary.ContainsKey(moduleName)) { projectData = this.solutionFile.ProjectDictionary[moduleName] as ICSProject; } else { var solutionType = Bam.Core.State.Get("VSSolutionBuilder", "SolutionType") as System.Type; var SolutionInstance = System.Activator.CreateInstance(solutionType); var ProjectExtensionProperty = solutionType.GetProperty("ProjectExtension"); var projectExtension = ProjectExtensionProperty.GetGetMethod().Invoke(SolutionInstance, null) as string; var projectDir = node.GetModuleBuildDirectoryLocation().GetSinglePath(); var projectPathName = System.IO.Path.Combine(projectDir, moduleName); projectPathName += projectExtension; var projectType = VSSolutionBuilder.GetProjectClassType(); projectData = System.Activator.CreateInstance(projectType, new object[] { moduleName, projectPathName, node.Package.Identifier, assemblyModule.ProxyPath }) as ICSProject; this.solutionFile.ProjectDictionary.Add(moduleName, projectData); } } { if (!projectData.Platforms.Contains(platformName)) { projectData.Platforms.Add(platformName); } } // solution folder { var groups = moduleToBuild.GetType().GetCustomAttributes(typeof(Bam.Core.ModuleGroupAttribute), true); if (groups.Length > 0) { projectData.GroupName = (groups as Bam.Core.ModuleGroupAttribute[])[0].GroupName; } } if (node.ExternalDependents != null) { foreach (var dependentNode in node.ExternalDependents) { if (dependentNode.ModuleName == moduleName) { continue; } // TODO: want to remove this lock (this.solutionFile.ProjectDictionary) { if (this.solutionFile.ProjectDictionary.ContainsKey(dependentNode.ModuleName)) { var dependentProject = this.solutionFile.ProjectDictionary[dependentNode.ModuleName]; projectData.DependentProjects.Add(dependentProject); } } } } // references // TODO: convert to var foreach (Bam.Core.Location location in (options as CSharp.IOptions).References) { var reference = location.GetSinglePath(); projectData.References.Add(reference); } var configurationName = VSSolutionBuilder.GetConfigurationNameFromTarget(target, platformName); ProjectConfiguration configuration; lock (projectData.Configurations) { if (!projectData.Configurations.Contains(configurationName)) { // TODO: fix me? configuration = new ProjectConfiguration(configurationName, projectData); configuration.CharacterSet = EProjectCharacterSet.NotSet; projectData.Configurations.Add((Bam.Core.BaseTarget)target, configuration); } else { configuration = projectData.Configurations[configurationName]; projectData.Configurations.AddExistingForTarget((Bam.Core.BaseTarget)target, configuration); } } var fields = moduleToBuild.GetType().GetFields(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic); foreach (var field in fields) { // C# files { var sourceFileAttributes = field.GetCustomAttributes(typeof(Bam.Core.SourceFilesAttribute), false); if (null != sourceFileAttributes && sourceFileAttributes.Length > 0) { var sourceField = field.GetValue(moduleToBuild); if (sourceField is Bam.Core.Location) { var file = sourceField as Bam.Core.Location; var absolutePath = file.GetSinglePath(); if (!System.IO.File.Exists(absolutePath)) { throw new Bam.Core.Exception("Source file '{0}' does not exist", absolutePath); } ProjectFile sourceFile; lock (projectData.SourceFiles) { if (!projectData.SourceFiles.Contains(absolutePath)) { sourceFile = new ProjectFile(absolutePath); sourceFile.FileConfigurations = new ProjectFileConfigurationCollection(); projectData.SourceFiles.Add(sourceFile); } else { sourceFile = projectData.SourceFiles[absolutePath]; } } } else if (sourceField is Bam.Core.FileCollection) { var sourceCollection = sourceField as Bam.Core.FileCollection; // TODO: convert to var foreach (Bam.Core.Location location in sourceCollection) { var absolutePath = location.GetSinglePath(); if (!System.IO.File.Exists(absolutePath)) { throw new Bam.Core.Exception("Source file '{0}' does not exist", absolutePath); } ProjectFile sourceFile; lock (projectData.SourceFiles) { if (!projectData.SourceFiles.Contains(absolutePath)) { sourceFile = new ProjectFile(absolutePath); sourceFile.FileConfigurations = new ProjectFileConfigurationCollection(); projectData.SourceFiles.Add(sourceFile); } else { sourceFile = projectData.SourceFiles[absolutePath]; } } } } else { throw new Bam.Core.Exception("Field '{0}' of '{1}' should be of type Bam.Core.File or Bam.Core.FileCollection, not '{2}'", field.Name, node.ModuleName, sourceField.GetType().ToString()); } } } // WPF application definition .xaml file { var xamlFileAttributes = field.GetCustomAttributes(typeof(CSharp.ApplicationDefinitionAttribute), false); if (null != xamlFileAttributes && xamlFileAttributes.Length > 0) { var sourceField = field.GetValue(moduleToBuild); if (sourceField is Bam.Core.Location) { var file = sourceField as Bam.Core.Location; var absolutePath = file.GetSinglePath(); if (!System.IO.File.Exists(absolutePath)) { throw new Bam.Core.Exception("Application definition file '{0}' does not exist", absolutePath); } #if false // TODO: in theory, this file should be generated in VS, but it doesn't seem to string csPath = absolutePath + ".cs"; if (!System.IO.File.Exists(csPath)) { throw new Bam.Core.Exception("Associated source file '{0}' to application definition file '{1}' does not exist", csPath, absolutePath); } #endif projectData.ApplicationDefinition = new ProjectFile(absolutePath); } else if (sourceField is Bam.Core.FileCollection) { var sourceCollection = sourceField as Bam.Core.FileCollection; if (sourceCollection.Count != 1) { throw new Bam.Core.Exception("There can be only one application definition"); } // TODO: convert to var foreach (string absolutePath in sourceCollection) { if (!System.IO.File.Exists(absolutePath)) { throw new Bam.Core.Exception("Application definition file '{0}' does not exist", absolutePath); } #if false // TODO: in theory, this file should be generated in VS, but it doesn't seem to string csPath = absolutePath + ".cs"; if (!System.IO.File.Exists(csPath)) { throw new Bam.Core.Exception("Associated source file '{0}' to application definition file '{1}' does not exist", csPath, absolutePath)); } #endif projectData.ApplicationDefinition = new ProjectFile(absolutePath); } } else { throw new Bam.Core.Exception("Field '{0}' of '{1}' should be of type Bam.Core.File or Bam.Core.FileCollection, not '{2}'", field.Name, node.ModuleName, sourceField.GetType().ToString()); } } } // WPF page .xaml files { var xamlFileAttributes = field.GetCustomAttributes(typeof(CSharp.PagesAttribute), false); if (null != xamlFileAttributes && xamlFileAttributes.Length > 0) { var sourceField = field.GetValue(moduleToBuild); if (sourceField is Bam.Core.Location) { var file = sourceField as Bam.Core.Location; var absolutePath = file.GetSinglePath(); if (!System.IO.File.Exists(absolutePath)) { throw new Bam.Core.Exception("Page file '{0}' does not exist", absolutePath); } lock (projectData.Pages) { if (!projectData.Pages.Contains(absolutePath)) { projectData.Pages.Add(new ProjectFile(absolutePath)); } } } else if (sourceField is Bam.Core.FileCollection) { var sourceCollection = sourceField as Bam.Core.FileCollection; // TODO: convert to var foreach (string absolutePath in sourceCollection) { if (!System.IO.File.Exists(absolutePath)) { throw new Bam.Core.Exception("Page file '{0}' does not exist", absolutePath); } var csPath = absolutePath + ".cs"; if (!System.IO.File.Exists(csPath)) { throw new Bam.Core.Exception("Associated source file '{0}' to page file '{1}' does not exist", csPath, absolutePath); } lock (projectData.Pages) { if (!projectData.Pages.Contains(absolutePath)) { projectData.Pages.Add(new ProjectFile(absolutePath)); } } } } else { throw new Bam.Core.Exception("Field '{0}' of '{1}' should be of type Bam.Core.File or Bam.Core.FileCollection, not '{2}'", field.Name, node.ModuleName, sourceField.GetType().ToString()); } } } } configuration.Type = EProjectConfigurationType.Application; var toolName = "VCSCompiler"; var vcsCompiler = configuration.GetTool(toolName); if (null == vcsCompiler) { vcsCompiler = new ProjectTool(toolName); configuration.AddToolIfMissing(vcsCompiler); configuration.OutputDirectory = moduleToBuild.Locations[CSharp.Assembly.OutputDir]; if (options is VisualStudioProcessor.IVisualStudioSupport) { var visualStudioProjectOption = options as VisualStudioProcessor.IVisualStudioSupport; var settingsDictionary = visualStudioProjectOption.ToVisualStudioProjectAttributes(target); foreach (var setting in settingsDictionary) { vcsCompiler[setting.Key] = setting.Value; } } else { throw new Bam.Core.Exception("Assembly options does not support VisualStudio project translation"); } } success = true; return projectData; }
public object Build( XmlUtilities.XmlModule moduleToBuild, out bool success) { var node = moduleToBuild.OwningNode; var targetNode = node.ExternalDependents[0]; var toProject = targetNode.Data as IProject; var configCollection = toProject.Configurations; var configurationName = configCollection.GetConfigurationNameForTarget((Bam.Core.BaseTarget)targetNode.Target); // TODO: not accurate var configuration = configCollection[configurationName]; var toolName = "VCPreBuildEventTool"; var vcPreBuildEventTool = configuration.GetTool(toolName); if (null == vcPreBuildEventTool) { vcPreBuildEventTool = new ProjectTool(toolName); configuration.AddToolIfMissing(vcPreBuildEventTool); } var commandLine = new System.Text.StringBuilder(); var locationMap = moduleToBuild.Locations; var outputDir = locationMap[XmlUtilities.XmlModule.OutputDir]; var outputDirPath = outputDir.GetSingleRawPath(); commandLine.AppendFormat("IF NOT EXIST {0} MKDIR {0}{1}", outputDirPath, System.Environment.NewLine); var outputFileLoc = locationMap[XmlUtilities.XmlModule.OutputFile]; var outputFilePath = outputFileLoc.GetSingleRawPath(); var content = XmlUtilities.XmlDocumentToStringBuilder.Write(moduleToBuild.Document); foreach (var line in content.ToString().Split('\n')) { commandLine.AppendFormat("ECHO {0} >> {1}{2}", line, outputFilePath, System.Environment.NewLine); } { string attributeName = null; if (VisualStudioProcessor.EVisualStudioTarget.VCPROJ == toProject.VSTarget) { attributeName = "CommandLine"; } else if (VisualStudioProcessor.EVisualStudioTarget.MSBUILD == toProject.VSTarget) { attributeName = "Command"; } lock (vcPreBuildEventTool) { if (vcPreBuildEventTool.HasAttribute(attributeName)) { var currentValue = vcPreBuildEventTool[attributeName]; currentValue += commandLine.ToString(); vcPreBuildEventTool[attributeName] = currentValue; } else { vcPreBuildEventTool.AddAttribute(attributeName, commandLine.ToString()); } } } success = true; return null; }
public void ReTransmogrifyProjectsToNugetPackages(SolutionTool solutionTool, FolderTool folderTool) { var projectsToRemove = folderTool.GetProjects(); var solutionProjectItems = solutionTool.GetProjectsWithParents().ToArray(); var solutionProjectsToRemove = solutionProjectItems.Where(p => projectsToRemove.Any(p2 => p2.Name == p.Name)).ToArray(); var possibleParentsToKill = new List <SolutionProjectItem>(); foreach (var solutionProjectToRemove in solutionProjectsToRemove) { if (solutionProjectToRemove.ParentId != Guid.Empty) { var parentProject = solutionProjectItems.Single(p => p.Id == solutionProjectToRemove.ParentId); if (!possibleParentsToKill.Contains(parentProject)) { possibleParentsToKill.Add(parentProject); } } _logger.LogInformation($"Remove {solutionProjectToRemove.Name}"); _logger.LogProgress(); } var dependentProjects = solutionProjectItems.Where(p => solutionProjectsToRemove.All(p2 => p2.Name != p.Name) && (p.Type == SolutionTool.ProjectTypeIdClassLibrary || p.Type == SolutionTool.ProjectTypeIdWebProject)); foreach (var dependentProject in dependentProjects) { var projectPath = System.IO.Path.Combine(solutionTool.FolderPath, dependentProject.Path); var projectTool = new ProjectTool(projectPath, _logger); var projectReferences = projectTool.GetProjectReferences().ToArray(); var packageReferences = projectTool.GetPackageReferences().ToArray(); _logger.LogInformation($"References in project {dependentProject.Name}"); var dependencies = new List <NugetPackage>(); var projectReferencesToRemove = projectReferences.Where(pr => solutionProjectsToRemove.Any(p => p.Name == pr.Name)).ToArray(); foreach (var projectReference in projectReferencesToRemove) { var projectReferencePath = PathExtensions.GetAbsolutePath(projectTool.FolderPath, projectReference.HintPath); var projectReferenceTool = new ProjectTool(projectReferencePath, _logger); var targetFramework = projectReferenceTool.GetTargetFramework(); var nugetPackageTool = NugetPackageTool.GetNugetPackageTool(solutionTool.FolderPath, projectReference.Name, targetFramework); if (nugetPackageTool != null) { var nuspec = nugetPackageTool.GetNuspec(); _logger.LogInformation($"\t{projectReference.Name} - {projectReference.HintPath} - {nuspec.Name} {nuspec.Version}"); foreach (var dependency in nuspec.Dependencies) { if (dependencies.All(a => a.Name != dependency.Name) && packageReferences.All(r => r.Name != dependency.Name) && solutionProjectsToRemove.All(p => p.Name != dependency.Name)) { dependencies.Add(new NugetPackage { Name = dependency.Name, Version = dependency.Version, TargetFramework = targetFramework }); _logger.LogInformation($"\t\tSub Nuget dependency {dependency.Name} {dependency.Version}"); } } _logger.LogProgress(); if (dependencies.All(a => a.Name != nuspec.Name) && packageReferences.All(r => r.Name != nuspec.Name)) { dependencies.Add(new NugetPackage { Name = nuspec.Name, Version = nuspec.Version.ToString(), TargetFramework = targetFramework }); } projectTool.RemoveProjectReference(projectReference); projectTool.AddNugetReference(nuspec.Name, nuspec.Version.ToString(), nugetPackageTool.TargetFrameworkVersion); } else { _logger.LogInformation($"\t{projectReference.Name} - {projectReference.HintPath} - NO NUGET"); } _logger.LogProgress(); } foreach (var dependency in dependencies) { var nugetPackageTool = new NugetPackageTool(solutionTool.FolderPath, dependency.Name, dependency.Version, dependency.TargetFramework); var libReferences = nugetPackageTool.GetLibPaths(); foreach (var libReference in libReferences) { projectTool.AddReference(libReference); _logger.LogProgress(); } _logger.LogProgress(); } projectTool.Save(); } foreach (var solutionProjectToRemove in solutionProjectsToRemove) { solutionTool.RemoveProject(solutionProjectToRemove); _logger.LogProgress(); } solutionTool.Save(); }
public void TransmogrifyNugetPackagesToProjects(SolutionTool solutionTool, FolderTool folderTool) { UpdateSolutionWithFolderTargets(solutionTool, folderTool); var projects = solutionTool.GetProjectsWithParents().ToArray(); var projectsLookup = projects.Where(p => solutionTool.CompilableProjects.Contains(p.Type)).ToDictionary(p => p.Name, p => p); foreach (var project in projects) { if (solutionTool.CompilableProjects.Contains(project.Type)) { var projectPath = PathExtensions.GetAbsolutePath(solutionTool.FolderPath, project.Path); var projectTool = new ProjectTool(projectPath, _logger); if (projectTool.IsCpsDocument) { foreach (var packageReference in projectTool.GetPackageReferences().ToArray()) { if (projectsLookup.ContainsKey(packageReference.Name)) { var matchingProject = projectsLookup[packageReference.Name]; projectTool.RemovePackageReference(packageReference.Name); _logger.LogInformation($"Removed NuGet {packageReference.Name} from {project.Name}"); var absolutePath = PathExtensions.GetAbsolutePath(solutionTool.FolderPath, matchingProject.Path); var relativePath = PathExtensions.MakeRelativePath(projectTool.FolderPath, absolutePath); projectTool.AddProjectReference(matchingProject.Name, relativePath, matchingProject.Id); _logger.LogInformation($"Added ProjectReference {matchingProject.Name} from {relativePath}"); var nugetPackageTool = new NugetPackageTool(solutionTool.FolderPath, packageReference.Name, packageReference.Version, packageReference.TargetFramework); var nuspec = nugetPackageTool.GetNuspec(); foreach (var dependency in nuspec.Dependencies) { if (projectsLookup.ContainsKey(dependency.Name)) { matchingProject = projectsLookup[dependency.Name]; absolutePath = PathExtensions.GetAbsolutePath(solutionTool.FolderPath, matchingProject.Path); relativePath = PathExtensions.MakeRelativePath(projectTool.FolderPath, absolutePath); projectTool.AddProjectReference(matchingProject.Name, relativePath, matchingProject.Id); _logger.LogInformation($"Added ProjectReference {matchingProject.Name} from {relativePath} for dependency from nuspec"); } else { projectTool.AddNugetReference(dependency.Name, dependency.Version, null); } _logger.LogProgress(); } } _logger.LogProgress(); } } else { foreach (var reference in projectTool.GetReferences().ToArray()) { if (projectsLookup.ContainsKey(reference.Name)) { var matchingProject = projectsLookup[reference.Name]; var packages = projectTool.GetPackageReferences().ToArray(); var referencePackage = packages.FirstOrDefault(pkg => pkg.Name == reference.Name); if (referencePackage != null) { projectTool.RemovePackageReference(referencePackage.Name); _logger.LogInformation($"Removed NuGet {referencePackage.Name} from packages.config"); projectTool.RemoveReference(reference.Name); _logger.LogInformation($"Removed Reference {reference.Name} from {projectTool.FilePath}"); var absolutePath = PathExtensions.GetAbsolutePath(solutionTool.FolderPath, matchingProject.Path); var relativePath = PathExtensions.MakeRelativePath(projectTool.FolderPath, absolutePath); projectTool.AddProjectReference(matchingProject.Name, relativePath, matchingProject.Id); _logger.LogInformation($"Added ProjectReference {matchingProject.Name} from {relativePath}"); var nugetPackageTool = new NugetPackageTool(solutionTool.FolderPath, referencePackage.Name, referencePackage.Version, referencePackage.TargetFramework); var nuspec = nugetPackageTool.GetNuspec(); foreach (var dependency in nuspec.Dependencies) { if (projectsLookup.ContainsKey(dependency.Name)) { matchingProject = projectsLookup[dependency.Name]; absolutePath = PathExtensions.GetAbsolutePath(solutionTool.FolderPath, matchingProject.Path); relativePath = PathExtensions.MakeRelativePath(projectTool.FolderPath, absolutePath); projectTool.AddProjectReference(matchingProject.Name, relativePath, matchingProject.Id); _logger.LogInformation($"Added ProjectReference {matchingProject.Name} from {relativePath} for dependency from nuspec"); } else { var existingReference = packages.FirstOrDefault(pkg => pkg.Name == dependency.Name); if (existingReference == null) { projectTool.AddNugetReference(dependency.Name, dependency.Version, projectTool.GetTargetFramework()); } } _logger.LogProgress(); } } } _logger.LogProgress(); } } projectTool.Save(); } _logger.LogProgress(); } }
/// <inheritdoc/> public override IDock CreateLayout() { // Documents var pageDocument = new PageDocument { Id = nameof(PageDocument), Title = "Page" }; // Tools var projectTool = new ProjectTool { Id = nameof(ProjectTool), Title = "Project" }; var optionsTool = new OptionsTool { Id = nameof(OptionsTool), Title = "Options" }; var imagesTool = new ImagesTool { Id = nameof(ImagesTool), Title = "Images" }; var groupsTool = new GroupsTool { Id = nameof(GroupsTool), Title = "Groups" }; var databasesTool = new DatabasesTool { Id = nameof(DatabasesTool), Title = "Databases" }; var scriptTool = new ScriptTool { Id = nameof(ScriptTool), Title = "Script" }; var browserTool = new BrowserTool { Id = nameof(BrowserTool), Title = "Browser" }; var stylesTool = new StylesTool { Id = nameof(StylesTool), Title = "Styles" }; var templatesTool = new TemplatesTool { Id = nameof(TemplatesTool), Title = "Templates" }; var containerTool = new ContainerTool { Id = nameof(ContainerTool), Title = "Container" }; var zoomTool = new ZoomTool { Id = nameof(ZoomTool), Title = "Zoom" }; var shapeTool = new ShapeTool { Id = nameof(ShapeTool), Title = "Shape" }; var toolsTool = new ToolsTool { Id = nameof(ToolsTool), Title = "Tools" }; var dataTool = new DataTool { Id = nameof(DataTool), Title = "Data" }; var styleTool = new StyleTool { Id = nameof(StyleTool), Title = "Style" }; var templateTool = new TemplateTool { Id = nameof(TemplateTool), Title = "Template" }; // Panes var leftPane = new LayoutDock { Id = nameof(ILayoutDock), Title = "EditorLeft", Orientation = Orientation.Vertical, Proportion = 0.17, CurrentView = null, Views = new ObservableCollection <IView> { new ToolDock { Id = nameof(IToolDock), Title = "EditorLeftTop", Proportion = double.NaN, CurrentView = projectTool, Views = new ObservableCollection <IView> { projectTool, optionsTool, imagesTool } }, new SplitterDock() { Id = nameof(ISplitterDock), Title = "LeftTopSplitter" }, new ToolDock { Id = nameof(IToolDock), Title = "EditorLeftBottom", Proportion = double.NaN, CurrentView = groupsTool, Views = new ObservableCollection <IView> { groupsTool, databasesTool, scriptTool, browserTool } } } }; var rightPane = new LayoutDock { Id = nameof(ILayoutDock), Title = "EditorRight", Orientation = Orientation.Vertical, Proportion = 0.17, CurrentView = null, Views = new ObservableCollection <IView> { new ToolDock { Id = nameof(IToolDock), Title = "EditorRightTop", Proportion = double.NaN, CurrentView = stylesTool, Views = new ObservableCollection <IView> { stylesTool, templatesTool, containerTool, zoomTool } }, new SplitterDock() { Id = nameof(ISplitterDock), Title = "RightTopSplitter" }, new ToolDock { Id = nameof(IToolDock), Title = "EditorRightBottom", Proportion = double.NaN, CurrentView = shapeTool, Views = new ObservableCollection <IView> { shapeTool, toolsTool, dataTool, styleTool, templateTool } } } }; var documentsPane = new DocumentDock { Id = nameof(IDocumentDock), Title = "DocumentsPane", Proportion = double.NaN, CurrentView = pageDocument, Views = new ObservableCollection <IView> { pageDocument } }; // Editor var editorLayout = new LayoutDock { Id = nameof(ILayoutDock), Title = "EditorLayout", Orientation = Orientation.Horizontal, Proportion = double.NaN, CurrentView = null, Views = new ObservableCollection <IView> { leftPane, new SplitterDock() { Id = nameof(ISplitterDock), Title = "LeftSplitter" }, documentsPane, new SplitterDock() { Id = nameof(ISplitterDock), Title = "RightSplitter" }, rightPane } }; // Views var editorView = new EditorView { Id = nameof(EditorView), Title = "Editor", CurrentView = editorLayout, Views = new ObservableCollection <IView> { editorLayout } }; var aboutView = new AboutView { Id = nameof(AboutView), Title = "About" }; var browserView = new BrowserView { Id = nameof(BrowserView), Title = "Browser" }; var scriptView = new ScriptView { Id = nameof(ScriptView), Title = "Script" }; var documentView = new DocumentView { Id = nameof(DocumentView), Title = "Document" }; var dashboardView = new DashboardView { Id = nameof(DashboardView), Title = "Dashboard" }; // Root var layout = new RootDock { Id = nameof(IRootDock), Title = "Root", CurrentView = dashboardView, DefaultView = dashboardView, Views = new ObservableCollection <IView> { dashboardView, editorView, aboutView, browserView, scriptView, documentView } }; return(layout); }
/// <inheritdoc/> public override IDock CreateLayout() { // Documents var pageDocument = new PageDocument { Id = nameof(PageDocument), Width = double.NaN, Height = double.NaN, Title = "Page" }; // Left / Top var projectView = new ProjectTool { Id = nameof(ProjectTool), Width = double.NaN, Height = double.NaN, Title = "Project" }; var optionsView = new OptionsTool { Id = nameof(OptionsTool), Width = 200, Height = 200, Title = "Options" }; var imagesView = new ImagesTool { Id = nameof(ImagesTool), Width = double.NaN, Height = double.NaN, Title = "Images" }; // Left / Bottom var groupsView = new GroupsTool { Id = nameof(GroupsTool), Width = double.NaN, Height = double.NaN, Title = "Groups" }; var databasesView = new DatabasesTool { Id = nameof(DatabasesTool), Width = double.NaN, Height = double.NaN, Title = "Databases" }; // Right / Top var stylesView = new StylesTool { Id = nameof(StylesTool), Width = double.NaN, Height = double.NaN, Title = "Styles" }; var templatesView = new TemplatesTool { Id = nameof(TemplatesTool), Width = double.NaN, Height = double.NaN, Title = "Templates" }; var containerView = new ContainerTool { Id = nameof(ContainerTool), Width = double.NaN, Height = double.NaN, Title = "Container" }; var zoomView = new ZoomTool { Id = nameof(ZoomTool), Width = double.NaN, Height = double.NaN, Title = "Zoom" }; // Right / Bottom var toolsView = new ToolsTool { Id = nameof(ToolsTool), Width = double.NaN, Height = double.NaN, Title = "Tools" }; var shapeView = new ShapeTool { Id = nameof(ShapeTool), Width = double.NaN, Height = double.NaN, Title = "Shape" }; var dataView = new DataTool { Id = nameof(DataTool), Width = double.NaN, Height = double.NaN, Title = "Data" }; var styleView = new StyleTool { Id = nameof(StyleTool), Width = double.NaN, Height = double.NaN, Title = "Style" }; var templateView = new TemplateTool { Id = nameof(TemplateTool), Width = double.NaN, Height = double.NaN, Title = "Template" }; // Left Pane var leftPane = new LayoutDock { Id = nameof(ILayoutDock), Dock = "Left", Width = 200, Height = double.NaN, Title = "EditorLeft", CurrentView = null, Views = new ObservableCollection <IView> { new ToolDock { Id = nameof(IToolDock), Dock = "Top", Width = double.NaN, Height = 340, Title = "EditorLeftTop", CurrentView = projectView, Views = new ObservableCollection <IView> { projectView, optionsView, imagesView } }, new SplitterDock() { Id = nameof(ISplitterDock), Dock = "Top", Title = "LeftTopSplitter" }, new ToolDock { Id = nameof(IToolDock), Dock = "Bottom", Width = double.NaN, Height = double.NaN, Title = "EditorLeftBottom", CurrentView = groupsView, Views = new ObservableCollection <IView> { groupsView, databasesView } } } }; // Right Pane var rightPane = new LayoutDock { Id = nameof(ILayoutDock), Dock = "Right", Width = 240, Height = double.NaN, Title = "EditorRight", CurrentView = null, Views = new ObservableCollection <IView> { new ToolDock { Id = nameof(IToolDock), Dock = "Top", Width = double.NaN, Height = 340, Title = "EditorRightTop", CurrentView = stylesView, Views = new ObservableCollection <IView> { stylesView, templatesView, containerView, zoomView } }, new SplitterDock() { Id = nameof(ISplitterDock), Dock = "Top", Title = "RightTopSplitter" }, new ToolDock { Id = nameof(IToolDock), Dock = "Bottom", Width = double.NaN, Height = double.NaN, Title = "EditorRightBottom", CurrentView = toolsView, Views = new ObservableCollection <IView> { toolsView, shapeView, dataView, styleView, templateView } } } }; // Documents var documentsPane = new DocumentDock { Id = nameof(IDocumentDock), Dock = "", Width = double.NaN, Height = double.NaN, Title = "DocumentsPane", CurrentView = pageDocument, Views = new ObservableCollection <IView> { pageDocument } }; // Main var editorLayout = new LayoutDock { Id = nameof(ILayoutDock), Dock = "", Width = double.NaN, Height = double.NaN, Title = "EditorLayout", CurrentView = null, Views = new ObservableCollection <IView> { leftPane, new SplitterDock() { Id = nameof(ISplitterDock), Dock = "Left", Title = "LeftSplitter" }, rightPane, new SplitterDock() { Id = nameof(ISplitterDock), Dock = "Right", Title = "RightSplitter" }, documentsPane } }; var editorView = new EditorView { Id = nameof(EditorView), Width = double.NaN, Height = double.NaN, Title = "Editor", CurrentView = editorLayout, Views = new ObservableCollection <IView> { editorLayout } }; // About var aboutView = new AboutView { Id = nameof(AboutView), Width = double.NaN, Height = double.NaN, Title = "About" }; // Browser var browserView = new BrowserView { Id = nameof(BrowserView), Width = double.NaN, Height = double.NaN, Title = "Browser" }; // Document var documentView = new DocumentView { Id = nameof(DocumentView), Width = double.NaN, Height = double.NaN, Title = "Document" }; // Dashboard var dashboardView = new DashboardView { Id = nameof(DashboardView), Width = double.NaN, Height = double.NaN, Title = "Dashboard" }; // Main var layout = new RootDock { Id = nameof(IRootDock), Width = double.NaN, Height = double.NaN, Title = "Root", CurrentView = dashboardView, DefaultView = dashboardView, Views = new ObservableCollection <IView> { dashboardView, editorView, aboutView, browserView, documentView } }; return(layout); }
/// <inheritdoc/> public override DM.IDock CreateLayout() { // Documents var pageDocument = new PageDocument { Id = nameof(PageDocument), Title = "Page" }; // Tools var projectTool = new ProjectTool { Id = nameof(ProjectTool), Title = "Project" }; var optionsTool = new OptionsTool { Id = nameof(OptionsTool), Title = "Options" }; var imagesTool = new ImagesTool { Id = nameof(ImagesTool), Title = "Images" }; var groupsTool = new GroupsTool { Id = nameof(GroupsTool), Title = "Groups" }; var databasesTool = new DatabasesTool { Id = nameof(DatabasesTool), Title = "Databases" }; var scriptTool = new ScriptTool { Id = nameof(ScriptTool), Title = "Script" }; var exportTool = new ExportTool { Id = nameof(ExportTool), Title = "Export" }; var browserTool = new BrowserTool { Id = nameof(BrowserTool), Title = "Browser" }; var documentTool = new DocumentTool { Id = nameof(DocumentTool), Title = "Document" }; var stylesTool = new StylesTool { Id = nameof(StylesTool), Title = "Styles" }; var templatesTool = new TemplatesTool { Id = nameof(TemplatesTool), Title = "Templates" }; var scriptsTool = new ScriptsTool { Id = nameof(ScriptsTool), Title = "Scripts" }; var containerTool = new ContainerTool { Id = nameof(ContainerTool), Title = "Container" }; var zoomTool = new ZoomTool { Id = nameof(ZoomTool), Title = "Zoom" }; var rendererTool = new RendererTool { Id = nameof(RendererTool), Title = "Renderer" }; var shapeTool = new ShapeTool { Id = nameof(ShapeTool), Title = "Shape" }; var toolsTool = new ToolsTool { Id = nameof(ToolsTool), Title = "Tools" }; var recordTool = new RecordTool { Id = nameof(RecordTool), Title = "Record" }; var propertiesTool = new PropertiesTool { Id = nameof(PropertiesTool), Title = "Properties" }; var styleTool = new StyleTool { Id = nameof(StyleTool), Title = "Style" }; var templateTool = new TemplateTool { Id = nameof(TemplateTool), Title = "Template" }; // Panes var leftPane = new DMC.ProportionalDock { Id = nameof(DMC.IProportionalDock), Title = "EditorLeft", Orientation = DM.Orientation.Vertical, Proportion = 0.17, ActiveDockable = null, VisibleDockables = CreateList <DM.IDockable> ( new DMC.ToolDock { Id = nameof(DMC.IToolDock), Title = "EditorLeftTop", Proportion = double.NaN, ActiveDockable = projectTool, VisibleDockables = CreateList <DM.IDockable> ( projectTool, optionsTool, rendererTool, imagesTool ) }, new DMC.SplitterDock() { Id = nameof(DMC.ISplitterDock), Title = "LeftTopSplitter" }, new DMC.ToolDock { Id = nameof(DMC.IToolDock), Title = "EditorLeftBottom", Proportion = double.NaN, ActiveDockable = groupsTool, VisibleDockables = CreateList <DM.IDockable> ( groupsTool, databasesTool, toolsTool, scriptsTool ) } ) }; var rightPane = new DMC.ProportionalDock { Id = nameof(DMC.IProportionalDock), Title = "EditorRight", Orientation = DM.Orientation.Vertical, Proportion = 0.20, ActiveDockable = null, VisibleDockables = CreateList <DM.IDockable> ( new DMC.ToolDock { Id = nameof(DMC.IToolDock), Title = "EditorRightTop", Proportion = double.NaN, ActiveDockable = stylesTool, VisibleDockables = CreateList <DM.IDockable> ( stylesTool, containerTool, templatesTool, templateTool ) }, new DMC.SplitterDock() { Id = nameof(DMC.ISplitterDock), Title = "RightTopSplitter" }, new DMC.ToolDock { Id = nameof(DMC.IToolDock), Title = "EditorRightBottom", Proportion = double.NaN, ActiveDockable = shapeTool, VisibleDockables = CreateList <DM.IDockable> ( shapeTool, propertiesTool, recordTool, styleTool, zoomTool ) } ) }; var documentsPane = new DMC.DocumentDock { Id = nameof(DMC.IDocumentDock), Title = "DocumentsPane", IsCollapsable = false, Proportion = double.NaN, ActiveDockable = pageDocument, VisibleDockables = CreateList <DM.IDockable> ( pageDocument, documentTool, scriptTool, exportTool, browserTool ) }; // Editor var editorLayout = new DMC.ProportionalDock { Id = nameof(DMC.IProportionalDock), Title = "EditorLayout", Orientation = DM.Orientation.Horizontal, Proportion = double.NaN, ActiveDockable = null, VisibleDockables = CreateList <DM.IDockable> ( leftPane, new DMC.SplitterDock() { Id = nameof(DMC.ISplitterDock), Title = "LeftSplitter" }, documentsPane, new DMC.SplitterDock() { Id = nameof(DMC.ISplitterDock), Title = "RightSplitter" }, rightPane ) }; // Views var dashboardView = new DashboardView { Id = nameof(DashboardView), Title = "Dashboard" }; var editorView = new EditorView { Id = nameof(EditorView), Title = "Editor", ActiveDockable = editorLayout, VisibleDockables = CreateList <DM.IDockable> ( editorLayout ) }; // Root var root = new DMC.RootDock { Id = nameof(DMC.IRootDock), Title = "Root", IsCollapsable = false, ActiveDockable = dashboardView, DefaultDockable = dashboardView, VisibleDockables = CreateList <DM.IDockable> ( dashboardView, editorView ) }; root.Top = CreatePinDock(); root.Top.Alignment = DM.Alignment.Top; root.Bottom = CreatePinDock(); root.Bottom.Alignment = DM.Alignment.Bottom; root.Left = CreatePinDock(); root.Left.Alignment = DM.Alignment.Left; root.Right = CreatePinDock(); root.Right.Alignment = DM.Alignment.Right; return(root); }
Build( XmlUtilities.TextFileModule moduleToBuild, out bool success) { var node = moduleToBuild.OwningNode; var targetNode = node.ExternalDependents[0]; var toProject = targetNode.Data as IProject; var configCollection = toProject.Configurations; var configurationName = configCollection.GetConfigurationNameForTarget((Bam.Core.BaseTarget)targetNode.Target); // TODO: not accurate var configuration = configCollection[configurationName]; var toolName = "VCPreBuildEventTool"; var vcPreBuildEventTool = configuration.GetTool(toolName); if (null == vcPreBuildEventTool) { vcPreBuildEventTool = new ProjectTool(toolName); configuration.AddToolIfMissing(vcPreBuildEventTool); } var commandLine = new System.Text.StringBuilder(); var locationMap = moduleToBuild.Locations; var outputDir = locationMap[XmlUtilities.TextFileModule.OutputDir]; var outputDirPath = outputDir.GetSingleRawPath(); commandLine.AppendFormat("IF NOT EXIST {0} MKDIR {0}{1}", outputDirPath, System.Environment.NewLine); var outputFileLoc = locationMap[XmlUtilities.TextFileModule.OutputFile]; var outputFilePath = outputFileLoc.GetSingleRawPath(); foreach (var line in moduleToBuild.Content.ToString().Split('\n')) { commandLine.AppendFormat("ECHO {0} >> {1}{2}", line, outputFilePath, System.Environment.NewLine); } { string attributeName = null; if (VisualStudioProcessor.EVisualStudioTarget.VCPROJ == toProject.VSTarget) { attributeName = "CommandLine"; } else if (VisualStudioProcessor.EVisualStudioTarget.MSBUILD == toProject.VSTarget) { attributeName = "Command"; } lock (vcPreBuildEventTool) { if (vcPreBuildEventTool.HasAttribute(attributeName)) { var currentValue = vcPreBuildEventTool[attributeName]; currentValue += commandLine.ToString(); vcPreBuildEventTool[attributeName] = currentValue; } else { vcPreBuildEventTool.AddAttribute(attributeName, commandLine.ToString()); } } } success = true; return(null); }
public void SetUp() { _clientMock = TestHelper.SetUpMockClient(); _fakeTool = new ProjectTool(_clientMock.Object, TestHelper.RealOrganization, TestHelper.RealProject); }