Skip to content

Commit

Permalink
class library output project generation
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidVollmers committed May 5, 2024
1 parent f0263fd commit 4f10981
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
src/Doki.Documentation.Content

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
Expand Down
6 changes: 6 additions & 0 deletions Doki.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
19 changes: 19 additions & 0 deletions src/Doki.Output.ClassLibrary/ClassLibraryOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = $"""
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
{options.GetTargetFrameworkProperty()}
<LangVersion>12</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
""";

File.WriteAllText(projectFilePath, projectFileContent);

return Task.CompletedTask;
}

Expand Down
11 changes: 11 additions & 0 deletions src/Doki.Output.ClassLibrary/InternalExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Doki.Output.ClassLibrary;

internal static class InternalExtensions
{
public static string GetTargetFrameworkProperty(this ClassLibraryOutputOptions options)
{
return options.TargetFrameworks != null
? $"<TargetFrameworks>{string.Join(";", options.TargetFrameworks)}</TargetFrameworks>"
: $"<TargetFramework>{options.TargetFramework}</TargetFramework>";
}
}

0 comments on commit 4f10981

Please sign in to comment.