Created
December 19, 2011 13:39
-
-
Save rasmuskl/1497275 to your computer and use it in GitHub Desktop.
Example web rakefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'albacore' | |
$msbuildpath = 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe' | |
$aspnet_compiler_path = 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe' | |
$publishdir = 'Publish' | |
$major_version = '1' | |
task :default => [:full] | |
task :full => [:publish, :zip] do | |
end | |
#task :publish => [:version, :clean, :compile, :transform, :test] do | |
task :publish => [:version, :clean, :compile ] do | |
rm_rf 'Dist' | |
rm_rf 'Publish' | |
puts %x{ #{$aspnet_compiler_path} -v / -p Source/AspectoWeb Publish -fixednames -f -u -nologo } | |
rm_rf 'Publish/obj' | |
rm_rf 'Publish/properties' | |
rm_rf 'Publish/Surveys' | |
rm_rf 'Publish/Fragments' | |
rm_rf 'Publish/Users' | |
rm_rf 'Publish/Images' | |
FileList['Publish/*.csproj', 'Publish/*.csproj.user', 'Publish/bin/*.xml', 'Publish/bin/*.pdb', 'Publish/*.targets', 'Publish/*.publish.xml' ].each do |f| | |
rm f | |
end | |
FileList['configs/**/transformed/Web.config'].each do |f| | |
cp f, 'Publish' | |
end | |
rm_rf 'configs' | |
end | |
desc "Zips up the Publish directory." | |
zip do |zip| | |
zip.directories_to_zip "Publish" | |
zip.output_file = "../AspectoWeb-#{get_build_number}.zip" | |
end | |
desc "Removes old build artifacts." | |
msbuild :clean do |msb| | |
msb.command = $msbuildpath | |
msb.properties :configuration => :Release | |
msb.targets :Clean | |
msb.solution = "Source/AspectoWeb.sln" | |
end | |
msbuild :compile do |msb| | |
msb.command = $msbuildpath | |
msb.properties :configuration => :Release | |
msb.targets :Build | |
msb.solution = "Source/AspectoWeb.sln" | |
end | |
msbuild :transform do |msb| | |
msb.command = $msbuildpath | |
msb.properties :configuration => :Release, :IntermediateOutputPath => "../../configs/" | |
msb.targets :TransformWebConfig | |
msb.solution = "Source/AspectoWeb/AspectoWeb.csproj" | |
end | |
desc "Run tests" | |
nunit :test do |nunit| | |
rm_rf "test-reports" | |
mkdir_p "test-reports" | |
nunit.path_to_command = "References/NUnit-2.5.5/nunit-console-x86.exe" | |
nunit.assemblies 'Source/AspectoXTest/bin/Release/AspectoXTest.dll', 'Source/AspectoXTest.Integration/bin/Release/AspectoXTest.Integration.dll' | |
nunit.options '/noshadow', '/framework:net-4.0', '/xml=test-reports/TestResults.xml' | |
puts "##teamcity[importData type='nunit' path='test-reports/TestResults.xml']" | |
end | |
def get_build_number | |
yearversion = Time.now.strftime("%Y") | |
dateversion = Time.now.strftime("%m%d") | |
buildnumber = ENV["BUILD_NUMBER"].nil? ? '0' : ENV["BUILD_NUMBER"] | |
"#{$major_version}.#{yearversion}.#{dateversion}.#{buildnumber}" | |
end | |
assemblyinfo :version do |asm| | |
asm.version = get_build_number | |
asm.output_file = "Source/AssemblyInfo.cs" | |
puts "##teamcity[buildNumber '#{asm.version}']" | |
commit = ENV["BUILD_VCS_NUMBER"].nil? ? `hg id -i` : ENV["BUILD_VCS_NUMBER"] | |
asm.description = Time.now.strftime("%Y-%m-%d %H:%M") | |
asm.trademark = commit | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment