diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..a514be3 --- /dev/null +++ b/Gemfile @@ -0,0 +1,6 @@ +source 'https://rubygems.org' + +gem 'rake' +gem 'os' +gem 'albacore' +gem 'nokogiri' \ No newline at end of file diff --git a/Rakefile.rb b/Rakefile.rb new file mode 100644 index 0000000..3aa3706 --- /dev/null +++ b/Rakefile.rb @@ -0,0 +1,44 @@ +require 'albacore' +require 'open-uri' +require 'fileutils' +require 'os' +require 'nokogiri' +import 'assets/rake/tools.rb' +import 'assets/rake/build.rb' +import 'assets/rake/test.rb' +import 'assets/rake/files.rb' + +BUILD_CONFIG = (ARGV.include?('preflight') || ARGV.include?('fly')) ? 'Release' : (ENV['BUILD_CONFIG'] || 'Debug') +PACKAGES = File.expand_path("packages") +TOOLS = File.expand_path("tools") +NUGET = File.expand_path("#{TOOLS}/NuGet") +NUNIT = File.expand_path("#{PACKAGES}/NUnit.Runners.2.6.3/tools") + + +# + +desc 'Bootstrap, fetch, build, test' +task :preflight => [:nuget, :build, :test ] +desc 'Bootstrap, fetch, build, test,' + +desc 'Build the whole solution' +task :build do + # Use msbuild in .net and xbuild in mono + if OS.windows? + Rake::Task["build:net_clean"].execute + Rake::Task["build:net_build"].execute + else + Rake::Task["build:mon_clean"].execute + Rake::Task["build:mon_build"].execute + end +end + +desc 'Clean build artifacts' +task :clean => ["files:clean_artifacts"] + +desc 'Retrieve nuget dependencies' +task :nuget => ["tools:nuget_fetch"] + +desc 'Run the unit tests' +task :test => "test:unit_tests" + diff --git a/assets/rake/build.rb b/assets/rake/build.rb new file mode 100644 index 0000000..069a381 --- /dev/null +++ b/assets/rake/build.rb @@ -0,0 +1,27 @@ +namespace :build do + # Build the solution + msbuild :net_build do |b| + b.verbosity = 'normal' + b.solution = "tparnell.ContentBundling.sln" + b.properties = { :Configuration => BUILD_CONFIG } + end + + xbuild :mon_build do |b| + b.verbosity = 'normal' + b.solution = "tparnell.ContentBundling.sln" + b.properties = { :Configuration => BUILD_CONFIG } + end + + # Clean the solution + msbuild :net_clean do |b| + b.verbosity = 'normal' + b.solution = "tparnell.ContentBundling.sln" + b.targets = [:Clean] + end + + xbuild :mon_clean do |b| + b.verbosity = 'normal' + b.solution = 'tparnell.ContentBundling.sln' + b.targets = [:Clean] + end +end \ No newline at end of file diff --git a/assets/rake/files.rb b/assets/rake/files.rb new file mode 100644 index 0000000..f6c9fc6 --- /dev/null +++ b/assets/rake/files.rb @@ -0,0 +1,9 @@ +namespace :files do + task :clean_artifacts do + puts 'Deleting all build artifacts from src/**/bin and src/**/obj. Removing output directory.' + + + FileUtils.rm_r Dir.glob("src/**/bin") + FileUtils.rm_r Dir.glob("src/**/obj") + end +end \ No newline at end of file diff --git a/assets/rake/test.rb b/assets/rake/test.rb new file mode 100644 index 0000000..83152c3 --- /dev/null +++ b/assets/rake/test.rb @@ -0,0 +1,9 @@ +namespace :test do + # Run unit tests with nunit + nunit :unit_tests do |cmd| + cmd.command = "#{NUNIT}/nunit-console.exe" + cmd.assemblies = FileList[Dir.glob("src/*.UnitTest/bin/#{BUILD_CONFIG}/*UnitTest.dll")] + #cmd.result_path = "output/tests" + #cmd.no_logo + end +end \ No newline at end of file diff --git a/assets/rake/tools.rb b/assets/rake/tools.rb new file mode 100644 index 0000000..1d86e9f --- /dev/null +++ b/assets/rake/tools.rb @@ -0,0 +1,33 @@ +namespace :tools do + + # If we don't have a copy of nuget, download it + task :nuget_bootstrap do + puts 'Ensuring NuGet exists in tools/NuGet' + + if !FileTest.exist?("#{NUGET}/nuget.exe") + puts 'Downloading nuget from nuget.org' + + FileUtils.mkdir_p("#{NUGET}") + File.open("#{NUGET}/nuget.exe", "wb") do |file| + file.write open('http://nuget.org/nuget.exe').read + end + end + end + + # Fetch nuget dependencies for all packages + task :nuget_fetch => :nuget_bootstrap do + + # If we aren't running under windows, assume we're using mono + CMD_PREFIX = "" + if !OS.windows? + CMD_PREFIX = "mono" + end + + # Make sure we get solution-level deps + sh "#{CMD_PREFIX} #{NUGET}/nuget.exe i .nuget/packages.config -o packages" + + FileList["**/packages.config"].each { |filepath| + sh "#{CMD_PREFIX} #{NUGET}/nuget.exe i #{filepath} -o packages" + } + end +end \ No newline at end of file diff --git a/tools/NuGet/nuget.exe b/tools/NuGet/nuget.exe new file mode 100644 index 0000000..e69de29