module Makit class DotNet def self.is_installed? File.exist?(Makit::Environment.which("dotnet")) end def self.version `dotnet --version` end def self.new_project(template, name, output) if Dir.exist? output puts " #{output}".colorize(:green) + " exists.".colorize(:grey) #puts "Directory #{output} already exists".colorize(:yellow) else "dotnet new #{template} --name #{name} --output #{output}".run end end def self.add_package(project_path, package_name) project_content = File.read(project_path) if (!project_content.include?("\"#{package_name}\"")) "dotnet add #{project_path} package #{package_name}".run else puts " package ".colorize(:grey) + "#{package_name}".colorize(:yellow) + " is in ".colorize(:grey) + "#{project_path}".colorize(:yellow) #puts "Package #{package_name} already exists in #{project_path}".colorize(:yellow) end end def self.add_reference(project_path, reference_path) project_content = File.read(project_path) if(project_content.include?("