This repository was archived by the owner on Dec 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrakefile.rb
More file actions
183 lines (147 loc) · 5.56 KB
/
Copy pathrakefile.rb
File metadata and controls
183 lines (147 loc) · 5.56 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
require 'albacore' #0.3.6
require 'version_bumper'
bumper_file "version.txt"
# Read any atypical version bump type from environment/command-line.
# e.g., rake bumpType=minor
# bumpType=major -> 2.3.251.0 becomes 3.0.0.0
# bumpType=minor -> 2.3.251.0 becomes 2.4.0.0
# no bumpType specified -> 2.3.251.0 becomes 2.3.252.0
bumpType = ENV["bumpType"] || 'revision'
# Setup variables.
assemblyName = "SecuritySwitch"
projectDir = "Source/SecuritySwitch/"
targetFile = "#{projectDir}bin/Release/#{assemblyName}.dll"
targetStrongFile = "#{projectDir}bin/Strong/#{assemblyName}.dll"
keyFile = "#{assemblyName}.snk"
productName = "Security Switch"
productDescription = ".NET libraries for automatically switching between HTTP and HTTPS protocols."
productAuthors = "Matt Sollars"
copyrightBeginYear = 2004
nugetId = "SecuritySwitch"
nugetDir = "NuGet/"
nuspecFile = "#{nugetDir}#{assemblyName}.nuspec"
configSchemaFile = "#{assemblyName}-v#{bumper_version.major}.xsd"
downloadsDir = "Downloads/"
workingDir = "#{downloadsDir}Working"
archiveName = "#{assemblyName} v#{bumper_version.to_s} - Binary"
archiveStrongName = "#{assemblyName} v#{bumper_version.to_s} - Strongly Named Binary"
# Start the build.
task :default => [:build, :pushNuGet, :createArchives]
#task :default => [:build, :pushNuGet, :uploadArchives]
desc "Sets common assembly information."
assemblyinfo :setAssemblyInfo do |asm|
case bumpType
when 'major'
Rake::Task['bump:major'].invoke
when 'minor'
Rake::Task['bump:minor'].invoke
when 'revision'
Rake::Task['bump:revision'].invoke
when 'none'
# no-op
else
puts "Unknown bumpType. Exiting."
exit 0
end
asm.version = bumper_version.to_s
asm.file_version = bumper_version.to_s
now = Time.new
asm.product_name = productName
asm.copyright = "Copyright (c) #{copyrightBeginYear}-#{now.year} #{productAuthors}"
asm.description = productDescription
asm.com_visible = false
asm.output_file = "CommonAssemblyInfo.cs"
end
desc "Builds the solution for a new release."
msbuild :build => :setAssemblyInfo do |msb|
msb.properties = { :configuration => :Release }
msb.targets = [:Clean, :Build]
msb.solution = "SecuritySwitch.sln"
end
desc "Builds the solution for a new strongly named release."
msbuild :buildStrong => :setAssemblyInfo do |msb|
msb.properties = {
:configuration => :Strong,
:signAssembly => "true",
:assemblyOriginatorKeyFile => "../../#{keyFile}"
}
msb.targets = [:Build]
msb.solution = "#{projectDir}SecuritySwitch.csproj"
end
desc "Runs tests for solution."
xunit :runTests do |xunit|
xunit.command = "packages/xunit.runners.1.9.1/tools/xunit.console.exe"
xunit.assembly = "Source/Tests/bin/Release/#{assemblyName}.Tests.dll"
end
desc "Creates the NuGet specification."
nuspec :createNuSpec do |spec|
spec.id = nugetId
spec.version = bumper_version.to_s
spec.title = productName
spec.authors = productAuthors
spec.description = productDescription
spec.language = "en-US"
spec.projectUrl = "http://code.google.com/p/securityswitch/"
spec.tags = "security switch secure SSL HTTPS ASP.NET MVC"
spec.output_file = nuspecFile
end
desc "Create the NuGet package."
nugetpack :packNuGet => [:runTests, :createNuSpec] do |nuget|
# Copy NuGet content files (config schema).
FileUtils.cp configSchemaFile, "#{nugetDir}content/"
# Copy NuGet lib files (output files/assemblies).
FileUtils.cp targetFile, "#{nugetDir}lib/"
# Pack NuGet spec file; output to the NuGet directory.
nuget.nuspec = nuspecFile
nuget.base_folder = nugetDir
nuget.output = nugetDir
end
desc "Pushes the NuGet package."
nugetpush :pushNuGet => :packNuGet do |nuget|
nuget.package = "#{nugetDir}#{assemblyName}.#{bumper_version.to_s}.nupkg"
end
desc "Sets up the working directory for archive creation."
task :setupWorkingDir do
FileUtils.mkpath workingDir
FileUtils.rm Dir.glob("#{workingDir}/*")
FileUtils.cp "License.txt", workingDir
FileUtils.cp "ReadMe.txt", workingDir
FileUtils.cp configSchemaFile, workingDir
end
desc "Creates the standard archive."
zip :createStandardArchive do |zip|
FileUtils.cp targetFile, workingDir
zip.directories_to_zip workingDir
zip.output_file = "#{archiveName}.zip"
zip.output_path = downloadsDir
puts "Archive created: #{downloadsDir}#{archiveName}.zip"
end
desc "Creates the strongly named archive."
zip :createStrongArchive do |zip|
FileUtils.cp targetStrongFile, workingDir
zip.directories_to_zip workingDir
zip.output_file = "#{archiveStrongName}.zip"
zip.output_path = downloadsDir
puts "Archive created: #{downloadsDir}#{archiveStrongName}.zip"
end
desc "Creates the download archives."
task :createArchives => [:build, :runTests, :buildStrong, :setupWorkingDir, :createStandardArchive, :createStrongArchive]
desc "Uploads the archive(s) to Google Code."
#task :uploadArchives => :createArchives do
task :uploadArchives do
uploadUrl = "https://uploads.code.google.com/upload/securityswitch"
userAgent = "Uploader via cURL"
fields = {
"summary" => archiveName,
"description" => "Latest stable build of SecuritySwitch v#{bumper_version.major}.#{bumper_version.minor}.",
#"file" => "@#{downloadsDir}#{archiveName}.zip"
"file" => "@#{downloadsDir}test.txt"
}
labels = ["Type-Archive", "Featured"]
fieldCommands = ""
#labels.each { |label| fieldCommands += "--form 'label=#{label}' " }
#fields.each { |key, value| fieldCommands += "--form '#{key}=#{value}' " }
verbose(true) do
sh "curl --basic " + fieldCommands + "#{uploadUrl}"
end
end