private void ApplyNecessaryChangesToSolution() { try { // Migrate solution from old configuration names to: Debug, ExportDebug and ExportRelease DotNetSolution.MigrateFromOldConfigNames(GodotSharpDirs.ProjectSlnPath); var msbuildProject = ProjectUtils.Open(GodotSharpDirs.ProjectCsProjPath) ?? throw new Exception("Cannot open C# project"); // NOTE: The order in which changes are made to the project is important // Migrate to MSBuild project Sdks style if using the old style ProjectUtils.MigrateToProjectSdksStyle(msbuildProject, ProjectAssemblyName); ProjectUtils.EnsureGodotSdkIsUpToDate(msbuildProject); if (msbuildProject.HasUnsavedChanges) { // Save a copy of the project before replacing it FileUtils.SaveBackupCopy(GodotSharpDirs.ProjectCsProjPath); msbuildProject.Save(); } } catch (Exception e) { GD.PushError(e.ToString()); } }
public static IEnumerable <DotNetSolutionProject> GetDotNetSolutionProjects(FileInfo slnFileInfo) { var dotNetSolution = DotNetSolution.Load(slnFileInfo.FullName); var slnProjects = dotNetSolution.Projects .Where(p => !p.Type.IsSolutionFolder) .OrderBy(p => p.Name); return(slnProjects); }
private bool CreateProjectSolution() { using (var pr = new EditorProgress("create_csharp_solution", "Generating solution...".TTR(), 2)) { pr.Step("Generating C# project...".TTR()); string resourceDir = ProjectSettings.GlobalizePath("res://"); string path = resourceDir; string name = GodotSharpDirs.ProjectAssemblyName; string guid = CsProjOperations.GenerateGameProject(path, name); if (guid.Length > 0) { var solution = new DotNetSolution(name) { DirectoryPath = path }; var projectInfo = new DotNetSolution.ProjectInfo { Guid = guid, PathRelativeToSolution = name + ".csproj", Configs = new List <string> { "Debug", "ExportDebug", "ExportRelease" } }; solution.AddNewProject(name, projectInfo); try { solution.Save(); } catch (IOException e) { ShowErrorDialog("Failed to save solution. Exception message: ".TTR() + e.Message); return(false); } pr.Step("Done".TTR()); // Here, after all calls to progress_task_step CallDeferred(nameof(_RemoveCreateSlnMenuOption)); } else { ShowErrorDialog("Failed to create C# project.".TTR()); } return(true); } }
private Result <DotNetSolution> ReadSolutionFromDisk(string solutionPath) { try { var solution = DotNetSolution.Load(solutionPath); return(Result.Ok(solution)); } catch (Exception e) { _logger.LogError(e); return(Result.Failure <DotNetSolution>("")); } }
public static List<string> GetRelativeProjectPaths(string solutionFilePath) { var paths = new List<string>(); var solution = DotNetSolution.Load(solutionFilePath); if (solution?.Projects?.Any() == true) { paths.AddRange(solution.Projects.Select(s => s.Path)); } return paths; }
public void Learning_ByteDevDotNet_SolutionParsing_Test1() { var settings = new TestParserSettings(); var solutionFile = @"TestFiles\\MerlinTransformSolution.txt"; var solutionPath = Path.GetDirectoryName(Path.GetFullPath(solutionFile)) ?? throw new NullReferenceException(@"Path.GetDirectoryName(Path.GetFullPath(solutionFile)) result is null"); var solution = DotNetSolution.Load(solutionFile); foreach (var solutionProject in solution.Projects) { var projectFile = Path.Combine(solutionPath, solutionProject.Path); TestContext.WriteLine("Project: {0}", projectFile); if (projectFile.EndsWith(settings.ProjectFileExtension, StringComparison.OrdinalIgnoreCase)) { var project = DotNetProject.Load(projectFile); TestContext.WriteLine("Project References:"); foreach (var reference in project.References) { TestContext.WriteLine(" {0}", reference.ToString()); } TestContext.WriteLine("Project Targets:"); foreach (var target in project.ProjectTargets) { TestContext.WriteLine(" {0}", target.ToString()); } TestContext.WriteLine("Package References:"); foreach (var package in project.PackageReferences) { TestContext.WriteLine(" {0}", package.ToString()); } TestContext.WriteLine("Project References:"); foreach (var projectReference in project.ProjectReferences) { TestContext.WriteLine(" {0}", projectReference.ToString()); } } } }
public static Dictionary<string, string> GetRelativeProjectFileNamePathMappings(string solutionFilePath) { var namePathMappings = new Dictionary<string, string>(); var solution = DotNetSolution.Load(solutionFilePath); if (solution != null) { foreach (var project in solution.Projects) { namePathMappings[project.Name] = project.Path; } } return namePathMappings; }
public static List<string> GetAbsoluteProjectPaths(string solutionFilePath) { var paths = new List<string>(); var parentDir = Path.GetDirectoryName(solutionFilePath); var solution = DotNetSolution.Load(solutionFilePath); if (solution?.Projects?.Any() == true) { // These paths are relative to the solution file, which isn't necessarily in the same directory as our git repo . . . // So let's just make the paths absolute. paths.AddRange(solution.Projects.OrderBy(p => p.Name).Select(s => Path.Join(parentDir, s.Path))); } return paths; }
public override void EnablePlugin() { base.EnablePlugin(); if (Instance != null) { throw new InvalidOperationException(); } Instance = this; var editorInterface = GetEditorInterface(); var editorBaseControl = editorInterface.GetBaseControl(); editorSettings = editorInterface.GetEditorSettings(); errorDialog = new AcceptDialog(); editorBaseControl.AddChild(errorDialog); BottomPanel = new BottomPanel(); bottomPanelBtn = AddControlToBottomPanel(BottomPanel, "Mono".TTR()); AddChild(new HotReloadAssemblyWatcher { Name = "HotReloadAssemblyWatcher" }); menuPopup = new PopupMenu(); menuPopup.Hide(); AddToolSubmenuItem("Mono", menuPopup); // TODO: Remove or edit this info dialog once Mono support is no longer in alpha { menuPopup.AddItem("About C# support".TTR(), (int)MenuOptions.AboutCSharp); aboutDialog = new AcceptDialog(); editorBaseControl.AddChild(aboutDialog); aboutDialog.Title = "Important: C# support is not feature-complete"; // We don't use DialogText as the default AcceptDialog Label doesn't play well with the TextureRect and CheckBox // we'll add. Instead we add containers and a new autowrapped Label inside. // Main VBoxContainer (icon + label on top, checkbox at bottom) var aboutVBox = new VBoxContainer(); aboutDialog.AddChild(aboutVBox); // HBoxContainer for icon + label var aboutHBox = new HBoxContainer(); aboutVBox.AddChild(aboutHBox); var aboutIcon = new TextureRect(); aboutIcon.Texture = aboutIcon.GetThemeIcon("NodeWarning", "EditorIcons"); aboutHBox.AddChild(aboutIcon); var aboutLabel = new Label(); aboutHBox.AddChild(aboutLabel); aboutLabel.RectMinSize = new Vector2(600, 150) * EditorScale; aboutLabel.SizeFlagsVertical = (int)Control.SizeFlags.ExpandFill; aboutLabel.Autowrap = true; aboutLabel.Text = "C# support in Godot Engine is in late alpha stage and, while already usable, " + "it is not meant for use in production.\n\n" + "Projects can be exported to Linux, macOS, Windows and Android, but not yet to iOS, HTML5 or UWP. " + "Bugs and usability issues will be addressed gradually over future releases, " + "potentially including compatibility breaking changes as new features are implemented for a better overall C# experience.\n\n" + "If you experience issues with this Mono build, please report them on Godot's issue tracker with details about your system, MSBuild version, IDE, etc.:\n\n" + " https://github.com/godotengine/godot/issues\n\n" + "Your critical feedback at this stage will play a great role in shaping the C# support in future releases, so thank you!"; EditorDef("mono/editor/show_info_on_start", true); // CheckBox in main container aboutDialogCheckBox = new CheckBox { Text = "Show this warning when starting the editor" }; aboutDialogCheckBox.Toggled += enabled => { bool showOnStart = (bool)editorSettings.GetSetting("mono/editor/show_info_on_start"); if (showOnStart != enabled) { editorSettings.SetSetting("mono/editor/show_info_on_start", enabled); } }; aboutVBox.AddChild(aboutDialogCheckBox); } if (File.Exists(GodotSharpDirs.ProjectSlnPath) && File.Exists(GodotSharpDirs.ProjectCsProjPath)) { try { // Migrate solution from old configuration names to: Debug, ExportDebug and ExportRelease DotNetSolution.MigrateFromOldConfigNames(GodotSharpDirs.ProjectSlnPath); // Migrate csproj from old configuration names to: Debug, ExportDebug and ExportRelease ProjectUtils.MigrateFromOldConfigNames(GodotSharpDirs.ProjectCsProjPath); // Apply the other fixes after configurations are migrated // Make sure the existing project has Api assembly references configured correctly ProjectUtils.FixApiHintPath(GodotSharpDirs.ProjectCsProjPath); } catch (Exception e) { GD.PushError(e.ToString()); } } else { bottomPanelBtn.Hide(); menuPopup.AddItem("Create C# solution".TTR(), (int)MenuOptions.CreateSln); } menuPopup.IdPressed += _MenuOptionPressed; var buildButton = new ToolButton { Text = "Build", HintTooltip = "Build solution", FocusMode = Control.FocusModeEnum.None }; buildButton.PressedSignal += _BuildSolutionPressed; AddControlToContainer(CustomControlContainer.Toolbar, buildButton); // External editor settings EditorDef("mono/editor/external_editor", ExternalEditorId.None); string settingsHintStr = "Disabled"; if (OS.IsWindows) { settingsHintStr += $",MonoDevelop:{(int)ExternalEditorId.MonoDevelop}" + $",Visual Studio Code:{(int)ExternalEditorId.VsCode}" + $",JetBrains Rider:{(int)ExternalEditorId.Rider}"; } else if (OS.IsOSX) { settingsHintStr += $",Visual Studio:{(int)ExternalEditorId.VisualStudioForMac}" + $",MonoDevelop:{(int)ExternalEditorId.MonoDevelop}" + $",Visual Studio Code:{(int)ExternalEditorId.VsCode}" + $",JetBrains Rider:{(int)ExternalEditorId.Rider}"; } else if (OS.IsUnixLike()) { settingsHintStr += $",MonoDevelop:{(int)ExternalEditorId.MonoDevelop}" + $",Visual Studio Code:{(int)ExternalEditorId.VsCode}" + $",JetBrains Rider:{(int)ExternalEditorId.Rider}"; } editorSettings.AddPropertyInfo(new Godot.Collections.Dictionary { ["type"] = Variant.Type.Int, ["name"] = "mono/editor/external_editor", ["hint"] = PropertyHint.Enum, ["hint_string"] = settingsHintStr }); // Export plugin var exportPlugin = new ExportPlugin(); AddExportPlugin(exportPlugin); exportPlugin.RegisterExportSettings(); exportPluginWeak = WeakRef(exportPlugin); BuildManager.Initialize(); RiderPathManager.Initialize(); GodotIdeManager = new GodotIdeManager(); AddChild(GodotIdeManager); }
private static DotNetSolution CreateSut(string slnFilePath) { return(DotNetSolution.Load(slnFilePath)); }
private bool CreateProjectSolution() { using (var pr = new EditorProgress("create_csharp_solution", "Generating solution...", 2)) // TTR("Generating solution...") { pr.Step("Generating C# project..."); // TTR("Generating C# project...") string resourceDir = ProjectSettings.GlobalizePath("res://"); string path = resourceDir; string name = (string)ProjectSettings.GetSetting("application/config/name"); if (name.Empty()) { name = "UnnamedProject"; } string guid = CSharpProject.GenerateGameProject(path, name); if (guid.Length > 0) { var solution = new DotNetSolution(name) { DirectoryPath = path }; var projectInfo = new DotNetSolution.ProjectInfo { Guid = guid, PathRelativeToSolution = name + ".csproj", Configs = new List <string> { "Debug", "Release", "Tools" } }; solution.AddNewProject(name, projectInfo); try { solution.Save(); } catch (IOException e) { ShowErrorDialog($"Failed to save solution. Exception message: {e.Message}"); // TTR return(false); } string apiConfig = "Debug"; if (!GodotSharpBuilds.MakeApiAssembly(ApiAssemblyType.Core, apiConfig)) { return(false); } if (!GodotSharpBuilds.MakeApiAssembly(ApiAssemblyType.Editor, apiConfig)) { return(false); } pr.Step("Done"); // TTR("Done") // Here, after all calls to progress_task_step CallDeferred(nameof(_RemoveCreateSlnMenuOption)); } else { ShowErrorDialog("Failed to create C# project."); // TTR } return(true); } }
private static int Cobble(IReadOnlyList <string> csprojFullPaths) { var dir = Directory.GetCurrentDirectory(); var file = "MagicSolution"; var slnFile = $"{file}.sln"; var commands = csprojFullPaths.Select(p => $"dotnet sln ./{slnFile} add {p}").ToList(); commands.Insert(0, $"dotnet new sln -n {file}"); ProcessProxy.RunCommands(commands); var sln = new DotNetSolution(Path.Combine(dir, slnFile)); var toProcess = new HashSet <IDotNetProjectInstance>(); var existing = sln.AllProjects.First().ProjectFileAbsolutePath; toProcess.Add(sln.AllProjects.First()); var analyzedProjectFiles = new HashSet <string>(); analyzedProjectFiles.Add(existing); var toAddProjectFiles = new HashSet <string>(); var dependencies = sln.AllProjects.First().ReferenceProjectPaths; foreach (var dependency in dependencies) { toAddProjectFiles.Add(dependency); } while (toAddProjectFiles.Count > 0) { var currentProjectFile = toAddProjectFiles.First(); ProcessProxy.RunCommands(new[] { $"dotnet sln ./{slnFile} add {currentProjectFile}" }); sln = new DotNetSolution(slnFile); var currentProjectInstance = sln.GetProjectInstanceForProjectFile(currentProjectFile); var paths = currentProjectInstance.ReferenceProjectPaths; foreach (var path in paths) { if (analyzedProjectFiles.Contains(path)) { continue; } else { toAddProjectFiles.Add(path); } } analyzedProjectFiles.Add(currentProjectFile); toAddProjectFiles.Remove(currentProjectFile); } var initialProjects = new HashSet <string>(csprojFullPaths.Select(p => p.ToLower())); var projectsToPutInFolder = sln.AllProjects.Where(p => !initialProjects.Contains(p.ProjectFileAbsolutePath.ToLower())).ToList(); var dependenciesFolder = sln.GetOrCreateSolutionFolder("Dependencies"); foreach (var project in projectsToPutInFolder) { sln.AddProjectToSolutionFolder(project, dependenciesFolder); } sln.Save(); return(0); }
/// <summary> /// args[0] is expected to be the path to the project file. /// </summary> /// <param name="args"></param> private static int Main(string[] args) { #if DOTNETTOOL if (args.Length == 0) { Console.WriteLine($"NuGetDefense v{Version}"); Console.WriteLine("-------------"); Console.WriteLine($"{Environment.NewLine}Usage:"); Console.WriteLine($"{Environment.NewLine} nugetdefense projectFile.proj TargetFrameworkMoniker"); Console.WriteLine($"{Environment.NewLine} nugetdefense SolutionFile.sln Release"); Console.WriteLine($"{Environment.NewLine} nugetdefense SolutionFile.sln Debug|Any CPU"); return(0); } #endif _settings = Settings.LoadSettings(Path.GetDirectoryName(args[0])); _projectFileName = Path.GetFileName(args[0]); ConfigureLogging(); try { Log.Logger.Verbose("Logging Configured"); Log.Logger.Verbose("Started NuGetDefense with arguments: {args}", args); var targetFramework = args.Length == 2 ? args[1] : ""; if (args[0].EndsWith(".sln", StringComparison.OrdinalIgnoreCase)) { var projects = DotNetSolution.Load(args[0]).Projects.Where(p => !p.Type.IsSolutionFolder).Select(p => p.Path).ToArray(); var specificFramework = !string.IsNullOrWhiteSpace(targetFramework); if (specificFramework) { Log.Logger.Information("Target Framework: {framework}", targetFramework); } _projects = LoadMultipleProjects(args[0], projects, specificFramework, targetFramework, true); } else if (_settings.CheckReferencedProjects) { var projects = new List <string> { args[0] }; GetProjectsReferenced(in args[0], in projects); var specificFramework = !string.IsNullOrWhiteSpace(targetFramework); if (specificFramework) { Log.Logger.Information("Target Framework: {framework}", targetFramework); } _projects = LoadMultipleProjects(args[0], projects.ToArray(), specificFramework, targetFramework, false); } else { var nugetFile = new NuGetFile(args[0]); _nuGetFile = nugetFile.Path; Log.Logger.Verbose("NuGetFile Path: {nugetFilePath}", _nuGetFile); Log.Logger.Information("Target Framework: {framework}", string.IsNullOrWhiteSpace(targetFramework) ? "Undefined" : targetFramework); Log.Logger.Verbose("Loading Packages"); Log.Logger.Verbose("Transitive Dependencies Included: {CheckTransitiveDependencies}", _settings.CheckTransitiveDependencies); if (_settings.CheckTransitiveDependencies && nugetFile.PackagesConfig) { var projects = DotNetProject.Load(args[0]).ProjectReferences.Select(p => p.FilePath).ToArray(); var specificFramework = !string.IsNullOrWhiteSpace(targetFramework); if (specificFramework) { Log.Logger.Information("Target Framework: {framework}", targetFramework); } _projects = LoadMultipleProjects(args[0], projects, specificFramework, targetFramework); } else { _projects = new Dictionary <string, NuGetPackage[]>(); _projects.Add(nugetFile.Path, nugetFile.LoadPackages(targetFramework, _settings.CheckTransitiveDependencies).Values.ToArray()); } } GetNonSensitivePackages(out var nonSensitivePackages); if (_settings.ErrorSettings.IgnoredPackages.Length > 0) { foreach (var(project, packages) in _projects.ToArray()) { IgnorePackages(in packages, _settings.ErrorSettings.IgnoredPackages, out var projPackages); _projects[project] = projPackages; } } Log.Logger.Information("Loaded {packageCount} packages", _projects.Sum(p => p.Value.Length)); if (_settings.ErrorSettings.BlockedPackages.Length > 0) { CheckBlockedPackages(); } if (_settings.ErrorSettings.AllowedPackages.Length > 0) { CheckAllowedPackages(); } Dictionary <string, Dictionary <string, Vulnerability> > vulnDict = null; if (_settings.OssIndex.Enabled) { Log.Logger.Verbose("Checking with OSSIndex for Vulnerabilities"); vulnDict = new Scanner(_nuGetFile, _settings.OssIndex.BreakIfCannotRun, UserAgentString, _settings.OssIndex.Username, _settings.OssIndex.ApiToken) .GetVulnerabilitiesForPackages(nonSensitivePackages.SelectMany(p => p.Value).ToArray()); } if (_settings.NVD.Enabled) { Log.Logger.Verbose("Checking the embedded NVD source for Vulnerabilities"); foreach (var(proj, pkgs) in _projects) { vulnDict = new NVD.Scanner(_nuGetFile, TimeSpan.FromSeconds(_settings.NVD.TimeoutInSeconds), _settings.NVD.BreakIfCannotRun, _settings.NVD.SelfUpdate) .GetVulnerabilitiesForPackages(pkgs, vulnDict); } } Log.Logger.Information("ignoring {ignoredCVECount} Vulnerabilities", _settings.ErrorSettings.IgnoredCvEs.Length); if (_settings.ErrorSettings.IgnoredCvEs.Length > 0) { VulnerabilityData.IgnoreCVEs(vulnDict, _settings.ErrorSettings.IgnoredCvEs); } ReportVulnerabilities(vulnDict); return(_settings.WarnOnly ? 0 : NumberOfVulnerabilities); } catch (Exception e) { var msBuildMessage = MsBuild.Log(_nuGetFile, MsBuild.Category.Error, $"Encountered a fatal exception while checking for Dependencies in {_nuGetFile}. Exception: {e}"); Console.WriteLine(msBuildMessage); Log.Logger.Fatal(msBuildMessage); return(-1); } }
public void WhenSlnExists_ThenRead() { var sln = new DotNetSolution(SlnText); Assert.That(sln.MajorVersion, Is.EqualTo(16)); }
private bool CreateProjectSolution() { using (var pr = new EditorProgress("create_csharp_solution", "Generating solution...".TTR(), 2)) { pr.Step("Generating C# project...".TTR()); string resourceDir = ProjectSettings.GlobalizePath("res://"); string path = resourceDir; string name = (string)ProjectSettings.GetSetting("application/config/name"); if (name.Empty()) { name = "UnnamedProject"; } string guid = CSharpProject.GenerateGameProject(path, name); if (guid.Length > 0) { var solution = new DotNetSolution(name) { DirectoryPath = path }; var projectInfo = new DotNetSolution.ProjectInfo { Guid = guid, PathRelativeToSolution = name + ".csproj", Configs = new List <string> { "Debug", "Release", "Tools" } }; solution.AddNewProject(name, projectInfo); try { solution.Save(); } catch (IOException e) { ShowErrorDialog("Failed to save solution. Exception message: ".TTR() + e.Message); return(false); } // Make sure to update the API assemblies if they happen to be missing. Just in // case the user decided to delete them at some point after they were loaded. Internal.UpdateApiAssembliesFromPrebuilt(); pr.Step("Done".TTR()); // Here, after all calls to progress_task_step CallDeferred(nameof(_RemoveCreateSlnMenuOption)); } else { ShowErrorDialog("Failed to create C# project.".TTR()); } return(true); } }
private bool CreateProjectSolution() { using (var pr = new EditorProgress("create_csharp_solution", "Generating solution...".TTR(), 3)) { pr.Step("Generating C# project...".TTR()); string resourceDir = ProjectSettings.GlobalizePath("res://"); string path = resourceDir; string name = (string)ProjectSettings.GetSetting("application/config/name"); if (name.Empty()) { name = "UnnamedProject"; } string guid = CsProjOperations.GenerateGameProject(path, name); if (guid.Length > 0) { var solution = new DotNetSolution(name) { DirectoryPath = path }; var projectInfo = new DotNetSolution.ProjectInfo { Guid = guid, PathRelativeToSolution = name + ".csproj", Configs = new List <string> { "Debug", "Release", "Tools" } }; solution.AddNewProject(name, projectInfo); try { solution.Save(); } catch (IOException e) { ShowErrorDialog("Failed to save solution. Exception message: ".TTR() + e.Message); return(false); } pr.Step("Updating Godot API assemblies...".TTR()); string debugApiAssembliesError = Internal.UpdateApiAssembliesFromPrebuilt("Debug"); if (!string.IsNullOrEmpty(debugApiAssembliesError)) { ShowErrorDialog("Failed to update the Godot API assemblies: " + debugApiAssembliesError); return(false); } string releaseApiAssembliesError = Internal.UpdateApiAssembliesFromPrebuilt("Release"); if (!string.IsNullOrEmpty(releaseApiAssembliesError)) { ShowErrorDialog("Failed to update the Godot API assemblies: " + releaseApiAssembliesError); return(false); } pr.Step("Done".TTR()); // Here, after all calls to progress_task_step CallDeferred(nameof(_RemoveCreateSlnMenuOption)); } else { ShowErrorDialog("Failed to create C# project.".TTR()); } return(true); } }
private void GenerateSolutionFiles(string namePostfix, IEnumerable <Module> modules, string configurationGroup, HashSet <string> projectWhitelist, params string[] externalDefineConstants) { Log.Heading("Generating solution projects files"); using (new Log.ScopedIndent()) { MasterConfiguration = configurationGroup; Solution solution = Reader.Solution; Configuration currentConfiguration = solution .ConfigurationGroups[MasterConfiguration].Configurations .First().Value; Directory.CreateDirectory(Reader.Solution.OutputDir); foreach (Module module in modules) { Log.Heading("Generating module '{0}' with project count of {1}", module.Name, module.ProjectIdLookup.Count); using (new CompositeDisposable( new Log.ScopedIndent())) { ExpandableVars.Instance.SetExpandableVariable(ExpandableVars.VAR_MODULE_NAME, module.Name); foreach (Project.Identifier projectId in module.ProjectIdLookup.Values) { if (!module.Configurations[currentConfiguration].Projects.ContainsKey(projectId.Name)) { // Project was excluded for this configuration group. Log.Info( "Project '{0}' for configuration '{1} - {2}' is excluded from generation", projectId.Name, currentConfiguration.GroupName, currentConfiguration.Name); continue; } Log.Heading("Generating project '{0}' with GUID '{1}' at source path '{2}'", projectId.Name, projectId.Guid, projectId.AbsoluteSourcePath); using (new Log.ScopedIndent()) { ExpandableVars.Instance.SetExpandableVariable(ExpandableVars.VAR_PROJECT_NAME, projectId.Name); var removedRefs = new HashSet <string>(); foreach (Project project in module.Configurations.Values .SelectMany(c => c.Projects.Values).Where(p => p.Name == projectId.Name)) { foreach (string r in project.ExcludeProjectRefs(Reader.ExcludedProjects)) { removedRefs.Add(r); } } if (removedRefs.Count > 0) { Log.Debug("Removing excluded projects refs:"); Log.IndentedCollection(removedRefs, Log.Debug); } var projectTemplate = new DotNetProject { Generator = this, Solution = Reader.Solution, Module = module, ProjectName = projectId.Name, ProjectIdLookup = projectIdLookup, CurrentConfiguration = currentConfiguration, ExternalDefineConstants = externalDefineConstants.ToHashSet(), ProjectNamePostfix = namePostfix, }; Log.Debug("Project name is {0}", projectId.Name); string projectText = projectTemplate.TransformText(); string projectPath = Path.Combine( Reader.Solution.OutputDir, projectId.AbsoluteSourcePath, projectId.Name + namePostfix) + ".csproj"; Log.Info("Writing project to disk at path '{0}'", projectPath); Directory.CreateDirectory(Path.GetDirectoryName(projectPath)); File.WriteAllText(projectPath, projectText); } } } } } Log.Heading("Generating main solution file '{0}'.sln", Reader.Solution.Name); using (new Log.ScopedIndent()) { Log.Debug("Project Whitelist:"); Log.IndentedCollection(projectWhitelist, Log.Debug); var solutionTemplate = new DotNetSolution { Generator = this, Solution = Reader.Solution, Modules = Reader.Modules, ActiveConfigurationGroup = Reader.Solution.ConfigurationGroups[MasterConfiguration], ProjectNamePostfix = namePostfix, ProjectWhitelist = projectWhitelist, }; string solutionText = solutionTemplate.TransformText(); string solutionPath = Path.Combine( Reader.SolutionConfigDir, Reader.Solution.OutputDir, Reader.Solution.Name + namePostfix) + ".sln"; Log.Info("Writing solution to disk at path '{0}'", solutionPath); File.WriteAllText(solutionPath, solutionText); } Log.Info("Finished generating solution '{0}' for configuration group '{1}'", Reader.Solution.Name, configurationGroup); }