Class: Makit::Cli::Generators::Templates::Dotnet::Csproj

Inherits:
Object
  • Object
show all
Defined in:
lib/makit/cli/generators/templates/dotnet_templates.rb

Overview

Template generator for .NET .csproj project files

Generates a basic .NET 6.0 console application project file with standard configuration including nullable reference types and implicit usings.

Examples:

csproj = Csproj.new("MyApp")
xml_content = csproj.render

Instance Method Summary collapse

Constructor Details

#initialize(project_name) ⇒ Csproj

Initialize a new .csproj template generator

Parameters:

  • project_name (String)

    the name of the .NET project



28
29
30
# File 'lib/makit/cli/generators/templates/dotnet_templates.rb', line 28

def initialize(project_name)
  @project_name = project_name
end

Instance Method Details

#renderString

Render the .csproj XML content

Returns:

  • (String)

    the complete .csproj XML content



35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/makit/cli/generators/templates/dotnet_templates.rb', line 35

def render
  "    <Project Sdk=\"Microsoft.NET.Sdk\">\n\n      <PropertyGroup>\n        <OutputType>Exe</OutputType>\n        <TargetFramework>net6.0</TargetFramework>\n        <ImplicitUsings>enable</ImplicitUsings>\n        <Nullable>enable</Nullable>\n      </PropertyGroup>\n\n    </Project>\n  XML\nend\n"