-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrakefile.rb
More file actions
143 lines (110 loc) · 3.81 KB
/
rakefile.rb
File metadata and controls
143 lines (110 loc) · 3.81 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
132
133
134
135
136
137
138
139
140
141
142
require 'rubygems'
sh "bundle install --system"
Gem.clear_paths
require 'albacore'
require 'rake/clean'
require 'set'
include FileUtils
solution_file = FileList["*.sln"].first
build_file = FileList["*.msbuild"].first
www_proj_file = FileList["**/MavenThought.PrDc.Demo/*.csproj"].first
begin
require 'git'
commit = Git.open(".").log.first.sha[0..10]
rescue
commit = 'na'
puts "Git not available"
end
project_name = "MavenThought.PrDc.Demo"
version = IO.readlines('VERSION')[0] rescue "0.0.0.0"
build_folder = File.join('.', 'build', 'www')
CLEAN.include("main/**/bin", "main/**/obj", "test/**/obj", "test/**/bin", "build")
CLOBBER.include("_Re*", "packages", "**/*.user", "**/*.cache", "**/*.suo", "*.docstate*", "Test*.xml")
desc 'Default build'
task :default => ["build:all"]
desc 'Setup requirements to build and deploy'
task :setup => ["setup:dep", "setup:os"]
desc "Alias for deploy:local"
task :deploy => ["deploy:local"]
desc "Run all unit tests"
task :test => ["test:unit"]
namespace :setup do
desc "Setup dependencies for nuget packages"
task :dep do
FileList["**/packages.config"].each do |file|
sh "nuget install #{file} /OutputDirectory Packages"
end
end
desc "Setup dependencies for this OS (x86/x64)"
task :os => ["setup:dep"] do
setup_os
end
end
namespace :build do
desc "Build the project"
msbuild :all, [:config] => ["setup"] do |msb, args|
msb.properties :configuration => args[:config] || :Debug
msb.targets :Build
msb.solution = solution_file
end
desc "Rebuild the project"
task :re => ["clean", "build:all"]
end
namespace :test do
desc "Run unit tests"
nunit :unit => ["build:all"] do |nunit|
nunit.command = "packages/NUnit.2.5.9.10348/Tools/nunit-console.exe"
nunit.assemblies FileList["test/unit/**/bin/debug/*Tests.dll"]
end
desc "Run acceptance tests"
nunit :acceptance, [:tag] => ["deploy:local"] do |nunit, args|
nunit.command = "packages/NUnit.2.5.9.10348/Tools/nunit-console.exe"
nunit.options "/include #{args.tag}" unless ( args.tag.nil? )
nunit.assemblies FileList["test/acceptance/**/bin/debug/*Tests.dll"]
end
end
namespace :deploy do
desc "Publish the site to a local build folder (via an MSBuild Publish target)"
msbuild :local, :config do |msb, args|
# set a default configuration
configuration = args[:config] || :Debug
# construct the absolute folder path to build_folder
complete_build_folder = File.expand_path(build_folder)
puts "Publish build locally to #{complete_build_folder}"
# clean out the build folder
puts "Removing '#{complete_build_folder}'..." if File.directory? complete_build_folder
rm_rf(complete_build_folder) if File.directory? complete_build_folder
# ensure the build folder exists
puts "Creating '#{complete_build_folder}'..." unless File.directory? complete_build_folder
FileUtils.mkdir_p(complete_build_folder) unless File.directory? complete_build_folder
# window-ize the paths
webprojoutdir = complete_build_folder.gsub('/', '\\')
bindir = "#{complete_build_folder}/bin//".gsub('/', '\\')
puts
puts "Packaging as '#{configuration}'"
puts "----------------------------------"
puts "site to: '#{webprojoutdir}'"
puts "bins to: '#{bindir}'"
puts
msb.targets :ResolveReferences,:_CopyWebApplication
msb.properties(
:configuration => configuration,
:webprojectoutputdir => webprojoutdir,
:outdir => bindir
)
msb.solution = www_proj_file
end
end
namespace :util do
task :clean_folder, :folder do |t, args|
rm_rf(args.folder)
Dir.mkdir(args.folder) unless File.directory? args.folder
end
end
def setup_os(target = nil)
target ||= File.exist?('c:\Program Files (x86)') ? 64 : 32
#puts "**** Setting up OS #{target} bits"
#files = FileList["Packages/SQLitex64.1.0.66/lib/#{target}/*.dll"].first
#puts "**** Using #{files}"
#FileUtils.cp(files, "Packages/SQLitex64.1.0.66/lib/")
end