From 4f109812201865d8cd0c657646c1eb61755219d6 Mon Sep 17 00:00:00 2001 From: dvolper Date: Sun, 5 May 2024 22:30:58 +0200 Subject: [PATCH] class library output project generation --- .gitignore | 2 ++ Doki.sln | 6 ++++++ .../ClassLibraryOutput.cs | 19 +++++++++++++++++++ .../InternalExtensions.cs | 11 +++++++++++ 4 files changed, 38 insertions(+) create mode 100644 src/Doki.Output.ClassLibrary/InternalExtensions.cs diff --git a/.gitignore b/.gitignore index 104b544..f4d7dfc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +src/Doki.Documentation.Content + ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. ## diff --git a/Doki.sln b/Doki.sln index 04e8537..a28972c 100644 --- a/Doki.sln +++ b/Doki.sln @@ -28,6 +28,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Doki.Output.ClassLibrary", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Doki.Output.Extensions", "src\Doki.Output.Extensions\Doki.Output.Extensions.csproj", "{A89D22B2-2427-4863-A2D9-9E1BEFF37C61}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Doki.Documentation.Content", "src\Doki.Documentation.Content\Doki.Documentation.Content.csproj", "{B810F145-0631-4240-AE20-EE816DB45B1F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -89,5 +91,9 @@ Global {A89D22B2-2427-4863-A2D9-9E1BEFF37C61}.Debug|Any CPU.Build.0 = Debug|Any CPU {A89D22B2-2427-4863-A2D9-9E1BEFF37C61}.Release|Any CPU.ActiveCfg = Release|Any CPU {A89D22B2-2427-4863-A2D9-9E1BEFF37C61}.Release|Any CPU.Build.0 = Release|Any CPU + {B810F145-0631-4240-AE20-EE816DB45B1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B810F145-0631-4240-AE20-EE816DB45B1F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B810F145-0631-4240-AE20-EE816DB45B1F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B810F145-0631-4240-AE20-EE816DB45B1F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/src/Doki.Output.ClassLibrary/ClassLibraryOutput.cs b/src/Doki.Output.ClassLibrary/ClassLibraryOutput.cs index 8594aea..644f666 100644 --- a/src/Doki.Output.ClassLibrary/ClassLibraryOutput.cs +++ b/src/Doki.Output.ClassLibrary/ClassLibraryOutput.cs @@ -6,6 +6,25 @@ public Task BeginAsync(CancellationToken cancellationToken = default) { options.ClearOutputDirectoryIfRequired(); + options.OutputDirectory.Create(); + + var projectFilePath = Path.Combine(options.OutputDirectory.FullName, $"{options.Namespace}.csproj"); + + var projectFileContent = $""" + + + + {options.GetTargetFrameworkProperty()} + 12 + enable + enable + + + + """; + + File.WriteAllText(projectFilePath, projectFileContent); + return Task.CompletedTask; } diff --git a/src/Doki.Output.ClassLibrary/InternalExtensions.cs b/src/Doki.Output.ClassLibrary/InternalExtensions.cs new file mode 100644 index 0000000..d0fcc8f --- /dev/null +++ b/src/Doki.Output.ClassLibrary/InternalExtensions.cs @@ -0,0 +1,11 @@ +namespace Doki.Output.ClassLibrary; + +internal static class InternalExtensions +{ + public static string GetTargetFrameworkProperty(this ClassLibraryOutputOptions options) + { + return options.TargetFrameworks != null + ? $"{string.Join(";", options.TargetFrameworks)}" + : $"{options.TargetFramework}"; + } +} \ No newline at end of file