Skip to content
This repository
tree: a0cf3db0ef
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 131 lines (110 sloc) 5.61 kb
1 2 3 4 5 6 7 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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
require 'fileutils'
require 'version_bumper'

#Unfortunately SQLite cannot be ILMerged in because it is not 100% managed.
#exec :ilmerge_runner_with_providers => :release do |cmd|
# FileUtils.mkdir_p 'il_merged'
# cmd.path_to_command = "tools/ILMerge.exe"
# cmd.parameters [
# '/target:library',
# '/out:il_merged\\FluentMigrator.Runner.dll',
# '/zeroPeKind', # necessary for SQLLite, which isn't managed. might not work though...
# 'src\\FluentMigrator\\bin\\Release\\FluentMigrator.dll',
# 'src\\FluentMigrator.Runner\\bin\\Release\\FluentMigrator.Runner.dll',
# 'lib\\MySql.Data.dll',
# 'lib\\System.Data.SQLite.DLL'
# ]
#end

FLUENTMIGRATOR_VERSION = bumper_version.to_s

def to_nuget_version(v)
v[1] + v[3]
end

def copy_files(from, to, filename, extensions)
  extensions.each do |ext|
    FileUtils.cp "#{from}#{filename}.#{ext}", "#{to}#{filename}.#{ext}"
  end
end

def prepare_lib(version)
  output_directory_lib = "./packages/FluentMigrator/lib/#{to_nuget_version(version)}/"
  FileUtils.mkdir_p output_directory_lib
  copy_files "./dist/console-#{version}-AnyCPU/", output_directory_lib, 'FluentMigrator', ['dll', 'pdb', 'xml']
end

def prepare_tools
  output_directory_tools = './packages/FluentMigrator/tools/'
  FileUtils.mkdir_p output_directory_tools
  cp_r FileList["dist/console-v4.0-x86/*"], output_directory_tools
end

def prepare_tools_package
  output_directory_tools = './packages/FluentMigrator.Tools/tools/'
  output_directory_content = './packages/FluentMigrator.Tools/content/'

  FileUtils.mkdir_p output_directory_content
  FileUtils.mkdir_p output_directory_tools

  copy_files './packages/', output_directory_tools, 'install', ['ps1']
  copy_files './packages/', output_directory_content, 'InstallationDummyFile', ['txt']
  
  @platforms.each do |p|
    FileUtils.mkdir_p output_directory_tools + p + '/'
    @versions.each do |v|
      output_folder = output_directory_tools + p + "/#{to_nuget_version(v)}/"
      FileUtils.mkdir_p output_folder
      cp_r FileList["dist/console-#{v}-#{p}/*"], output_folder
    end
  end
end

namespace :nuget do
  task :clean do
    FileUtils.rm_rf './packages/FluentMigrator/tools/'
    FileUtils.rm_rf './packages/FluentMigrator/lib/'
    FileUtils.rm_rf './packages/FluentMigrator.Tools/tools/'
  end
  
  desc "create the FluentMigrator nuspec file"
  nuspec :create_spec do |nuspec|
     version = "#{ENV['version']}"

     nuspec.id = "FluentMigrator"
     nuspec.version = version.length == 7 ? version : FLUENTMIGRATOR_VERSION
     nuspec.authors = "Josh Coffman"
     nuspec.owners = "Sean Chambers"
     nuspec.description = "FluentMigrator is a database migration framework for .NET written in C#. The basic idea is that you can create migrations which are simply classes that derive from the Migration base class and have a Migration attribute with a unique version number attached to them. Upon executing FluentMigrator, you tell it which version to migrate to and it will run all necessary migrations in order to bring your database up to that version.
In addition to forward migration support, FluentMigrator also supports different ways to execute the migrations along with selective migrations called profiles and executing arbitrary SQL."
     nuspec.title = "Fluent Migrator"
     nuspec.language = "en-US"
     nuspec.projectUrl = "https://github.com/schambers/fluentmigrator/wiki/"
     nuspec.working_directory = "packages/FluentMigrator"
     nuspec.output_file = "FluentMigrator.nuspec"
  end
  
  desc "create the nuspec file"
  nuspec :create_tools_spec do |nuspec|
     version = "#{ENV['version']}"
     new_version = version.length == 7 ? version : FLUENTMIGRATOR_VERSION
     nuspec.id = "FluentMigrator.Tools"
     nuspec.version = new_version
     nuspec.authors = "Josh Coffman"
     nuspec.owners = "Sean Chambers"
     nuspec.description = "FluentMigrator is a database migration framework for .NET written in C#. The basic idea is that you can create migrations which are simply classes that derive from the Migration base class and have a Migration attribute with a unique version number attached to them. Upon executing FluentMigrator, you tell it which version to migrate to and it will run all necessary migrations in order to bring your database up to that version.
In addition to forward migration support, FluentMigrator also supports different ways to execute the migrations along with selective migrations called profiles and executing arbitrary SQL."
     nuspec.title = "Fluent Migrator Tools"
     nuspec.language = "en-US"
     nuspec.projectUrl = "https://github.com/schambers/fluentmigrator/wiki/"
     nuspec.working_directory = "packages/FluentMigrator.Tools"
     nuspec.output_file = "FluentMigrator.Tools.nuspec"
nuspec.dependency "FluentMigrator", new_version
  end

  @platforms = ['x86', 'AnyCPU']
  @versions = ['v3.5', 'v4.0']
    
  task :prepare_package => ['build:solutioninfo', 'build:console', :create_spec, :create_tools_spec, :clean] do
    
    @versions.each do |v|
      prepare_lib v
    end
    
    prepare_tools
    prepare_tools_package
  end

  task :package => :prepare_package do
    nuget_pack('packages/FluentMigrator/', 'packages/FluentMigrator/FluentMigrator.nuspec')
    nuget_pack('packages/FluentMigrator.Tools/', 'packages/FluentMigrator.Tools/FluentMigrator.Tools.nuspec')
  end
  
  def nuget_pack(base_folder, nuspec_path)
    cmd = Exec.new
    output = 'nuget/'
    cmd.command = 'tools/NuGet.exe'
    cmd.parameters = "pack #{nuspec_path} -basepath #{base_folder} -outputdirectory #{output}"
    cmd.execute
  end

end
Something went wrong with that request. Please try again.