Class: Makit::Setup::ClassLib
- Inherits:
-
Object
- Object
- Makit::Setup::ClassLib
- Defined in:
- lib/makit/setup/classlib.rb
Class Method Summary collapse
Class Method Details
.run ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/makit/setup/classlib.rb', line 8 def self.run # puts "Setting up Nuget project..." project = Makit::Configuration::Project.default dotnet_project_directory = "source/#{project.name}" dotnet_project = Makit::Configuration::DotNetProject.new dotnet_project.name = project.name dotnet_project.template = "classlib" dotnet_project.output_dir = dotnet_project_directory dotnet_project.frameworks = ["net8.0", "net8.0-browser"] project_filename = "source/#{project.name}/#{project.name}.csproj" if (!File.exist?(project_filename)) Makit::DotNet::Project.new_project("classlib", project.name, "source/#{project.name}", "--framework net8.0") dotnet_project = Makit::DotNet::Project.new("source/#{project.name}/#{project.name}.csproj") # set the version to project.version dotnet_project.set_version(project.version) # set the frameworks = ["net8.0","net8.0-browser"] dotnet_project.set_target_frameworks(["net8.0", "net8.0-browser"]) # set the nuget metadata dotnet_project.(project.name, project., project.description, project.license_expression) end test_project_filename = "tests/#{project.name}.Tests/#{project.name}.Tests.csproj" if (File.exist?(test_project_filename)) Makit::DotNet::Project.new_project("TUnit", "#{project.name}.Tests", "tests/#{project.name}.Tests") dotnet_project = Makit::DotNet::Project.new("tests/#{project.name}.Tests/#{project.name}.Tests.csproj") # set the version to project.version dotnet_project.set_version(project.version) # set the frameworks = ["net8.0","net8.0-browser"] dotnet_project.set_target_frameworks(["net8.0"]) # set the nuget metadata dotnet_project.("#{project.name}.Tests", project., project.description, project.license_expression) Makit::DotNet::Project.add_reference("tests/#{project.name}/#{project.name}.Tests.csproj", "source/#{project.name}/#{project.name}.csproj") end update_build_step(project) update_test_step(project) project.save # Setup the sln, then slnx if (!File.exist?("#{project.name}.slnx")) Makit::DotNet.new_solution(project.name) Makit::DotNet.sln_add_projects(project.name) # migrate the sln to slnx "dotnet sln migrate #{project.name}.sln".run FileUtils.rm_f("#{project.name}.sln") if File.exist?("#{project.name}.slnx") end Makit::Logging.default_logger.debug("Project setup completed") end |
.update_build_step(project) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/makit/setup/classlib.rb', line 62 def self.update_build_step(project) build_commands = [] build_commands << "dotnet restore #{project.name}.slnx" if File.exist?("#{project.name}.slnx") build_commands << "dotnet build source/#{project.name}/#{project.name}.csproj --configuration Release" build_commands << "dotnet build tests/#{project.name}.Tests/#{project.name}.Tests.csproj --configuration Release" build_commands << "dotnet pack source/#{project.name}/#{project.name}.csproj --configuration Release --output artifacts/Packages" build_commands << "dotnet pack tests/#{project.name}.Tests/#{project.name}.Tests.csproj --configuration Release --output artifacts/Packages" steps = project.steps if steps.any? { |step| step.name == "build" } build_step = steps.find { |step| step.name == "build" } build_step.commands = build_commands else build_step = Makit::Configuration::Step.new(name: "build", description: "Build the project artifacts", commands: build_commands) build_step.commands = build_commands project.add_step(build_step) end build_step.commands = build_commands project.save end |
.update_test_step(project) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/makit/setup/classlib.rb', line 84 def self.update_test_step(project) test_commands = [] test_commands << "dotnet test tests/#{project.name}/#{project.name}.Tests.csproj" steps = project.steps if steps.any? { |step| step.name == "test" } test_step = steps.find { |step| step.name == "test" } test_step.commands = test_commands else test_step = Makit::Configuration::Step.new(name: "test", description: "Run the project tests", commands: test_commands) test_step.commands = test_commands project.add_step(test_step) end project.save end |