/// <summary> /// Builds the Destination folder path based upon the settings in the config file for Visual Studio Projects /// </summary> /// <param name="project"></param> /// <returns></returns> private AbsolutePath BuildDestinationFolderLayout_VS(SlugCIProject project, string framework) { string versionFolder = ""; if (CISession.SlugCIConfigObj.DeployToVersionedFolder) { if (CISession.SlugCIConfigObj.DeployFolderUsesSemVer) { versionFolder = CISession.VersionInfo.SemVersionAsString; } else { versionFolder = CISession.VersionInfo.SemVersion.Major.ToString() + "." + CISession.VersionInfo.SemVersion.Minor.ToString() + "." + CISession.VersionInfo.SemVersion.Patch.ToString(); } } versionFolder = "Ver" + versionFolder; string projFolder = project.Name; // Now calculate main project folder name if (CISession.SlugCIConfigObj.DeployToAssemblyFolders) { string assemblyName = project.AssemblyName; projFolder = assemblyName.Replace('.', '\\'); } // Build Path AbsolutePath destFolder = CISession.DeployCopyPath / projFolder / framework / versionFolder; return(destFolder); }
/// <summary> /// Adds a SlugCIProject that is based upon a Visual Studio Project /// </summary> /// <param name="vsProject"></param> private SlugCIProject AddSlugCIProject(SlugCIConfig slugCIConfig, VisualStudioProject vsProject) { SlugCIProject slugCIProject = new SlugCIProject() { Name = vsProject.Name }; slugCIProject.IsTestProject = vsProject.IsTestProject; if (vsProject.IsTestProject) { slugCIProject.Deploy = SlugCIDeployMethod.None; // Also add the Required Nuget Coverage package CoverletInstall(vsProject); } else { slugCIProject.Deploy = vsProject.SlugCIDeploymentMethod; } slugCIConfig.Projects.Add(slugCIProject); return(slugCIProject); }
/// <summary> /// Constructor /// </summary> public PublishResultRecord(SlugCIProject project) { NameOfProject = project.Name; DeployMethod = project.Deploy; }
/// <summary> /// Ensures there is a valid SlugCI Config file and updates it if necessary OR creates it. /// </summary> /// <returns></returns> private bool ProcessSlugCIConfigFile() { SlugCIConfig slugCiConfig = SlugCIConfig; if (slugCiConfig == null) { EnsureExistingDirectory(CISession.SlugCIPath); slugCiConfig = new SlugCIConfig(); slugCiConfig.DeployToVersionedFolder = true; } // Make a copy that we will compare against. SlugCIConfig origSlugCiConfig = slugCiConfig.Copy(); // Ensure the version of the config file layout is set to most current. We do this after the copy, so we can // detect changes in the file layout, fields, etc. slugCiConfig.ConfigStructureVersion = SlugCIConfig.CONFIG_STRUCTURE_VERSION; bool updateProjectAdd = false; bool hasCopyDeployMethod = false; // Now go thru the Visual Studio Projects and update the config foreach (VisualStudioProject project in Projects) { SlugCIProject slugCIProject = slugCiConfig.GetProjectByName(project.Name); // New Visual Studio project that does not exist in SlugCIConfig if (slugCIProject == null) { slugCIProject = AddSlugCIProject(slugCiConfig, project); } if (slugCIProject.Deploy == SlugCIDeployMethod.Copy) { hasCopyDeployMethod = true; } } // Ensure Deploy Roots have values if at least one of the projects has a deploy method of Copy if (hasCopyDeployMethod) { foreach (PublishTargetEnum value in Enum.GetValues(typeof(PublishTargetEnum))) { ValidateDeployFolders(value, slugCiConfig); } } // Add Angular Projects ProcessAngularProjects(slugCiConfig); // Determine if we need to save new config. if (origSlugCiConfig != slugCiConfig) { string json = JsonSerializer.Serialize <SlugCIConfig>(slugCiConfig, SlugCIConfig.SerializerOptions()); File.WriteAllText(CISession.SlugCIFileName, json); AOT_Success("SlugCIConfig file updated to latest version / values"); SlugCIConfig = GetSlugCIConfig(true); if (updateProjectAdd) { Logger.Warn("The file: {0} was updated. One ore more projects were added. Ensure they have the correct Deploy setting.", CISession.SlugCIFileName); } } return(true); }
/// <summary> /// Either upgrades a current config or converts an existing solution into SlugCI format /// </summary> /// <returns></returns> public bool Converter() { // Create src folder if it does not exist. if (!DirectoryExists(CISession.SourceDirectory)) { Directory.CreateDirectory(CISession.SourceDirectory.ToString()); } // Create Tests folder if it does not exist. if (!DirectoryExists(CISession.TestsDirectory)) { Directory.CreateDirectory(CISession.TestsDirectory.ToString()); } // Create Artifacts / Output folder if it does not exist. if (!DirectoryExists(CISession.OutputDirectory)) { Directory.CreateDirectory(CISession.OutputDirectory.ToString()); } // Load an existing SlugCI file if there is one. SlugCIConfig = GetSlugCIConfig(); // Load our own version of the Visual Studio project, so we can process some info from it foreach (Project project in CISession.Solution.AllProjects) { VisualStudioProject vsProject = GetInitProject(project); Projects.Add(vsProject); } // If New to SlugCI if (SlugCIConfig == null) { // Determine if any of these are a test project... If so we confirm with user and then move. foreach (VisualStudioProject visualStudioProject in Projects) { GetVisualStudioProjectInfoForNewProjectFromUser(visualStudioProject); } bool setupSuccess = SlugCI_NewSetup_EnsureProperDirectoryStructure(CISession.SolutionFileName); ControlFlow.Assert(setupSuccess, "Attempted to put solution in proper directory structure, but failed."); } else { // See if any new Projects, if so prompt for required info foreach (VisualStudioProject visualStudioProject in Projects) { SlugCIProject slugCIProject = CISession.SlugCIConfigObj.GetProjectByName(visualStudioProject.Name); if (slugCIProject == null) { GetVisualStudioProjectInfoForNewProjectFromUser(visualStudioProject); } } } // Ensure Config file is valid and up-to-date with current Class Structure ProcessSlugCIConfigFile(); return(true); }