From cd24a3cdfa09414520c7c9b5a0b4a50db777dc23 Mon Sep 17 00:00:00 2001 From: Jeff Kluge Date: Fri, 3 Oct 2025 12:26:14 -0700 Subject: [PATCH 1/5] WIP --- Directory.Packages.props | 3 +- .../SolutionTests.cs | 23 +++++++ ...oft.Build.Utilities.ProjectCreation.csproj | 5 +- .../SolutionCreator.cs | 63 +++++++++++++++++++ 4 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 src/Microsoft.Build.Utilities.ProjectCreation.UnitTests/SolutionTests.cs create mode 100644 src/Microsoft.Build.Utilities.ProjectCreation/SolutionCreator.cs diff --git a/Directory.Packages.props b/Directory.Packages.props index 86630cb..aeb0141 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -14,6 +14,7 @@ + @@ -27,4 +28,4 @@ - + \ No newline at end of file diff --git a/src/Microsoft.Build.Utilities.ProjectCreation.UnitTests/SolutionTests.cs b/src/Microsoft.Build.Utilities.ProjectCreation.UnitTests/SolutionTests.cs new file mode 100644 index 0000000..52a0cd8 --- /dev/null +++ b/src/Microsoft.Build.Utilities.ProjectCreation.UnitTests/SolutionTests.cs @@ -0,0 +1,23 @@ +// Copyright (c) Jeff Kluge. All rights reserved. +// +// Licensed under the MIT license. + +using System.IO; +using Xunit; + +namespace Microsoft.Build.Utilities.ProjectCreation.UnitTests +{ + public class SolutionTests : TestBase + { + [Fact] + public void Test1() + { + ProjectCreator project1 = ProjectCreator.Templates.SdkCsproj() + .Save(Path.Combine(TestRootPath, "project1", "project1.csproj")); + + SolutionCreator solution = SolutionCreator.Create(Path.Combine(TestRootPath, "solution1.sln")) + .Project(project1) + .Save(); + } + } +} diff --git a/src/Microsoft.Build.Utilities.ProjectCreation/Microsoft.Build.Utilities.ProjectCreation.csproj b/src/Microsoft.Build.Utilities.ProjectCreation/Microsoft.Build.Utilities.ProjectCreation.csproj index 775b828..cc998c2 100644 --- a/src/Microsoft.Build.Utilities.ProjectCreation/Microsoft.Build.Utilities.ProjectCreation.csproj +++ b/src/Microsoft.Build.Utilities.ProjectCreation/Microsoft.Build.Utilities.ProjectCreation.csproj @@ -8,6 +8,8 @@ *nupkg true $(NoWarn);RS0026;SA1600 + + $(NoWarn);RS0016;CS1591 MSBuild.ProjectCreation @@ -32,6 +34,7 @@ + @@ -55,6 +58,6 @@ - + diff --git a/src/Microsoft.Build.Utilities.ProjectCreation/SolutionCreator.cs b/src/Microsoft.Build.Utilities.ProjectCreation/SolutionCreator.cs new file mode 100644 index 0000000..b87945a --- /dev/null +++ b/src/Microsoft.Build.Utilities.ProjectCreation/SolutionCreator.cs @@ -0,0 +1,63 @@ +// Copyright (c) Jeff Kluge. All rights reserved. +// +// Licensed under the MIT license. + +using Microsoft.VisualStudio.SolutionPersistence; +using Microsoft.VisualStudio.SolutionPersistence.Model; +using Microsoft.VisualStudio.SolutionPersistence.Serializer; +using System; +using System.Threading; + +namespace Microsoft.Build.Utilities.ProjectCreation +{ + public partial class SolutionCreator + { + private SolutionFolderModel? _lastSolutionFolder = default; + + private SolutionProjectModel? _lastProject = default; + + private string _path; + + private SolutionModel _solutionModel; + + private SolutionCreator(string path) + { + _path = path; + + _solutionModel = new SolutionModel(); + } + + public static SolutionCreator Create(string path) + { + return new SolutionCreator(path); + } + + public SolutionCreator Folder(string path) + { + _lastSolutionFolder = _solutionModel.AddFolder(path); + + return this; + } + + public SolutionCreator Project(ProjectCreator project, string? projectTypeName = null) + { + _lastProject = _solutionModel.AddProject(project.FullPath, projectTypeName, folder: null); + + return this; + } + + public SolutionCreator Save() + { + ISolutionSerializer? serializer = SolutionSerializers.GetSerializerByMoniker(_path); + + if (serializer == null) + { + throw new InvalidOperationException($"No solution serializer found for path '{_path}'."); + } + + serializer.SaveAsync(_path, _solutionModel, CancellationToken.None).GetAwaiter().GetResult(); + + return this; + } + } +} From ec4e0e6d167ffe970a7bae7ff4b4459825f2a500 Mon Sep 17 00:00:00 2001 From: Jeff Kluge Date: Wed, 8 Oct 2025 12:14:16 -0700 Subject: [PATCH 2/5] Initial support for solutions --- .../SolutionTests.cs | 29 +++- .../ProjectCreator.cs | 2 +- .../SolutionCreator.cs | 125 ++++++++++++++++-- 3 files changed, 139 insertions(+), 17 deletions(-) diff --git a/src/Microsoft.Build.Utilities.ProjectCreation.UnitTests/SolutionTests.cs b/src/Microsoft.Build.Utilities.ProjectCreation.UnitTests/SolutionTests.cs index 52a0cd8..c74c54c 100644 --- a/src/Microsoft.Build.Utilities.ProjectCreation.UnitTests/SolutionTests.cs +++ b/src/Microsoft.Build.Utilities.ProjectCreation.UnitTests/SolutionTests.cs @@ -2,6 +2,8 @@ // // Licensed under the MIT license. +using Microsoft.VisualStudio.SolutionPersistence.Model; +using Shouldly; using System.IO; using Xunit; @@ -10,14 +12,29 @@ namespace Microsoft.Build.Utilities.ProjectCreation.UnitTests public class SolutionTests : TestBase { [Fact] - public void Test1() + public void BasicTest() { - ProjectCreator project1 = ProjectCreator.Templates.SdkCsproj() - .Save(Path.Combine(TestRootPath, "project1", "project1.csproj")); + string solutionFileFullPath = Path.Combine(TestRootPath, "solution1.sln"); - SolutionCreator solution = SolutionCreator.Create(Path.Combine(TestRootPath, "solution1.sln")) - .Project(project1) - .Save(); + string project1Name = "project1"; + + string project1FullPath = Path.Combine(TestRootPath, project1Name, "project1.csproj"); + + ProjectCreator project1 = ProjectCreator.Templates.SdkCsproj(project1FullPath); + + SolutionCreator solution = SolutionCreator.Create() + .TryProject(project1, projectInSolution: out SolutionProjectModel projectInSolution) + .Save(solutionFileFullPath); + + File.ReadAllText(solutionFileFullPath).ShouldBe(@$"Microsoft Visual Studio Solution File, Format Version 12.00 +Project(""{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}"") = ""{project1Name}"", ""{project1FullPath}"", ""{{{projectInSolution.Id.ToString().ToUpperInvariant()}}}"" +EndProject +Global + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal +", StringCompareShould.IgnoreLineEndings); } } } diff --git a/src/Microsoft.Build.Utilities.ProjectCreation/ProjectCreator.cs b/src/Microsoft.Build.Utilities.ProjectCreation/ProjectCreator.cs index 21f4491..f965c80 100644 --- a/src/Microsoft.Build.Utilities.ProjectCreation/ProjectCreator.cs +++ b/src/Microsoft.Build.Utilities.ProjectCreation/ProjectCreator.cs @@ -185,4 +185,4 @@ protected T AddTopLevelElement(T element) return element; } } -} \ No newline at end of file +} diff --git a/src/Microsoft.Build.Utilities.ProjectCreation/SolutionCreator.cs b/src/Microsoft.Build.Utilities.ProjectCreation/SolutionCreator.cs index b87945a..9d12a16 100644 --- a/src/Microsoft.Build.Utilities.ProjectCreation/SolutionCreator.cs +++ b/src/Microsoft.Build.Utilities.ProjectCreation/SolutionCreator.cs @@ -10,28 +10,67 @@ namespace Microsoft.Build.Utilities.ProjectCreation { + /// + /// A fluent API for generating Visual Studio solutions. + /// public partial class SolutionCreator { - private SolutionFolderModel? _lastSolutionFolder = default; - + /// + /// Stores the last project added to the solution. + /// private SolutionProjectModel? _lastProject = default; - private string _path; + /// + /// Stores the last solution folder added to the solution. + /// + private SolutionFolderModel? _lastSolutionFolder = default; + + /// + /// Stores the path to save the solution to. + /// + private string? _path; + /// + /// Stores the representing the solution being created. + /// private SolutionModel _solutionModel; - private SolutionCreator(string path) + /// + /// Initializes a new instance of the class. + /// + /// An optional path to save the solution to. + private SolutionCreator(string? path) { _path = path; _solutionModel = new SolutionModel(); } - public static SolutionCreator Create(string path) + /// + /// Gets the last project added to the solution. + /// + protected SolutionProjectModel? LastProject => _lastProject; + + /// + /// Gets the last solution folder added to the solution. + /// + protected SolutionFolderModel? LastSolutionFolder => _lastSolutionFolder; + + /// + /// Creates a new instance. + /// + /// An optional path to use when saving the solution. + /// A object used to construct a Visual Studio solution. + public static SolutionCreator Create(string? path = null) { return new SolutionCreator(path); } + /// + /// Adds a folder to the solution. This folder becomes the current context for adding projects. + /// + /// A path to the folder. + /// The current . public SolutionCreator Folder(string path) { _lastSolutionFolder = _solutionModel.AddFolder(path); @@ -39,23 +78,89 @@ public SolutionCreator Folder(string path) return this; } + /// + /// Adds a project to the solution. The project is added to the last solution folder added, if any. + /// + /// The representing the project to add. + /// An optional type name for the project. By default, the project type is detected automatically. + /// The current . public SolutionCreator Project(ProjectCreator project, string? projectTypeName = null) { - _lastProject = _solutionModel.AddProject(project.FullPath, projectTypeName, folder: null); + return Project(project, _lastSolutionFolder, projectTypeName); + } - return this; + /// + /// Adds a project to the solution. The project is added to the specified solution folder, if any. + /// + /// The representing the project to add. + /// The representing the folder to add the project to. + /// An optional type name for the project. By default, the project type is detected automatically. + /// The current . + public SolutionCreator Project(ProjectCreator project, SolutionFolderModel? folder, string? projectTypeName = null) + { + return TryProject(project, folder, out _, projectTypeName); } + /// + /// Saves the solution. + /// + /// The current . + /// A path was not specified when the method was called. public SolutionCreator Save() { - ISolutionSerializer? serializer = SolutionSerializers.GetSerializerByMoniker(_path); + if (_path is null || string.IsNullOrEmpty(_path)) + { + throw new InvalidOperationException("Path must be specified to save the solution."); + } + + return Save(_path); + } + + /// + /// Saves the solution to the specified path. + /// + /// The path to save the solution to. + /// The current . + /// The format for the solution could not be detected because the path does not end in .sln or .slnx. + public SolutionCreator Save(string path) + { + ISolutionSerializer? serializer = SolutionSerializers.GetSerializerByMoniker(path); if (serializer == null) { - throw new InvalidOperationException($"No solution serializer found for path '{_path}'."); + throw new InvalidOperationException($"No solution serializer found for path '{path}'."); } - serializer.SaveAsync(_path, _solutionModel, CancellationToken.None).GetAwaiter().GetResult(); + serializer.SaveAsync(path, _solutionModel, CancellationToken.None).GetAwaiter().GetResult(); + + return this; + } + + /// + /// Adds a project to the solution and outputs the representing the project in the solution. The project is added to the last solution folder added, if any. + /// + /// The representing the project to add. + /// Receives a representing the project in the solution. + /// An optional type name for the project. By default, the project type is detected automatically. + /// The current . + public SolutionCreator TryProject(ProjectCreator project, out SolutionProjectModel projectInSolution, string? projectTypeName = null) + { + return TryProject(project, _lastSolutionFolder, out projectInSolution, projectTypeName); + } + + /// + /// Adds a project to the solution and outputs the representing the project in the solution. The project is added to the specified solution folder, if any. + /// + /// The representing the project to add. + /// The representing the folder to add the project to. + /// Receives a representing the project in the solution. + /// An optional type name for the project. By default, the project type is detected automatically. + /// The current . + public SolutionCreator TryProject(ProjectCreator project, SolutionFolderModel? folder, out SolutionProjectModel projectInSolution, string? projectTypeName = null) + { + project.Save(); + + projectInSolution = _lastProject = _solutionModel.AddProject(project.FullPath, projectTypeName, folder); return this; } From f83530035ecc3562ab05c17604db36e550a8881e Mon Sep 17 00:00:00 2001 From: Jeff Kluge Date: Thu, 9 Oct 2025 14:35:17 -0700 Subject: [PATCH 3/5] WIP --- README.md | 16 + .../SolutionTests.cs | 23 +- .../BuildHost.cs | 209 +++++++ .../ExtensionMethods.cs | 16 - ...oft.Build.Utilities.ProjectCreation.csproj | 2 - .../ProjectCreator.Build.cs | 86 +-- .../ProjectCreator.Templates.cs | 2 +- .../ProjectCreator.UsingTasks.cs | 1 - .../LegacyCsproj.cs | 1 - .../LogsMessage.cs | 3 +- .../SdkCsproj.cs | 1 - .../PublicAPI/net10.0/PublicAPI.Shipped.txt | 1 - .../PublicAPI/net10.0/PublicAPI.Unshipped.txt | 51 ++ .../PublicAPI/net472/PublicAPI.Shipped.txt | 1 - .../PublicAPI/net472/PublicAPI.Unshipped.txt | 51 ++ .../PublicAPI/net8.0/PublicAPI.Shipped.txt | 1 - .../PublicAPI/net8.0/PublicAPI.Unshipped.txt | 51 ++ .../PublicAPI/net9.0/PublicAPI.Shipped.txt | 1 - .../PublicAPI/net9.0/PublicAPI.Unshipped.txt | 51 ++ .../SolutionCreator.Build.cs | 518 ++++++++++++++++++ .../SolutionCreator.Templates.cs | 14 + .../SolutionCreator.cs | 145 +++-- .../SolutionCreatorTemplates/DotNet.cs | 25 + 23 files changed, 1128 insertions(+), 142 deletions(-) create mode 100644 src/Microsoft.Build.Utilities.ProjectCreation/BuildHost.cs rename src/Microsoft.Build.Utilities.ProjectCreation/{Templates => ProjectCreatorTemplates}/LegacyCsproj.cs (99%) rename src/Microsoft.Build.Utilities.ProjectCreation/{Templates => ProjectCreatorTemplates}/LogsMessage.cs (98%) rename src/Microsoft.Build.Utilities.ProjectCreation/{Templates => ProjectCreatorTemplates}/SdkCsproj.cs (99%) create mode 100644 src/Microsoft.Build.Utilities.ProjectCreation/SolutionCreator.Build.cs create mode 100644 src/Microsoft.Build.Utilities.ProjectCreation/SolutionCreator.Templates.cs create mode 100644 src/Microsoft.Build.Utilities.ProjectCreation/SolutionCreatorTemplates/DotNet.cs diff --git a/README.md b/README.md index 5beadd1..ff8e379 100644 --- a/README.md +++ b/README.md @@ -225,6 +225,22 @@ And the resulting project would look like this: ``` +# Visual Studio Solutions +You can create Visual Studio solutions with the `SolutionCreator` class. +This class is a wrapper around the [VS-SolutionPersistence] library which supports both `.sln` and `.slnx` solution file formats. + +The following example creates a solution with two projects: +```C# +ProjectCreator project1 = ProjectCreator.Templates.SdkCsproj(path: Path.Combine(Environment.CurrentDirectory, "project1", "project1.csproj")); + +SolutionCreator.Create(Path.Combine(Environment.CurrentDirectory, "solution1.sln")) + .Configuration("Debug") + .Configuration("Release") + .Platform("Any CPU") + .Project(project1) + .Save(); +``` + # Package Repositories and Feeds NuGet and MSBuild are very tightly coupled and a lot of times you need packages available when building projects. This API offers two solutions: diff --git a/src/Microsoft.Build.Utilities.ProjectCreation.UnitTests/SolutionTests.cs b/src/Microsoft.Build.Utilities.ProjectCreation.UnitTests/SolutionTests.cs index c74c54c..4157503 100644 --- a/src/Microsoft.Build.Utilities.ProjectCreation.UnitTests/SolutionTests.cs +++ b/src/Microsoft.Build.Utilities.ProjectCreation.UnitTests/SolutionTests.cs @@ -22,11 +22,12 @@ public void BasicTest() ProjectCreator project1 = ProjectCreator.Templates.SdkCsproj(project1FullPath); - SolutionCreator solution = SolutionCreator.Create() + SolutionCreator solution = SolutionCreator.Create(solutionFileFullPath) .TryProject(project1, projectInSolution: out SolutionProjectModel projectInSolution) - .Save(solutionFileFullPath); + .Save(); - File.ReadAllText(solutionFileFullPath).ShouldBe(@$"Microsoft Visual Studio Solution File, Format Version 12.00 + File.ReadAllText(solutionFileFullPath).ShouldBe( + @$"Microsoft Visual Studio Solution File, Format Version 12.00 Project(""{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}"") = ""{project1Name}"", ""{project1FullPath}"", ""{{{projectInSolution.Id.ToString().ToUpperInvariant()}}}"" EndProject Global @@ -34,7 +35,21 @@ public void BasicTest() HideSolutionNode = FALSE EndGlobalSection EndGlobal -", StringCompareShould.IgnoreLineEndings); +", + StringCompareShould.IgnoreLineEndings); + } + + [Fact] + public void CanBuild() + { + ProjectCreator project1 = ProjectCreator.Templates.SdkCsproj(path: Path.Combine(TestRootPath, "project1", "project1.csproj")); + + SolutionCreator.Create(Path.Combine(TestRootPath, "solution1.sln")) + .Configuration("Debug") + .Configuration("Release") + .Platform("Any CPU") + .Project(project1) + .TryBuild(out _); } } } diff --git a/src/Microsoft.Build.Utilities.ProjectCreation/BuildHost.cs b/src/Microsoft.Build.Utilities.ProjectCreation/BuildHost.cs new file mode 100644 index 0000000..2bfbd86 --- /dev/null +++ b/src/Microsoft.Build.Utilities.ProjectCreation/BuildHost.cs @@ -0,0 +1,209 @@ +// Copyright (c) Jeff Kluge. All rights reserved. +// +// Licensed under the MIT license. + +using Microsoft.Build.Evaluation; +using Microsoft.Build.Execution; +using Microsoft.Build.Framework; +using System; +using System.Collections.Generic; + +namespace Microsoft.Build.Utilities.ProjectCreation +{ + internal static class BuildHost + { + private static readonly IDictionary EmptyGlobalProperties = new Dictionary(capacity: 0); + +#if !NET8_0 + private static readonly IDictionary EmptyGlobalPropertiesWithNull = new Dictionary(capacity: 0); +#endif + + public static bool Restore( + string projectFullPath, + ProjectCollection projectCollection, + IDictionary? globalProperties, + BuildOutput buildOutput, + out IDictionary? targetOutputs) + { + Dictionary restoreGlobalProperties = new(globalProperties ?? projectCollection.GlobalProperties); // IMPORTANT: Make a copy of the global properties here so as not to modify the ones passed in + + restoreGlobalProperties["ExcludeRestorePackageImports"] = "true"; + restoreGlobalProperties["MSBuildRestoreSessionId"] = Guid.NewGuid().ToString("D"); + + BuildRequestDataFlags buildRequestDataFlags = BuildRequestDataFlags.ClearCachesAfterBuild | BuildRequestDataFlags.SkipNonexistentTargets | BuildRequestDataFlags.IgnoreMissingEmptyAndInvalidImports; + + return BuildProjectFromFullPath(projectFullPath, ["Restore"], restoreGlobalProperties, [.. projectCollection.Loggers, buildOutput], buildRequestDataFlags, out targetOutputs); + } + + public static bool TryBuild( + string projectFullPath, + ProjectCollection projectCollection, + BuildOutput buildOutput, + out IDictionary? targetOutputs, + bool restore = false, + string? target = null, + IDictionary? globalProperties = null) + { + return Build(projectFullPath, restore, target is null ? Array.Empty() : [target], projectCollection, globalProperties, buildOutput, out targetOutputs); + } + + public static bool TryBuild( + string projectFullPath, + ProjectCollection projectCollection, + BuildOutput buildOutput, + out IDictionary? targetOutputs, + bool restore = false, + string[]? targets = null, + IDictionary? globalProperties = null) + { + return Build(projectFullPath, restore, targets ?? Array.Empty(), projectCollection, globalProperties, buildOutput, out targetOutputs); + } + + public static bool TryBuild( + ProjectInstance projectInstance, + ProjectCollection projectCollection, + BuildOutput buildOutput, + out IDictionary? targetOutputs, + string? target = null, + IDictionary? globalProperties = null) + { + return Build(projectInstance, target is null ? Array.Empty() : [target], projectCollection, globalProperties, buildOutput, out targetOutputs); + } + + public static bool TryBuild( + ProjectInstance projectInstance, + ProjectCollection projectCollection, + BuildOutput buildOutput, + out IDictionary? targetOutputs, + string[]? targets = null, + IDictionary? globalProperties = null) + { + return Build(projectInstance, targets ?? Array.Empty(), projectCollection, globalProperties, buildOutput, out targetOutputs); + } + + private static bool Build( + string projectFullPath, + bool restore, + string[] targets, + ProjectCollection projectCollection, + IDictionary? globalProperties, + BuildOutput buildOutput, + out IDictionary? targetOutputs) + { + targetOutputs = null; + + if (restore) + { + if (!Restore(projectFullPath, projectCollection, globalProperties, buildOutput, out _)) + { + return false; + } + } + + return BuildProjectFromFullPath(projectFullPath, targets, globalProperties, [.. projectCollection.Loggers, buildOutput], BuildRequestDataFlags.None, out targetOutputs); + } + + private static bool Build( + ProjectInstance projectInstance, + string[] targets, + ProjectCollection projectCollection, + IDictionary? globalProperties, + BuildOutput buildOutput, + out IDictionary? targetOutputs) + { + targetOutputs = null; + + return BuildProjectFromProjectInstance(projectInstance, targets, globalProperties, [.. projectCollection.Loggers, buildOutput], BuildRequestDataFlags.None, out targetOutputs); + } + + private static bool BuildProjectFromProjectInstance( + ProjectInstance projectInstance, + string[] targets, + IDictionary? globalProperties, + IEnumerable loggers, + BuildRequestDataFlags buildRequestDataFlags, + out IDictionary? targetOutputs) + { + targetOutputs = null; + + BuildResult buildResult = BuildManagerHost.Build( + projectInstance, + targets, + globalProperties ?? EmptyGlobalProperties, + loggers, + buildRequestDataFlags); + + if (buildResult.Exception != null) + { + throw buildResult.Exception; + } + + targetOutputs = buildResult.ResultsByTarget; + + return buildResult.OverallResult == BuildResultCode.Success; + } + + private static bool BuildProjectFromFullPath( + string projectFullPath, + string[] targets, + IDictionary? globalProperties, + IEnumerable loggers, + BuildRequestDataFlags buildRequestDataFlags, + out IDictionary? targetOutputs) + { + targetOutputs = null; + + BuildResult buildResult = BuildManagerHost.Build( + projectFullPath, + targets, + GetGlobalProperties(globalProperties), + loggers, + buildRequestDataFlags); + + if (buildResult.Exception != null) + { + throw buildResult.Exception; + } + + if (targetOutputs != null) + { + foreach (KeyValuePair targetResult in buildResult.ResultsByTarget) + { + targetOutputs[targetResult.Key] = targetResult.Value; + } + } + else + { + targetOutputs = buildResult.ResultsByTarget; + } + + return buildResult.OverallResult == BuildResultCode.Success; + +#if NET8_0 + IDictionary +#else + IDictionary +#endif + GetGlobalProperties(IDictionary? globalProperties) + { +#if NET8_0 + return globalProperties ?? EmptyGlobalProperties; +#else + if (globalProperties is null) + { + return EmptyGlobalPropertiesWithNull; + } + + Dictionary finalGlobalProperties = new(globalProperties.Count); + + foreach (var kvp in globalProperties) + { + finalGlobalProperties[kvp.Key] = kvp.Value; + } + + return finalGlobalProperties; +#endif + } + } + } +} diff --git a/src/Microsoft.Build.Utilities.ProjectCreation/ExtensionMethods.cs b/src/Microsoft.Build.Utilities.ProjectCreation/ExtensionMethods.cs index fb90939..9b2706a 100644 --- a/src/Microsoft.Build.Utilities.ProjectCreation/ExtensionMethods.cs +++ b/src/Microsoft.Build.Utilities.ProjectCreation/ExtensionMethods.cs @@ -73,22 +73,6 @@ public static IEnumerable AsEnumerable(this T? item) return result; } - /// - /// Gets the current object as an array of objects. - /// - /// The type of the object. - /// The item to make into an array. - /// An array of T objects. - [DebuggerStepThrough] - public static T[] ToArrayWithSingleElement(this T item) - where T : class - { - return new[] - { - item, - }; - } - /// /// Creates an entry in the current based on the specified . /// diff --git a/src/Microsoft.Build.Utilities.ProjectCreation/Microsoft.Build.Utilities.ProjectCreation.csproj b/src/Microsoft.Build.Utilities.ProjectCreation/Microsoft.Build.Utilities.ProjectCreation.csproj index cc998c2..5389f92 100644 --- a/src/Microsoft.Build.Utilities.ProjectCreation/Microsoft.Build.Utilities.ProjectCreation.csproj +++ b/src/Microsoft.Build.Utilities.ProjectCreation/Microsoft.Build.Utilities.ProjectCreation.csproj @@ -8,8 +8,6 @@ *nupkg true $(NoWarn);RS0026;SA1600 - - $(NoWarn);RS0016;CS1591 MSBuild.ProjectCreation diff --git a/src/Microsoft.Build.Utilities.ProjectCreation/ProjectCreator.Build.cs b/src/Microsoft.Build.Utilities.ProjectCreation/ProjectCreator.Build.cs index 87ca947..c0713b5 100644 --- a/src/Microsoft.Build.Utilities.ProjectCreation/ProjectCreator.Build.cs +++ b/src/Microsoft.Build.Utilities.ProjectCreation/ProjectCreator.Build.cs @@ -20,7 +20,7 @@ public partial class ProjectCreator /// The current . public ProjectCreator TryBuild(string target, out bool result) { - return TryBuild(target, null, out result); + return TryBuild(target, globalProperties: null, out result); } /// @@ -44,7 +44,7 @@ public ProjectCreator TryBuild(string target, IDictionary? globa /// The current . public ProjectCreator TryBuild(bool restore, string target, out bool result) { - return TryBuild(restore, target, null, out result); + return TryBuild(restore, target, globalProperties: null, out result); } /// @@ -67,7 +67,7 @@ public ProjectCreator TryBuild(bool restore, string target, IDictionaryThe current . public ProjectCreator TryBuild(string target, out bool result, out BuildOutput buildOutput) { - return TryBuild(target, null, out result, out buildOutput); + return TryBuild(target, globalProperties: null, out result, out buildOutput); } /// @@ -107,7 +107,7 @@ public ProjectCreator TryBuild(string target, IDictionary? globa /// The current . public ProjectCreator TryBuild(bool restore, string target, out bool result, out BuildOutput buildOutput) { - return TryBuild(restore, target, null, out result, out buildOutput); + return TryBuild(restore, target, globalProperties: null, out result, out buildOutput); } /// @@ -123,7 +123,7 @@ public ProjectCreator TryBuild(bool restore, string target, IDictionary? global } } - Build(null, globalProperties: globalProperties, out result, out _, out _); + result = Build(null, globalProperties: globalProperties, out _, out _); return this; } @@ -231,7 +231,7 @@ public ProjectCreator TryBuild(bool restore, IDictionary? global { buildOutput = BuildOutput.Create(); - Build(restore, null, globalProperties, buildOutput, out result, out _); + result = Build(restore, null, globalProperties, buildOutput, out _); return this; } @@ -347,7 +347,7 @@ public ProjectCreator TryBuild(bool restore, string[] targets, IDictionary? globalProperties, { buildOutput = BuildOutput.Create(); - Restore(globalProperties, buildOutput, out result, out targetOutputs); + result = Restore(globalProperties, buildOutput, out targetOutputs); return this; } - private void Build(string[]? targets, IDictionary? globalProperties, out bool result, out BuildOutput buildOutput, out IDictionary? targetOutputs) + private bool Build(string[]? targets, IDictionary? globalProperties, out BuildOutput buildOutput, out IDictionary? targetOutputs) { buildOutput = BuildOutput.Create(); - Build(restore: false, targets, globalProperties, buildOutput, out result, out targetOutputs); + return Build(restore: false, targets, globalProperties, buildOutput, out targetOutputs); } - private void Build(bool restore, string[]? targets, IDictionary? globalProperties, BuildOutput buildOutput, out bool result, out IDictionary? targetOutputs) + private bool Build(bool restore, string[]? targets, IDictionary? globalProperties, BuildOutput buildOutput, out IDictionary? targetOutputs) { targetOutputs = null; if (restore) { - Restore(globalProperties, buildOutput, out result, out targetOutputs); - - if (!result) + if (!Restore(globalProperties, buildOutput, out targetOutputs)) { - return; + return false; } } @@ -515,60 +513,18 @@ private void Build(bool restore, string[]? targets, IDictionary? projectInstance = ProjectInstance; } - BuildResult buildResult = BuildManagerHost.Build( - projectInstance, - targets!, - globalProperties!, - new List(ProjectCollection.Loggers.Concat(buildOutput.AsEnumerable())), - BuildRequestDataFlags.None); - - result = buildResult.OverallResult == BuildResultCode.Success; - - if (targetOutputs != null) - { - foreach (KeyValuePair targetResult in buildResult.ResultsByTarget) - { - targetOutputs[targetResult.Key] = targetResult.Value; - } - } - else - { - targetOutputs = buildResult.ResultsByTarget; - } + bool result = BuildHost.TryBuild(projectInstance, ProjectCollection, buildOutput, out targetOutputs, targets: targets); ResetProjectInstance(); + + return result; } - private void Restore(IDictionary? globalProperties, BuildOutput buildOutput, out bool result, out IDictionary targetOutputs) + private bool Restore(IDictionary? globalProperties, BuildOutput buildOutput, out IDictionary? targetOutputs) { Save(); - // IMPORTANT: Make a copy of the global properties here so as not to modify the ones passed in -#if NET8_0 - Dictionary restoreGlobalProperties = -#else - Dictionary restoreGlobalProperties = -#endif - new(globalProperties ?? _globalProperties ?? ProjectCollection.GlobalProperties); - - restoreGlobalProperties["ExcludeRestorePackageImports"] = "true"; - restoreGlobalProperties["MSBuildRestoreSessionId"] = Guid.NewGuid().ToString("D"); - - BuildResult buildResult = BuildManagerHost.Build( - FullPath, - new[] { "Restore" }, - restoreGlobalProperties, - new List(ProjectCollection.Loggers.Concat(buildOutput.AsEnumerable())), - BuildRequestDataFlags.ClearCachesAfterBuild | BuildRequestDataFlags.SkipNonexistentTargets | BuildRequestDataFlags.IgnoreMissingEmptyAndInvalidImports); - - targetOutputs = buildResult.ResultsByTarget; - - if (buildResult.Exception != null) - { - throw buildResult.Exception; - } - - result = buildResult.OverallResult == BuildResultCode.Success; + return BuildHost.Restore(FullPath, ProjectCollection, globalProperties ?? _globalProperties, buildOutput, out targetOutputs); } } -} \ No newline at end of file +} diff --git a/src/Microsoft.Build.Utilities.ProjectCreation/ProjectCreator.Templates.cs b/src/Microsoft.Build.Utilities.ProjectCreation/ProjectCreator.Templates.cs index 7f2a3e2..02aa92b 100644 --- a/src/Microsoft.Build.Utilities.ProjectCreation/ProjectCreator.Templates.cs +++ b/src/Microsoft.Build.Utilities.ProjectCreation/ProjectCreator.Templates.cs @@ -7,7 +7,7 @@ namespace Microsoft.Build.Utilities.ProjectCreation public partial class ProjectCreator { /// - /// Gets a set of project templates that can be used to generate complete projects. + /// Gets a set of templates that can be used to generate complete projects. /// public static ProjectCreatorTemplates Templates { get; } = new ProjectCreatorTemplates(); } diff --git a/src/Microsoft.Build.Utilities.ProjectCreation/ProjectCreator.UsingTasks.cs b/src/Microsoft.Build.Utilities.ProjectCreation/ProjectCreator.UsingTasks.cs index 195b4ea..0688f4c 100644 --- a/src/Microsoft.Build.Utilities.ProjectCreation/ProjectCreator.UsingTasks.cs +++ b/src/Microsoft.Build.Utilities.ProjectCreation/ProjectCreator.UsingTasks.cs @@ -104,7 +104,6 @@ public ProjectCreator UsingTaskParameter(string name, string? parameterType = nu _lastUsingTask.AddParameterGroup(); } - // ReSharper disable once PossibleNullReferenceException _lastUsingTask!.ParameterGroup!.AddParameter( name, output?.ToString() ?? string.Empty, diff --git a/src/Microsoft.Build.Utilities.ProjectCreation/Templates/LegacyCsproj.cs b/src/Microsoft.Build.Utilities.ProjectCreation/ProjectCreatorTemplates/LegacyCsproj.cs similarity index 99% rename from src/Microsoft.Build.Utilities.ProjectCreation/Templates/LegacyCsproj.cs rename to src/Microsoft.Build.Utilities.ProjectCreation/ProjectCreatorTemplates/LegacyCsproj.cs index d66e43c..76059b9 100644 --- a/src/Microsoft.Build.Utilities.ProjectCreation/Templates/LegacyCsproj.cs +++ b/src/Microsoft.Build.Utilities.ProjectCreation/ProjectCreatorTemplates/LegacyCsproj.cs @@ -7,7 +7,6 @@ using System.Collections.Generic; using System.IO; -// ReSharper disable once CheckNamespace namespace Microsoft.Build.Utilities.ProjectCreation { /// diff --git a/src/Microsoft.Build.Utilities.ProjectCreation/Templates/LogsMessage.cs b/src/Microsoft.Build.Utilities.ProjectCreation/ProjectCreatorTemplates/LogsMessage.cs similarity index 98% rename from src/Microsoft.Build.Utilities.ProjectCreation/Templates/LogsMessage.cs rename to src/Microsoft.Build.Utilities.ProjectCreation/ProjectCreatorTemplates/LogsMessage.cs index bc5df53..f133c3a 100644 --- a/src/Microsoft.Build.Utilities.ProjectCreation/Templates/LogsMessage.cs +++ b/src/Microsoft.Build.Utilities.ProjectCreation/ProjectCreatorTemplates/LogsMessage.cs @@ -5,7 +5,6 @@ using Microsoft.Build.Evaluation; using Microsoft.Build.Framework; -// ReSharper disable once CheckNamespace namespace Microsoft.Build.Utilities.ProjectCreation { public partial class ProjectCreatorTemplates @@ -53,4 +52,4 @@ public ProjectCreator LogsMessage( .TaskMessage(text, importance, condition); } } -} \ No newline at end of file +} diff --git a/src/Microsoft.Build.Utilities.ProjectCreation/Templates/SdkCsproj.cs b/src/Microsoft.Build.Utilities.ProjectCreation/ProjectCreatorTemplates/SdkCsproj.cs similarity index 99% rename from src/Microsoft.Build.Utilities.ProjectCreation/Templates/SdkCsproj.cs rename to src/Microsoft.Build.Utilities.ProjectCreation/ProjectCreatorTemplates/SdkCsproj.cs index e752658..0ab316b 100644 --- a/src/Microsoft.Build.Utilities.ProjectCreation/Templates/SdkCsproj.cs +++ b/src/Microsoft.Build.Utilities.ProjectCreation/ProjectCreatorTemplates/SdkCsproj.cs @@ -7,7 +7,6 @@ using System.Collections.Generic; using System.Linq; -// ReSharper disable once CheckNamespace namespace Microsoft.Build.Utilities.ProjectCreation { public partial class ProjectCreatorTemplates diff --git a/src/Microsoft.Build.Utilities.ProjectCreation/PublicAPI/net10.0/PublicAPI.Shipped.txt b/src/Microsoft.Build.Utilities.ProjectCreation/PublicAPI/net10.0/PublicAPI.Shipped.txt index 37c0dfd..d9d0adb 100644 --- a/src/Microsoft.Build.Utilities.ProjectCreation/PublicAPI/net10.0/PublicAPI.Shipped.txt +++ b/src/Microsoft.Build.Utilities.ProjectCreation/PublicAPI/net10.0/PublicAPI.Shipped.txt @@ -290,7 +290,6 @@ static Microsoft.Build.Utilities.ProjectCreation.BuildOutput.Create() -> Microso static Microsoft.Build.Utilities.ProjectCreation.ExtensionMethods.AsEnumerable(this T? item) -> System.Collections.Generic.IEnumerable! static Microsoft.Build.Utilities.ProjectCreation.ExtensionMethods.Merge(this System.Collections.Generic.IDictionary? first, System.Collections.Generic.IDictionary! second) -> System.Collections.Generic.IDictionary! static Microsoft.Build.Utilities.ProjectCreation.ExtensionMethods.Merge(this System.Collections.Generic.IDictionary? first, System.Collections.Generic.IDictionary! second, System.Collections.Generic.IEqualityComparer! comparer) -> System.Collections.Generic.IDictionary! -static Microsoft.Build.Utilities.ProjectCreation.ExtensionMethods.ToArrayWithSingleElement(this T! item) -> T![]! static Microsoft.Build.Utilities.ProjectCreation.MSBuildAssemblyResolver.AssemblyResolve(System.Runtime.Loader.AssemblyLoadContext! assemblyLoadContext, System.Reflection.AssemblyName! requestedAssemblyName) -> System.Reflection.Assembly? static Microsoft.Build.Utilities.ProjectCreation.MSBuildAssemblyResolver.DotNetSdksPath.get -> string? static Microsoft.Build.Utilities.ProjectCreation.MSBuildAssemblyResolver.MSBuildExePath.get -> string? diff --git a/src/Microsoft.Build.Utilities.ProjectCreation/PublicAPI/net10.0/PublicAPI.Unshipped.txt b/src/Microsoft.Build.Utilities.ProjectCreation/PublicAPI/net10.0/PublicAPI.Unshipped.txt index ab058de..cdc99ba 100644 --- a/src/Microsoft.Build.Utilities.ProjectCreation/PublicAPI/net10.0/PublicAPI.Unshipped.txt +++ b/src/Microsoft.Build.Utilities.ProjectCreation/PublicAPI/net10.0/PublicAPI.Unshipped.txt @@ -1 +1,52 @@ #nullable enable +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Configuration(string! configuration) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Folder(string! path) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.FullPath.get -> string! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Platform(string! platform) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Project(Microsoft.Build.Utilities.ProjectCreation.ProjectCreator! project, Microsoft.VisualStudio.SolutionPersistence.Model.SolutionFolderModel? folder, string? projectTypeName = null) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Project(Microsoft.Build.Utilities.ProjectCreation.ProjectCreator! project, string? projectTypeName = null) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Project(params Microsoft.Build.Utilities.ProjectCreation.ProjectCreator![]! projects) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.ProjectCollection.get -> Microsoft.Build.Evaluation.ProjectCollection! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Save() -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, string! target, out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, string! target, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, string! target, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, string! target, System.Collections.Generic.IDictionary? globalProperties, out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, string! target, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, string! target, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, string![]! targets, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, string![]! targets, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, System.Collections.Generic.IDictionary? globalProperties, out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, System.Collections.Generic.IEnumerable! targets, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, System.Collections.Generic.IEnumerable! targets, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(string! target, out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(string! target, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(string! target, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(string! target, System.Collections.Generic.IDictionary? globalProperties, out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(string! target, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(string! target, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(string![]! targets, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(string![]! targets, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(System.Collections.Generic.Dictionary? globalProperties, out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(System.Collections.Generic.IEnumerable! targets, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(System.Collections.Generic.IEnumerable! targets, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryProject(Microsoft.Build.Utilities.ProjectCreation.ProjectCreator! project, Microsoft.VisualStudio.SolutionPersistence.Model.SolutionFolderModel? folder, out Microsoft.VisualStudio.SolutionPersistence.Model.SolutionProjectModel! projectInSolution, string? projectTypeName = null) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryProject(Microsoft.Build.Utilities.ProjectCreation.ProjectCreator! project, out Microsoft.VisualStudio.SolutionPersistence.Model.SolutionProjectModel! projectInSolution, string? projectTypeName = null) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryRestore(out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryRestore(out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryRestore(out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryRestore(System.Collections.Generic.IDictionary? globalProperties, out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryRestore(System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryRestore(System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreatorTemplates +Microsoft.Build.Utilities.ProjectCreation.SolutionCreatorTemplates.DotNet(string! path) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreatorTemplates.SolutionCreatorTemplates() -> void +static Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Create(string! path, Microsoft.Build.Evaluation.ProjectCollection? projectCollection = null, System.Collections.Generic.IDictionary? globalProperties = null) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +static Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Templates.get -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreatorTemplates! diff --git a/src/Microsoft.Build.Utilities.ProjectCreation/PublicAPI/net472/PublicAPI.Shipped.txt b/src/Microsoft.Build.Utilities.ProjectCreation/PublicAPI/net472/PublicAPI.Shipped.txt index 525fa50..63940ac 100644 --- a/src/Microsoft.Build.Utilities.ProjectCreation/PublicAPI/net472/PublicAPI.Shipped.txt +++ b/src/Microsoft.Build.Utilities.ProjectCreation/PublicAPI/net472/PublicAPI.Shipped.txt @@ -290,7 +290,6 @@ static Microsoft.Build.Utilities.ProjectCreation.BuildOutput.Create() -> Microso static Microsoft.Build.Utilities.ProjectCreation.ExtensionMethods.AsEnumerable(this T? item) -> System.Collections.Generic.IEnumerable! static Microsoft.Build.Utilities.ProjectCreation.ExtensionMethods.Merge(this System.Collections.Generic.IDictionary? first, System.Collections.Generic.IDictionary! second) -> System.Collections.Generic.IDictionary! static Microsoft.Build.Utilities.ProjectCreation.ExtensionMethods.Merge(this System.Collections.Generic.IDictionary? first, System.Collections.Generic.IDictionary! second, System.Collections.Generic.IEqualityComparer! comparer) -> System.Collections.Generic.IDictionary! -static Microsoft.Build.Utilities.ProjectCreation.ExtensionMethods.ToArrayWithSingleElement(this T! item) -> T![]! static Microsoft.Build.Utilities.ProjectCreation.MSBuildAssemblyResolver.AssemblyResolve(object? sender, System.ResolveEventArgs! args) -> System.Reflection.Assembly? static Microsoft.Build.Utilities.ProjectCreation.MSBuildAssemblyResolver.DotNetSdksPath.get -> string? static Microsoft.Build.Utilities.ProjectCreation.MSBuildAssemblyResolver.MSBuildExePath.get -> string? diff --git a/src/Microsoft.Build.Utilities.ProjectCreation/PublicAPI/net472/PublicAPI.Unshipped.txt b/src/Microsoft.Build.Utilities.ProjectCreation/PublicAPI/net472/PublicAPI.Unshipped.txt index ab058de..cdc99ba 100644 --- a/src/Microsoft.Build.Utilities.ProjectCreation/PublicAPI/net472/PublicAPI.Unshipped.txt +++ b/src/Microsoft.Build.Utilities.ProjectCreation/PublicAPI/net472/PublicAPI.Unshipped.txt @@ -1 +1,52 @@ #nullable enable +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Configuration(string! configuration) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Folder(string! path) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.FullPath.get -> string! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Platform(string! platform) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Project(Microsoft.Build.Utilities.ProjectCreation.ProjectCreator! project, Microsoft.VisualStudio.SolutionPersistence.Model.SolutionFolderModel? folder, string? projectTypeName = null) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Project(Microsoft.Build.Utilities.ProjectCreation.ProjectCreator! project, string? projectTypeName = null) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Project(params Microsoft.Build.Utilities.ProjectCreation.ProjectCreator![]! projects) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.ProjectCollection.get -> Microsoft.Build.Evaluation.ProjectCollection! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Save() -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, string! target, out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, string! target, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, string! target, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, string! target, System.Collections.Generic.IDictionary? globalProperties, out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, string! target, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, string! target, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, string![]! targets, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, string![]! targets, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, System.Collections.Generic.IDictionary? globalProperties, out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, System.Collections.Generic.IEnumerable! targets, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, System.Collections.Generic.IEnumerable! targets, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(string! target, out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(string! target, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(string! target, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(string! target, System.Collections.Generic.IDictionary? globalProperties, out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(string! target, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(string! target, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(string![]! targets, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(string![]! targets, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(System.Collections.Generic.Dictionary? globalProperties, out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(System.Collections.Generic.IEnumerable! targets, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(System.Collections.Generic.IEnumerable! targets, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryProject(Microsoft.Build.Utilities.ProjectCreation.ProjectCreator! project, Microsoft.VisualStudio.SolutionPersistence.Model.SolutionFolderModel? folder, out Microsoft.VisualStudio.SolutionPersistence.Model.SolutionProjectModel! projectInSolution, string? projectTypeName = null) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryProject(Microsoft.Build.Utilities.ProjectCreation.ProjectCreator! project, out Microsoft.VisualStudio.SolutionPersistence.Model.SolutionProjectModel! projectInSolution, string? projectTypeName = null) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryRestore(out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryRestore(out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryRestore(out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryRestore(System.Collections.Generic.IDictionary? globalProperties, out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryRestore(System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryRestore(System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreatorTemplates +Microsoft.Build.Utilities.ProjectCreation.SolutionCreatorTemplates.DotNet(string! path) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreatorTemplates.SolutionCreatorTemplates() -> void +static Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Create(string! path, Microsoft.Build.Evaluation.ProjectCollection? projectCollection = null, System.Collections.Generic.IDictionary? globalProperties = null) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +static Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Templates.get -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreatorTemplates! diff --git a/src/Microsoft.Build.Utilities.ProjectCreation/PublicAPI/net8.0/PublicAPI.Shipped.txt b/src/Microsoft.Build.Utilities.ProjectCreation/PublicAPI/net8.0/PublicAPI.Shipped.txt index 37c0dfd..d9d0adb 100644 --- a/src/Microsoft.Build.Utilities.ProjectCreation/PublicAPI/net8.0/PublicAPI.Shipped.txt +++ b/src/Microsoft.Build.Utilities.ProjectCreation/PublicAPI/net8.0/PublicAPI.Shipped.txt @@ -290,7 +290,6 @@ static Microsoft.Build.Utilities.ProjectCreation.BuildOutput.Create() -> Microso static Microsoft.Build.Utilities.ProjectCreation.ExtensionMethods.AsEnumerable(this T? item) -> System.Collections.Generic.IEnumerable! static Microsoft.Build.Utilities.ProjectCreation.ExtensionMethods.Merge(this System.Collections.Generic.IDictionary? first, System.Collections.Generic.IDictionary! second) -> System.Collections.Generic.IDictionary! static Microsoft.Build.Utilities.ProjectCreation.ExtensionMethods.Merge(this System.Collections.Generic.IDictionary? first, System.Collections.Generic.IDictionary! second, System.Collections.Generic.IEqualityComparer! comparer) -> System.Collections.Generic.IDictionary! -static Microsoft.Build.Utilities.ProjectCreation.ExtensionMethods.ToArrayWithSingleElement(this T! item) -> T![]! static Microsoft.Build.Utilities.ProjectCreation.MSBuildAssemblyResolver.AssemblyResolve(System.Runtime.Loader.AssemblyLoadContext! assemblyLoadContext, System.Reflection.AssemblyName! requestedAssemblyName) -> System.Reflection.Assembly? static Microsoft.Build.Utilities.ProjectCreation.MSBuildAssemblyResolver.DotNetSdksPath.get -> string? static Microsoft.Build.Utilities.ProjectCreation.MSBuildAssemblyResolver.MSBuildExePath.get -> string? diff --git a/src/Microsoft.Build.Utilities.ProjectCreation/PublicAPI/net8.0/PublicAPI.Unshipped.txt b/src/Microsoft.Build.Utilities.ProjectCreation/PublicAPI/net8.0/PublicAPI.Unshipped.txt index ab058de..cdc99ba 100644 --- a/src/Microsoft.Build.Utilities.ProjectCreation/PublicAPI/net8.0/PublicAPI.Unshipped.txt +++ b/src/Microsoft.Build.Utilities.ProjectCreation/PublicAPI/net8.0/PublicAPI.Unshipped.txt @@ -1 +1,52 @@ #nullable enable +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Configuration(string! configuration) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Folder(string! path) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.FullPath.get -> string! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Platform(string! platform) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Project(Microsoft.Build.Utilities.ProjectCreation.ProjectCreator! project, Microsoft.VisualStudio.SolutionPersistence.Model.SolutionFolderModel? folder, string? projectTypeName = null) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Project(Microsoft.Build.Utilities.ProjectCreation.ProjectCreator! project, string? projectTypeName = null) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Project(params Microsoft.Build.Utilities.ProjectCreation.ProjectCreator![]! projects) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.ProjectCollection.get -> Microsoft.Build.Evaluation.ProjectCollection! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Save() -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, string! target, out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, string! target, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, string! target, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, string! target, System.Collections.Generic.IDictionary? globalProperties, out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, string! target, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, string! target, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, string![]! targets, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, string![]! targets, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, System.Collections.Generic.IDictionary? globalProperties, out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, System.Collections.Generic.IEnumerable! targets, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, System.Collections.Generic.IEnumerable! targets, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(string! target, out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(string! target, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(string! target, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(string! target, System.Collections.Generic.IDictionary? globalProperties, out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(string! target, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(string! target, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(string![]! targets, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(string![]! targets, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(System.Collections.Generic.Dictionary? globalProperties, out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(System.Collections.Generic.IEnumerable! targets, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(System.Collections.Generic.IEnumerable! targets, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryProject(Microsoft.Build.Utilities.ProjectCreation.ProjectCreator! project, Microsoft.VisualStudio.SolutionPersistence.Model.SolutionFolderModel? folder, out Microsoft.VisualStudio.SolutionPersistence.Model.SolutionProjectModel! projectInSolution, string? projectTypeName = null) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryProject(Microsoft.Build.Utilities.ProjectCreation.ProjectCreator! project, out Microsoft.VisualStudio.SolutionPersistence.Model.SolutionProjectModel! projectInSolution, string? projectTypeName = null) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryRestore(out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryRestore(out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryRestore(out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryRestore(System.Collections.Generic.IDictionary? globalProperties, out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryRestore(System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryRestore(System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreatorTemplates +Microsoft.Build.Utilities.ProjectCreation.SolutionCreatorTemplates.DotNet(string! path) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreatorTemplates.SolutionCreatorTemplates() -> void +static Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Create(string! path, Microsoft.Build.Evaluation.ProjectCollection? projectCollection = null, System.Collections.Generic.IDictionary? globalProperties = null) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +static Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Templates.get -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreatorTemplates! diff --git a/src/Microsoft.Build.Utilities.ProjectCreation/PublicAPI/net9.0/PublicAPI.Shipped.txt b/src/Microsoft.Build.Utilities.ProjectCreation/PublicAPI/net9.0/PublicAPI.Shipped.txt index 37c0dfd..d9d0adb 100644 --- a/src/Microsoft.Build.Utilities.ProjectCreation/PublicAPI/net9.0/PublicAPI.Shipped.txt +++ b/src/Microsoft.Build.Utilities.ProjectCreation/PublicAPI/net9.0/PublicAPI.Shipped.txt @@ -290,7 +290,6 @@ static Microsoft.Build.Utilities.ProjectCreation.BuildOutput.Create() -> Microso static Microsoft.Build.Utilities.ProjectCreation.ExtensionMethods.AsEnumerable(this T? item) -> System.Collections.Generic.IEnumerable! static Microsoft.Build.Utilities.ProjectCreation.ExtensionMethods.Merge(this System.Collections.Generic.IDictionary? first, System.Collections.Generic.IDictionary! second) -> System.Collections.Generic.IDictionary! static Microsoft.Build.Utilities.ProjectCreation.ExtensionMethods.Merge(this System.Collections.Generic.IDictionary? first, System.Collections.Generic.IDictionary! second, System.Collections.Generic.IEqualityComparer! comparer) -> System.Collections.Generic.IDictionary! -static Microsoft.Build.Utilities.ProjectCreation.ExtensionMethods.ToArrayWithSingleElement(this T! item) -> T![]! static Microsoft.Build.Utilities.ProjectCreation.MSBuildAssemblyResolver.AssemblyResolve(System.Runtime.Loader.AssemblyLoadContext! assemblyLoadContext, System.Reflection.AssemblyName! requestedAssemblyName) -> System.Reflection.Assembly? static Microsoft.Build.Utilities.ProjectCreation.MSBuildAssemblyResolver.DotNetSdksPath.get -> string? static Microsoft.Build.Utilities.ProjectCreation.MSBuildAssemblyResolver.MSBuildExePath.get -> string? diff --git a/src/Microsoft.Build.Utilities.ProjectCreation/PublicAPI/net9.0/PublicAPI.Unshipped.txt b/src/Microsoft.Build.Utilities.ProjectCreation/PublicAPI/net9.0/PublicAPI.Unshipped.txt index ab058de..cdc99ba 100644 --- a/src/Microsoft.Build.Utilities.ProjectCreation/PublicAPI/net9.0/PublicAPI.Unshipped.txt +++ b/src/Microsoft.Build.Utilities.ProjectCreation/PublicAPI/net9.0/PublicAPI.Unshipped.txt @@ -1 +1,52 @@ #nullable enable +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Configuration(string! configuration) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Folder(string! path) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.FullPath.get -> string! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Platform(string! platform) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Project(Microsoft.Build.Utilities.ProjectCreation.ProjectCreator! project, Microsoft.VisualStudio.SolutionPersistence.Model.SolutionFolderModel? folder, string? projectTypeName = null) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Project(Microsoft.Build.Utilities.ProjectCreation.ProjectCreator! project, string? projectTypeName = null) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Project(params Microsoft.Build.Utilities.ProjectCreation.ProjectCreator![]! projects) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.ProjectCollection.get -> Microsoft.Build.Evaluation.ProjectCollection! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Save() -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, string! target, out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, string! target, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, string! target, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, string! target, System.Collections.Generic.IDictionary? globalProperties, out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, string! target, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, string! target, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, string![]! targets, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, string![]! targets, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, System.Collections.Generic.IDictionary? globalProperties, out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, System.Collections.Generic.IEnumerable! targets, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(bool restore, System.Collections.Generic.IEnumerable! targets, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(string! target, out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(string! target, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(string! target, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(string! target, System.Collections.Generic.IDictionary? globalProperties, out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(string! target, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(string! target, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(string![]! targets, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(string![]! targets, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(System.Collections.Generic.Dictionary? globalProperties, out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(System.Collections.Generic.IEnumerable! targets, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryBuild(System.Collections.Generic.IEnumerable! targets, System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryProject(Microsoft.Build.Utilities.ProjectCreation.ProjectCreator! project, Microsoft.VisualStudio.SolutionPersistence.Model.SolutionFolderModel? folder, out Microsoft.VisualStudio.SolutionPersistence.Model.SolutionProjectModel! projectInSolution, string? projectTypeName = null) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryProject(Microsoft.Build.Utilities.ProjectCreation.ProjectCreator! project, out Microsoft.VisualStudio.SolutionPersistence.Model.SolutionProjectModel! projectInSolution, string? projectTypeName = null) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryRestore(out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryRestore(out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryRestore(out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryRestore(System.Collections.Generic.IDictionary? globalProperties, out bool result) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryRestore(System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.TryRestore(System.Collections.Generic.IDictionary? globalProperties, out bool result, out Microsoft.Build.Utilities.ProjectCreation.BuildOutput! buildOutput, out System.Collections.Generic.IDictionary? targetOutputs) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreatorTemplates +Microsoft.Build.Utilities.ProjectCreation.SolutionCreatorTemplates.DotNet(string! path) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +Microsoft.Build.Utilities.ProjectCreation.SolutionCreatorTemplates.SolutionCreatorTemplates() -> void +static Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Create(string! path, Microsoft.Build.Evaluation.ProjectCollection? projectCollection = null, System.Collections.Generic.IDictionary? globalProperties = null) -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreator! +static Microsoft.Build.Utilities.ProjectCreation.SolutionCreator.Templates.get -> Microsoft.Build.Utilities.ProjectCreation.SolutionCreatorTemplates! diff --git a/src/Microsoft.Build.Utilities.ProjectCreation/SolutionCreator.Build.cs b/src/Microsoft.Build.Utilities.ProjectCreation/SolutionCreator.Build.cs new file mode 100644 index 0000000..e9a6e64 --- /dev/null +++ b/src/Microsoft.Build.Utilities.ProjectCreation/SolutionCreator.Build.cs @@ -0,0 +1,518 @@ +// Copyright (c) Jeff Kluge. All rights reserved. +// +// Licensed under the MIT license. + +using Microsoft.Build.Evaluation; +using Microsoft.Build.Execution; +using System.Collections.Generic; +using System.Linq; + +namespace Microsoft.Build.Utilities.ProjectCreation +{ + public partial class SolutionCreator + { + /// + /// Saves the current Visual Studio solution and attempts to build it. + /// + /// The name of the target to build. + /// A value indicating the result of the build. + /// The current . + public SolutionCreator TryBuild(string target, out bool result) + { + return TryBuild(target, globalProperties: null, out result); + } + + /// + /// Saves the current Visual Studio solution and attempts to build it. + /// + /// The name of the target to build. + /// Global properties to use when building the target. + /// A value indicating the result of the build. + /// The current . + public SolutionCreator TryBuild(string target, IDictionary? globalProperties, out bool result) + { + return TryBuild(restore: false, target, globalProperties, out result); + } + + /// + /// Saves the current Visual Studio solution and attempts to build it. + /// + /// A value indicating whether or not the Visual Studio solution should be restored before building. + /// The name of the target to build. + /// A value indicating the result of the build. + /// The current . + public SolutionCreator TryBuild(bool restore, string target, out bool result) + { + return TryBuild(restore, target, null, out result); + } + + /// + /// Saves the current Visual Studio solution and attempts to build it. + /// + /// A value indicating whether or not the Visual Studio solution should be restored before building. + /// The name of the target to build. + /// Global properties to use when building the target. + /// A value indicating the result of the build. + /// The current . + public SolutionCreator TryBuild(bool restore, string target, IDictionary? globalProperties, out bool result) + { + if (restore) + { + TryRestore(out result); + + if (!result) + { + return this; + } + } + + result = Build([target], globalProperties, out _, out _); + + return this; + } + + /// + /// Saves the current Visual Studio solution and attempts to build it. + /// + /// The name of the target to build. + /// A value indicating the result of the build. + /// A object that captured the logging from the build. + /// The current . + public SolutionCreator TryBuild(string target, out bool result, out BuildOutput buildOutput) + { + return TryBuild(target, null, out result, out buildOutput); + } + + /// + /// Saves the current Visual Studio solution and attempts to build it. + /// + /// The name of the target to build. + /// Global properties to use when building the target. + /// A value indicating the result of the build. + /// A object that captured the logging from the build. + /// The current . + public SolutionCreator TryBuild(string target, IDictionary? globalProperties, out bool result, out BuildOutput buildOutput) + { + return TryBuild(restore: false, target, globalProperties, out result, out buildOutput); + } + + /// + /// Saves the current Visual Studio solution and attempts to build it. + /// + /// A value indicating whether or not the Visual Studio solution should be restored before building. + /// The name of the target to build. + /// A value indicating the result of the build. + /// A object that captured the logging from the build. + /// The current . + public SolutionCreator TryBuild(bool restore, string target, out bool result, out BuildOutput buildOutput) + { + return TryBuild(restore, target, null, out result, out buildOutput); + } + + /// + /// Saves the current Visual Studio solution and attempts to build it. + /// + /// A value indicating whether or not the Visual Studio solution should be restored before building. + /// The name of the target to build. + /// Global properties to use when building the target. + /// A value indicating the result of the build. + /// A object that captured the logging from the build. + /// The current . + public SolutionCreator TryBuild(bool restore, string target, IDictionary? globalProperties, out bool result, out BuildOutput buildOutput) + { + buildOutput = BuildOutput.Create(); + + result = Build(restore, [target], globalProperties, buildOutput, out _); + + return this; + } + + /// + /// Saves the current Visual Studio solution and attempts to build it. + /// + /// A value indicating the result of the build. + /// The current . + public SolutionCreator TryBuild(out bool result) + { + return TryBuild(globalProperties: null, out result); + } + + /// + /// Saves the current Visual Studio solution and attempts to build it. + /// + /// Global properties to use when building the target. + /// A value indicating the result of the build. + /// The current . + public SolutionCreator TryBuild(Dictionary? globalProperties, out bool result) + { + return TryBuild(restore: false, globalProperties: globalProperties, out result); + } + + /// + /// Saves the current Visual Studio solution and attempts to build it. + /// + /// A value indicating whether or not the Visual Studio solution should be restored before building. + /// A value indicating the result of the build. + /// The current . + public SolutionCreator TryBuild(bool restore, out bool result) + { + return TryBuild(restore, globalProperties: null, out result); + } + + /// + /// Saves the current Visual Studio solution and attempts to build it. + /// + /// A value indicating whether or not the Visual Studio solution should be restored before building. + /// Global properties to use when building the target. + /// A value indicating the result of the build. + /// The current . + public SolutionCreator TryBuild(bool restore, IDictionary? globalProperties, out bool result) + { + if (restore) + { + TryRestore(out result); + + if (!result) + { + return this; + } + } + + result = Build(null, globalProperties: globalProperties, out _, out _); + + return this; + } + + /// + /// Saves the current Visual Studio solution and attempts to build it. + /// + /// A value indicating the result of the build. + /// A object that captured the logging from the build. + /// The current . + public SolutionCreator TryBuild(out bool result, out BuildOutput buildOutput) + { + return TryBuild(globalProperties: null, out result, out buildOutput); + } + + /// + /// Saves the current Visual Studio solution and attempts to build it. + /// + /// Global properties to use when building the target. + /// A value indicating the result of the build. + /// A object that captured the logging from the build. + /// The current . + public SolutionCreator TryBuild(IDictionary? globalProperties, out bool result, out BuildOutput buildOutput) + { + return TryBuild(restore: false, globalProperties, out result, out buildOutput); + } + + /// + /// Saves the current Visual Studio solution and attempts to build it. + /// + /// A value indicating whether or not the Visual Studio solution should be restored before building. + /// A value indicating the result of the build. + /// A object that captured the logging from the build. + /// The current . + public SolutionCreator TryBuild(bool restore, out bool result, out BuildOutput buildOutput) + { + return TryBuild(restore, globalProperties: null, out result, out buildOutput); + } + + /// + /// Saves the current Visual Studio solution and attempts to build it. + /// + /// A value indicating whether or not the Visual Studio solution should be restored before building. + /// Global properties to use when building the target. + /// A value indicating the result of the build. + /// A object that captured the logging from the build. + /// The current . + public SolutionCreator TryBuild(bool restore, IDictionary? globalProperties, out bool result, out BuildOutput buildOutput) + { + buildOutput = BuildOutput.Create(); + + result = Build(restore, null, globalProperties, buildOutput, out _); + + return this; + } + + /// + /// Saves the current Visual Studio solution and attempts to build it. + /// + /// The name of the target to build. + /// A value indicating the result of the build. + /// A object that captured the logging from the build. + /// A containing the target outputs. + /// The current . + public SolutionCreator TryBuild(string target, out bool result, out BuildOutput buildOutput, out IDictionary? targetOutputs) + { + return TryBuild(target, null, out result, out buildOutput, out targetOutputs); + } + + /// + /// Saves the current Visual Studio solution and attempts to build it. + /// + /// The name of the target to build. + /// Global properties to use when building the target. + /// A value indicating the result of the build. + /// A object that captured the logging from the build. + /// A containing the target outputs. + /// The current . + public SolutionCreator TryBuild(string target, IDictionary? globalProperties, out bool result, out BuildOutput buildOutput, out IDictionary? targetOutputs) + { + return TryBuild(restore: false, target, globalProperties, out result, out buildOutput, out targetOutputs); + } + + /// + /// Saves the current Visual Studio solution and attempts to build it. + /// + /// A value indicating whether or not the Visual Studio solution should be restored before building. + /// The name of the target to build. + /// A value indicating the result of the build. + /// A object that captured the logging from the build. + /// A containing the target outputs. + /// The current . + public SolutionCreator TryBuild(bool restore, string target, out bool result, out BuildOutput buildOutput, out IDictionary? targetOutputs) + { + return TryBuild(restore, target, null, out result, out buildOutput, out targetOutputs); + } + + /// + /// Saves the current Visual Studio solution and attempts to build it. + /// + /// A value indicating whether or not the Visual Studio solution should be restored before building. + /// The name of the target to build. + /// Global properties to use when building the target. + /// A value indicating the result of the build. + /// A object that captured the logging from the build. + /// A containing the target outputs. + /// The current . + public SolutionCreator TryBuild(bool restore, string target, IDictionary? globalProperties, out bool result, out BuildOutput buildOutput, out IDictionary? targetOutputs) + { + return TryBuild(restore, new[] { target }, globalProperties, out result, out buildOutput, out targetOutputs); + } + + /// + /// Saves the current Visual Studio solution and attempts to build it. + /// + /// The names of the targets to build. + /// A value indicating the result of the build. + /// A object that captured the logging from the build. + /// A containing the target outputs. + /// The current . + public SolutionCreator TryBuild(string[] targets, out bool result, out BuildOutput buildOutput, out IDictionary? targetOutputs) + { + return TryBuild(targets, null, out result, out buildOutput, out targetOutputs); + } + + /// + /// Saves the current Visual Studio solution and attempts to build it. + /// + /// The names of the targets to build. + /// Global properties to use when building the target. + /// A value indicating the result of the build. + /// A object that captured the logging from the build. + /// A containing the target outputs. + /// The current . + public SolutionCreator TryBuild(string[] targets, IDictionary? globalProperties, out bool result, out BuildOutput buildOutput, out IDictionary? targetOutputs) + { + return TryBuild(restore: false, targets, globalProperties, out result, out buildOutput, out targetOutputs); + } + + /// + /// Saves the current Visual Studio solution and attempts to build it. + /// + /// A value indicating whether or not the Visual Studio solution should be restored before building. + /// The names of the targets to build. + /// A value indicating the result of the build. + /// A object that captured the logging from the build. + /// A containing the target outputs. + /// The current . + public SolutionCreator TryBuild(bool restore, string[] targets, out bool result, out BuildOutput buildOutput, out IDictionary? targetOutputs) + { + return TryBuild(restore, targets, null, out result, out buildOutput, out targetOutputs); + } + + /// + /// Saves the current Visual Studio solution and attempts to build it. + /// + /// A value indicating whether or not the Visual Studio solution should be restored before building. + /// The names of the targets to build. + /// Global properties to use when building the target. + /// A value indicating the result of the build. + /// A object that captured the logging from the build. + /// A containing the target outputs. + /// The current . + public SolutionCreator TryBuild(bool restore, string[] targets, IDictionary? globalProperties, out bool result, out BuildOutput buildOutput, out IDictionary? targetOutputs) + { + buildOutput = BuildOutput.Create(); + + result = Build(restore, targets, globalProperties, buildOutput, out targetOutputs); + + return this; + } + + /// + /// Saves the current Visual Studio solution and attempts to build it. + /// + /// The names of the targets to build. + /// A value indicating the result of the build. + /// A object that captured the logging from the build. + /// A containing the target outputs. + /// The current . + public SolutionCreator TryBuild(IEnumerable targets, out bool result, out BuildOutput buildOutput, out IDictionary? targetOutputs) + { + return TryBuild(targets, null, out result, out buildOutput, out targetOutputs); + } + + /// + /// Saves the current Visual Studio solution and attempts to build it. + /// + /// The names of the targets to build. + /// Global properties to use when building the target. + /// A value indicating the result of the build. + /// A object that captured the logging from the build. + /// A containing the target outputs. + /// The current . + public SolutionCreator TryBuild(IEnumerable targets, IDictionary? globalProperties, out bool result, out BuildOutput buildOutput, out IDictionary? targetOutputs) + { + return TryBuild(restore: false, targets, globalProperties, out result, out buildOutput, out targetOutputs); + } + + /// + /// Saves the current Visual Studio solution and attempts to build it. + /// + /// A value indicating whether or not the Visual Studio solution should be restored before building. + /// The names of the targets to build. + /// A value indicating the result of the build. + /// A object that captured the logging from the build. + /// A containing the target outputs. + /// The current . + public SolutionCreator TryBuild(bool restore, IEnumerable targets, out bool result, out BuildOutput buildOutput, out IDictionary? targetOutputs) + { + return TryBuild(restore, targets, null, out result, out buildOutput, out targetOutputs); + } + + /// + /// Saves the current Visual Studio solution and attempts to build it. + /// + /// A value indicating whether or not the Visual Studio solution should be restored before building. + /// The names of the targets to build. + /// Global properties to use when building the target. + /// A value indicating the result of the build. + /// A object that captured the logging from the build. + /// A containing the target outputs. + /// The current . + public SolutionCreator TryBuild(bool restore, IEnumerable targets, IDictionary? globalProperties, out bool result, out BuildOutput buildOutput, out IDictionary? targetOutputs) + { + return TryBuild(restore, targets.ToArray(), globalProperties, out result, out buildOutput, out targetOutputs); + } + + /// + /// Saves the current Visual Studio solution and attempts to run the Restore target with a unique evaluation context. + /// + /// A value indicating the result of the restore. + /// The current . + public SolutionCreator TryRestore(out bool result) + { + return TryRestore(null, out result); + } + + /// + /// Saves the current Visual Studio solution and attempts to run the Restore target with a unique evaluation context. + /// + /// Global properties to use when running the Restore the target. + /// A value indicating the result of the restore. + /// The current . + public SolutionCreator TryRestore(IDictionary? globalProperties, out bool result) + { + return TryRestore(globalProperties, out result, out BuildOutput _, out IDictionary? _); + } + + /// + /// Saves the current Visual Studio solution and attempts to run the Restore target with a unique evaluation context. + /// + /// A value indicating the result of the restore. + /// A object that captured the logging from the restore. + /// The current . + public SolutionCreator TryRestore(out bool result, out BuildOutput buildOutput) + { + return TryRestore(null, out result, out buildOutput); + } + + /// + /// Saves the current Visual Studio solution and attempts to run the Restore target with a unique evaluation context. + /// + /// Global properties to use when running the Restore the target. + /// A value indicating the result of the restore. + /// A object that captured the logging from the restore. + /// The current . + public SolutionCreator TryRestore(IDictionary? globalProperties, out bool result, out BuildOutput buildOutput) + { + return TryRestore(globalProperties, out result, out buildOutput, out IDictionary? _); + } + + /// + /// Saves the current Visual Studio solution and attempts to run the Restore target with a unique evaluation context. + /// + /// A value indicating the result of the restore. + /// A object that captured the logging from the restore. + /// A containing the target outputs. + /// The current . + public SolutionCreator TryRestore(out bool result, out BuildOutput buildOutput, out IDictionary? targetOutputs) + { + return TryRestore(null, out result, out buildOutput, out targetOutputs); + } + + /// + /// Saves the current Visual Studio solution and attempts to run the Restore target with a unique evaluation context. + /// + /// Global properties to use when running the Restore the target. + /// A value indicating the result of the restore. + /// A object that captured the logging from the restore. + /// A containing the target outputs. + /// The current . + public SolutionCreator TryRestore(IDictionary? globalProperties, out bool result, out BuildOutput buildOutput, out IDictionary? targetOutputs) + { + buildOutput = BuildOutput.Create(); + + result = Restore(globalProperties, buildOutput, out targetOutputs); + + return this; + } + + private bool Build(string[]? targets, IDictionary? globalProperties, out BuildOutput buildOutput, out IDictionary? targetOutputs) + { + buildOutput = BuildOutput.Create(); + + return Build(restore: false, targets, globalProperties, buildOutput, out targetOutputs); + } + + private bool Build(bool restore, string[]? targets, IDictionary? globalProperties, BuildOutput buildOutput, out IDictionary? targetOutputs) + { + targetOutputs = null; + + if (restore) + { + if (!Restore(globalProperties, buildOutput, out targetOutputs)) + { + return false; + } + } + else + { + Save(); + } + + bool result = BuildHost.TryBuild(FullPath, ProjectCollection, buildOutput, out targetOutputs, targets: targets); + + return result; + } + + private bool Restore(IDictionary? globalProperties, BuildOutput buildOutput, out IDictionary? targetOutputs) + { + Save(); + + return BuildHost.Restore(FullPath, ProjectCollection, globalProperties ?? _globalProperties, buildOutput, out targetOutputs); + } + } +} diff --git a/src/Microsoft.Build.Utilities.ProjectCreation/SolutionCreator.Templates.cs b/src/Microsoft.Build.Utilities.ProjectCreation/SolutionCreator.Templates.cs new file mode 100644 index 0000000..60fb569 --- /dev/null +++ b/src/Microsoft.Build.Utilities.ProjectCreation/SolutionCreator.Templates.cs @@ -0,0 +1,14 @@ +// Copyright (c) Jeff Kluge. All rights reserved. +// +// Licensed under the MIT license. + +namespace Microsoft.Build.Utilities.ProjectCreation +{ + public partial class SolutionCreator + { + /// + /// Gets a set of templates that be used to generate complete Visual Studio solutions. + /// + public static SolutionCreatorTemplates Templates { get; } = new SolutionCreatorTemplates(); + } +} diff --git a/src/Microsoft.Build.Utilities.ProjectCreation/SolutionCreator.cs b/src/Microsoft.Build.Utilities.ProjectCreation/SolutionCreator.cs index 9d12a16..eccd4ef 100644 --- a/src/Microsoft.Build.Utilities.ProjectCreation/SolutionCreator.cs +++ b/src/Microsoft.Build.Utilities.ProjectCreation/SolutionCreator.cs @@ -2,10 +2,13 @@ // // Licensed under the MIT license. +using Microsoft.Build.Evaluation; using Microsoft.VisualStudio.SolutionPersistence; using Microsoft.VisualStudio.SolutionPersistence.Model; using Microsoft.VisualStudio.SolutionPersistence.Serializer; using System; +using System.Collections.Generic; +using System.IO; using System.Threading; namespace Microsoft.Build.Utilities.ProjectCreation @@ -15,59 +18,97 @@ namespace Microsoft.Build.Utilities.ProjectCreation /// public partial class SolutionCreator { + private readonly IDictionary? _globalProperties = default; + /// - /// Stores the last project added to the solution. + /// Stores the last project added to the Visual Studio solution. /// private SolutionProjectModel? _lastProject = default; /// - /// Stores the last solution folder added to the solution. + /// Stores the last solution folder added to the Visual Studio solution. /// private SolutionFolderModel? _lastSolutionFolder = default; /// - /// Stores the path to save the solution to. - /// - private string? _path; - - /// - /// Stores the representing the solution being created. + /// Stores the representing the Visual Studio solution being created. /// private SolutionModel _solutionModel; /// /// Initializes a new instance of the class. /// - /// An optional path to save the solution to. - private SolutionCreator(string? path) + /// The path to solution where it will be saved. + /// An optional to use when loading the project. + /// An optional dictionary of global properties to use when evaluating projects. + private SolutionCreator( + string path, + ProjectCollection? projectCollection = null, + IDictionary? globalProperties = null) { - _path = path; + if (string.IsNullOrWhiteSpace(path)) + { + throw new ArgumentNullException(nameof(path)); + } + + FullPath = Path.GetFullPath(path); + + ProjectCollection = projectCollection ?? ProjectCollection.GlobalProjectCollection; + + _globalProperties = globalProperties; _solutionModel = new SolutionModel(); } /// - /// Gets the last project added to the solution. + /// Gets the full path to the Visual Studio solution. + /// + public string FullPath { get; private set; } + + /// + /// Gets the for the current Visual Studio solution. + /// + public ProjectCollection ProjectCollection { get; private set; } + + /// + /// Gets the last project added to the Visual Studio solution. /// protected SolutionProjectModel? LastProject => _lastProject; /// - /// Gets the last solution folder added to the solution. + /// Gets the last solution folder added to the Visual Studio solution. /// protected SolutionFolderModel? LastSolutionFolder => _lastSolutionFolder; /// /// Creates a new instance. /// - /// An optional path to use when saving the solution. - /// A object used to construct a Visual Studio solution. - public static SolutionCreator Create(string? path = null) + /// The path to use when saving the Visual Studio solution. + /// An optional to use when evaluating projects. + /// An optional dictionary of global properties to use when evaluating projects. + /// A object used to construct a Visual Studio solution. + public static SolutionCreator Create( + string path, + ProjectCollection? projectCollection = null, + IDictionary? globalProperties = null) { - return new SolutionCreator(path); + return new SolutionCreator(path, projectCollection, globalProperties); } /// - /// Adds a folder to the solution. This folder becomes the current context for adding projects. + /// Adds a build configuration to the Visual Studio solution. + /// + /// The name of the build configuration to add like "Debug" or "Release" + /// The current . + public SolutionCreator Configuration(string configuration) + { + _solutionModel.AddBuildType(configuration); + + return this; + } + + /// + /// Adds a folder to the Visual Studio solution. This folder becomes the current context for adding projects. /// /// A path to the folder. /// The current . @@ -79,7 +120,34 @@ public SolutionCreator Folder(string path) } /// - /// Adds a project to the solution. The project is added to the last solution folder added, if any. + /// Adds a build platform to the Visual Studio solution. + /// + /// The name of the build platform to add like "Any CPU" or "x64". + /// The current . + public SolutionCreator Platform(string platform) + { + _solutionModel.AddPlatform(platform); + + return this; + } + + /// + /// Adds the specified projects to the Visual Studio solution. The projects are added to the last solution folder added, if any. + /// + /// One or more instances representing the projects to add. + /// The current . + public SolutionCreator Project(params ProjectCreator[] projects) + { + foreach (ProjectCreator project in projects) + { + Project(project, projectTypeName: null); + } + + return this; + } + + /// + /// Adds a project to the Visual Studio solution. The project is added to the last solution folder added, if any. /// /// The representing the project to add. /// An optional type name for the project. By default, the project type is detected automatically. @@ -90,7 +158,7 @@ public SolutionCreator Project(ProjectCreator project, string? projectTypeName = } /// - /// Adds a project to the solution. The project is added to the specified solution folder, if any. + /// Adds a project to the Visual Studio solution. The project is added to the specified solution folder, if any. /// /// The representing the project to add. /// The representing the folder to add the project to. @@ -102,45 +170,30 @@ public SolutionCreator Project(ProjectCreator project, SolutionFolderModel? fold } /// - /// Saves the solution. + /// Saves the Visual Studio solution. /// /// The current . - /// A path was not specified when the method was called. public SolutionCreator Save() { - if (_path is null || string.IsNullOrEmpty(_path)) - { - throw new InvalidOperationException("Path must be specified to save the solution."); - } - - return Save(_path); - } - - /// - /// Saves the solution to the specified path. - /// - /// The path to save the solution to. - /// The current . - /// The format for the solution could not be detected because the path does not end in .sln or .slnx. - public SolutionCreator Save(string path) - { - ISolutionSerializer? serializer = SolutionSerializers.GetSerializerByMoniker(path); + ISolutionSerializer? serializer = SolutionSerializers.GetSerializerByMoniker(FullPath); if (serializer == null) { - throw new InvalidOperationException($"No solution serializer found for path '{path}'."); + throw new InvalidOperationException($"No solution serializer found for path '{FullPath}'."); } - serializer.SaveAsync(path, _solutionModel, CancellationToken.None).GetAwaiter().GetResult(); + Directory.CreateDirectory(Path.GetDirectoryName(FullPath)!); + + serializer.SaveAsync(FullPath, _solutionModel, CancellationToken.None).GetAwaiter().GetResult(); return this; } /// - /// Adds a project to the solution and outputs the representing the project in the solution. The project is added to the last solution folder added, if any. + /// Adds a project to the Visual Studio solution and outputs the representing the project in the Visual Studio solution. The project is added to the last solution folder added, if any. /// /// The representing the project to add. - /// Receives a representing the project in the solution. + /// Receives a representing the project in the Visual Studio solution. /// An optional type name for the project. By default, the project type is detected automatically. /// The current . public SolutionCreator TryProject(ProjectCreator project, out SolutionProjectModel projectInSolution, string? projectTypeName = null) @@ -149,11 +202,11 @@ public SolutionCreator TryProject(ProjectCreator project, out SolutionProjectMod } /// - /// Adds a project to the solution and outputs the representing the project in the solution. The project is added to the specified solution folder, if any. + /// Adds a project to the Visual Studio solution and outputs the representing the project in the Visual Studio solution. The project is added to the specified solution folder, if any. /// /// The representing the project to add. /// The representing the folder to add the project to. - /// Receives a representing the project in the solution. + /// Receives a representing the project in the Visual Studio solution. /// An optional type name for the project. By default, the project type is detected automatically. /// The current . public SolutionCreator TryProject(ProjectCreator project, SolutionFolderModel? folder, out SolutionProjectModel projectInSolution, string? projectTypeName = null) @@ -162,6 +215,8 @@ public SolutionCreator TryProject(ProjectCreator project, SolutionFolderModel? f projectInSolution = _lastProject = _solutionModel.AddProject(project.FullPath, projectTypeName, folder); + _solutionModel.DistillProjectConfigurations(); + return this; } } diff --git a/src/Microsoft.Build.Utilities.ProjectCreation/SolutionCreatorTemplates/DotNet.cs b/src/Microsoft.Build.Utilities.ProjectCreation/SolutionCreatorTemplates/DotNet.cs new file mode 100644 index 0000000..4d5c63a --- /dev/null +++ b/src/Microsoft.Build.Utilities.ProjectCreation/SolutionCreatorTemplates/DotNet.cs @@ -0,0 +1,25 @@ +// Copyright (c) Jeff Kluge. All rights reserved. +// +// Licensed under the MIT license. + +namespace Microsoft.Build.Utilities.ProjectCreation +{ + /// + /// Represents Visual Studio solution templates. + /// + public partial class SolutionCreatorTemplates + { + /// + /// Gets a Visual Studio solution for .NET projects that has "Debug" and "Release" configurations as well as an "Any CPU" platform. + /// + /// The path to the Visual Studio solution. + /// A instance configured for .NET projects with "Debug" and "Release" configurations as well as an "Any CPU" platform. + public SolutionCreator DotNet(string path) + { + return SolutionCreator.Create(path) + .Configuration("Debug") + .Configuration("Release") + .Platform("Any CPU"); + } + } +} From 7f0a420caf6b0d538eb53c1e4ae20f82c3688aae Mon Sep 17 00:00:00 2001 From: Jeff Kluge Date: Thu, 9 Oct 2025 14:35:44 -0700 Subject: [PATCH 4/5] Version --- version.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.json b/version.json index 1f1aaed..54ad603 100644 --- a/version.json +++ b/version.json @@ -1,5 +1,5 @@ { - "version": "15.0", + "version": "16.0", "assemblyVersion": "1.0", "buildNumberOffset": -2, "nugetPackageVersion": { From 0252ce2483488be6a45a5e82da7192e1fd583503 Mon Sep 17 00:00:00 2001 From: Jeff Kluge Date: Thu, 9 Oct 2025 14:46:34 -0700 Subject: [PATCH 5/5] Fix test --- .../SolutionTests.cs | 2 +- .../SolutionCreator.cs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.Build.Utilities.ProjectCreation.UnitTests/SolutionTests.cs b/src/Microsoft.Build.Utilities.ProjectCreation.UnitTests/SolutionTests.cs index 4157503..461675d 100644 --- a/src/Microsoft.Build.Utilities.ProjectCreation.UnitTests/SolutionTests.cs +++ b/src/Microsoft.Build.Utilities.ProjectCreation.UnitTests/SolutionTests.cs @@ -28,7 +28,7 @@ public void BasicTest() File.ReadAllText(solutionFileFullPath).ShouldBe( @$"Microsoft Visual Studio Solution File, Format Version 12.00 -Project(""{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}"") = ""{project1Name}"", ""{project1FullPath}"", ""{{{projectInSolution.Id.ToString().ToUpperInvariant()}}}"" +Project(""{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}"") = ""{project1Name}"", ""{project1FullPath.Replace('/', '\\')}"", ""{{{projectInSolution.Id.ToString().ToUpperInvariant()}}}"" EndProject Global GlobalSection(SolutionProperties) = preSolution diff --git a/src/Microsoft.Build.Utilities.ProjectCreation/SolutionCreator.cs b/src/Microsoft.Build.Utilities.ProjectCreation/SolutionCreator.cs index eccd4ef..df15aaf 100644 --- a/src/Microsoft.Build.Utilities.ProjectCreation/SolutionCreator.cs +++ b/src/Microsoft.Build.Utilities.ProjectCreation/SolutionCreator.cs @@ -211,6 +211,11 @@ public SolutionCreator TryProject(ProjectCreator project, out SolutionProjectMod /// The current . public SolutionCreator TryProject(ProjectCreator project, SolutionFolderModel? folder, out SolutionProjectModel projectInSolution, string? projectTypeName = null) { + if (string.IsNullOrWhiteSpace(project.FullPath)) + { + throw new InvalidOperationException("The project must have a valid path before it can be added to the solution."); + } + project.Save(); projectInSolution = _lastProject = _solutionModel.AddProject(project.FullPath, projectTypeName, folder);