private SlnProject CreateAndValidateProject(bool isMainProject = false, string expectedGuid = null, string expectedName = null, string extension = ".csproj", IDictionary <string, string> globalProperties = null) { Project expectedProject = CreateProject(expectedGuid, expectedName, extension, globalProperties); SlnProject actualProject = SlnProject.FromProject(expectedProject, new Dictionary <string, string>(), isMainProject); actualProject.FullPath.ShouldBe(expectedProject.FullPath); if (!String.IsNullOrWhiteSpace(expectedName)) { actualProject.Name.ShouldBe(expectedName); } if (!String.IsNullOrWhiteSpace(extension)) { actualProject.ProjectTypeGuid.ShouldBe(SlnProject.KnownProjectTypeGuids.ContainsKey(extension) ? SlnProject.KnownProjectTypeGuids[extension] : SlnProject.DefaultProjectTypeGuid); } if (expectedGuid != null) { actualProject.ProjectGuid.ShouldBe(expectedGuid); } actualProject.IsMainProject.ShouldBe(isMainProject); return(actualProject); }
private void GenerateSolutionFile(ICollection <Project> projects) { if (String.IsNullOrWhiteSpace(SolutionFileFullPath)) { SolutionFileFullPath = Path.ChangeExtension(ProjectFullPath, ".sln"); } Dictionary <string, Guid> customProjectTypeGuids = ParseCustomProjectTypeGuids(); LogMessageHigh($"Generating Visual Studio solution \"{SolutionFileFullPath}\" ..."); if (customProjectTypeGuids.Count > 0) { LogMessageLow("Custom Project Type GUIDs:"); foreach (KeyValuePair <string, Guid> item in customProjectTypeGuids) { LogMessageLow(" {0} = {1}", item.Key, item.Value); } } SlnFile solution = new SlnFile(); solution.AddProjects( projects.Where(ShouldIncludeInSolution) .Select(p => SlnProject.FromProject(p, customProjectTypeGuids, p.FullPath == ProjectFullPath))); solution.AddSolutionItems(GetSolutionItems()); solution.Save(SolutionFileFullPath, Folders); }
private SlnProject CreateAndValidateProject(bool isMainProject = false, string expectedGuid = null, string expectedName = null, string extension = ".csproj", IDictionary <string, string> globalProperties = null, string isDeployable = null) { if (!string.IsNullOrWhiteSpace(isDeployable)) { if (globalProperties == null) { globalProperties = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); } globalProperties["SlnGenIsDeployable"] = isDeployable; } Project expectedProject = CreateProject(expectedGuid, expectedName, extension, globalProperties); SlnProject actualProject = SlnProject.FromProject(expectedProject, new Dictionary <string, Guid>(), isMainProject); actualProject.FullPath.ShouldBe(expectedProject.FullPath); if (!string.IsNullOrWhiteSpace(expectedName)) { actualProject.Name.ShouldBe(expectedName); } if (expectedGuid != null) { actualProject.ProjectGuid.ToSolutionString().ShouldBe(expectedGuid); } actualProject.IsMainProject.ShouldBe(isMainProject); return(actualProject); }
public void ConfigurationsAndPlatformsWithGlobalProperties() { Dictionary <string, string> globalProperties = new Dictionary <string, string> { ["Configuration"] = "Mix", ["Platform"] = "x86", }; using (TestProject testProject = TestProject.Create(globalProperties)) { SlnProject slnProject = SlnProject.FromProject(testProject.Project, new Dictionary <string, Guid>(), true); slnProject.Configurations.ShouldBe(new[] { "Debug", "Mix", "Release" }, ignoreOrder: true); slnProject.Platforms.ShouldBe(new[] { "amd64", "Any CPU", "x86", "x64" }, ignoreOrder: true); } }
public void GetPlatformsAndConfigurationsFromCppProject() { Project project = ProjectCreator.Create() .ItemInclude( "ProjectConfiguration", "ConfigA|PlatformA", metadata: new Dictionary <string, string> { ["Configuration"] = "ConfigA", ["Platform"] = "PlatformA", }) .ItemInclude( "ProjectConfiguration", "ConfigA|PlatformB", metadata: new Dictionary <string, string> { ["Configuration"] = "ConfigA", ["Platform"] = "PlatformB", }) .ItemInclude( "ProjectConfiguration", "ConfigB|PlatformA", metadata: new Dictionary <string, string> { ["Configuration"] = "ConfigB", ["Platform"] = "PlatformA", }) .ItemInclude( "ProjectConfiguration", "ConfigB|PlatformB", metadata: new Dictionary <string, string> { ["Configuration"] = "ConfigB", ["Platform"] = "PlatformB", }) .Save(GetTempFileName(".vcxproj")); SlnProject slnProject = SlnProject.FromProject(project, new Dictionary <string, Guid>()); slnProject.Configurations.ShouldBe(new[] { "ConfigA", "ConfigB" }); slnProject.Platforms.ShouldBe(new[] { "PlatformA", "PlatformB" }); }
private SlnProject CreateAndValidateProject(bool isMainProject = false, string expectedGuid = null, string expectedName = null, string extension = ".csproj", IDictionary <string, string> globalProperties = null) { Project expectedProject = CreateProject(expectedGuid, expectedName, extension, globalProperties); SlnProject actualProject = SlnProject.FromProject(expectedProject, new Dictionary <string, Guid>(), isMainProject); actualProject.FullPath.ShouldBe(expectedProject.FullPath); if (!string.IsNullOrWhiteSpace(expectedName)) { actualProject.Name.ShouldBe(expectedName); } if (expectedGuid != null) { actualProject.ProjectGuid.ToSolutionString().ShouldBe(expectedGuid); } actualProject.IsMainProject.ShouldBe(isMainProject); return(actualProject); }