Skip to content

Commit

Permalink
Setting up initial project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Kelley committed Mar 18, 2011
0 parents commit 2adc301
Show file tree
Hide file tree
Showing 8 changed files with 643 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .gitignore
@@ -0,0 +1,23 @@
TestResult.xml
build
[oO]bj
[Bb]in
deploy
deploy/*
_ReSharper.*
*.csproj.user
*.resharper.user
*.ReSharper.user
*.resharper
*.suo
*.cache
~$*
*.orig
*.5.0.ReSharper
CommonAssemblyInfo.cs
coverage
coverage/*
Coverage.Log
Specifications/*
build_support/tmp
*.xap
11 changes: 11 additions & 0 deletions InstallGems.bat
@@ -0,0 +1,11 @@
@ECHO *** Installing Rake
@call gem install rake --include-dependencies

@ECHO *** Installing ActiveRecord
@call gem install activerecord --include-dependencies

@ECHO *** Installing RubyZip
@call gem install rubyzip --include-dependencies

@ECHO *** Installing Rails
@call gem install rails --include-dependencies
210 changes: 210 additions & 0 deletions build_support/BuildUtils.rb
@@ -0,0 +1,210 @@
require 'erb'

class NUnitRunner
include FileTest

def initialize(paths)
@sourceDir = paths.fetch(:source, 'source')
@resultsDir = paths.fetch(:results, 'results')
@compilePlatform = paths.fetch(:platform, '')
@compileTarget = paths.fetch(:compilemode, 'debug')
@options = paths.fetch(:options, '/framework=4.0.30319')


if ENV["teamcity.dotnet.nunitlauncher"] # check if we are running in TeamCity
# We are not using the TeamCity nunit launcher. We use NUnit with the TeamCity NUnit Addin which needs tO be copied to our NUnit addins folder
# http://blogs.jetbrains.com/teamcity/2008/07/28/unfolding-teamcity-addin-for-nunit-secrets/
# The teamcity.dotnet.nunitaddin environment variable is not available until TeamCity 4.0, so we hardcode it for now
puts "Add In Path is "
puts ENV["teamcity.dotnet.nunitaddin"] ? ENV["teamcity.dotnet.nunitaddin"] : 'NOT FOUND'
#@teamCityAddinPath = ENV["teamcity.dotnet.nunitaddin"] ? ENV["teamcity.dotnet.nunitaddin"] : 'c:/buildAgent/plugins/dotnetPlugin/bin/JetBrains.TeamCity.NUnitAddin-NUnit'
@teamCityAddinPath = 'c:/buildAgent/plugins/dotnetPlugin/bin/JetBrains.TeamCity.NUnitAddin-NUnit'
cp @teamCityAddinPath + '-2.5.4.dll', 'lib/nunit/addins/'
end

@nunitExe = File.join('lib', 'nunit', "nunit-console#{(@compilePlatform.empty? ? '' : "-#{@compilePlatform}")}.exe").gsub('/','\\') + ' /nothread'
end

def executeTests(assemblies)
Dir.mkdir @resultsDir unless exists?(@resultsDir)

assemblies.each do |assem|
file = File.expand_path("#{@sourceDir}/#{assem}/bin/#{@compileTarget}/#{assem}.dll")
puts "#{@nunitExe} #{@options} \"#{file}\""
sh "#{@nunitExe} #{@options} \"#{file}\""
end
end

def getExecutable(assemblies)
files = "";
assemblies.each do |assem|
file = File.expand_path("#{@sourceDir}/#{assem}/bin/#{@compileTarget}/#{assem}.dll")
files += file + " "
end

file = files.chop

@executable = "#{@nunitExe} #{@options} \"#{file}\""
return @executable
end

def get_command_line
return @executable
end


end

class NCoverRunner
include FileTest

def initialize(paths)
@resultsDir = paths.fetch(:results, 'coverage')
@nunitCommand = paths.fetch(:nunit, '')

@ncoverExe = File.join('lib', 'ncover', "NCover.Console.exe")
end

def cover(assemblies)
Dir.mkdir @resultsDir unless exists?(@resultsDir)
output = "//x #{@resultsDir}/coverage.xml"

includes = "//a "
assemblies.each do |assem|
includes += assem + ";"
end

assemToCover = includes.chop
sh "regsvr32 lib/ncover/CoverLib.dll /s"
sh "#{@ncoverExe} #{output} #{assemToCover} #{@nunitCommand}"
sh "regsvr32 lib/ncover/CoverLib.dll /u /s"
end
end

class NCoverExplorer

def initialize(paths)
@resultsDir = paths.fetch(:results, 'coverage')
@coverageFile = paths.fetch(:coverage, 'coverage.xml')
@projectName = paths.fetch(:project, 'Unkown')
@minAccept = paths.fetch(:minimumLevel, '80')

@ncoverExplorer = File.join('lib', 'ncoverexplorer', 'NCoverExplorer.Console.exe')


end

def generateReports()

sh "#{@ncoverExplorer} #{@resultsDir}/#{@coverageFile} /r:ModuleClassSummary /h:#{@resultsDir}/CoverageReport.html /p:#{@projectName} /so:Name"

end
end

class MSBuildRunner
def self.compile(attributes)
version = attributes.fetch(:clrversion, 'v4.0.30319')
compileTarget = attributes.fetch(:compilemode, 'debug')
solutionFile = attributes[:solutionfile]

frameworkDir = File.join(ENV['windir'].dup, 'Microsoft.NET', 'Framework', version)
msbuildFile = File.join(frameworkDir, 'msbuild.exe')

sh "#{msbuildFile} #{solutionFile} /nologo /maxcpucount /v:m /property:BuildInParallel=false /property:Configuration=#{compileTarget} /t:Rebuild"
end
end

class AspNetCompilerRunner
def self.compile(attributes)

webPhysDir = attributes.fetch(:webPhysDir, '')
webVirDir = attributes.fetch(:webVirDir, 'This_Value_Is_Not_Used')
outputPath = attributes.fetch(:outputPath, '')
frameworkDir = File.join(ENV['windir'].dup, 'Microsoft.NET', 'Framework', 'v4.0.30319')
aspNetCompiler = File.join(frameworkDir, 'aspnet_compiler.exe')

sh "#{aspNetCompiler} -nologo -errorstack -c -p #{webPhysDir} -v #{webVirDir} -f #{outputPath}"
end
end

class AsmInfoBuilder
attr_reader :buildnumber

def initialize(baseVersion, properties)
@properties = properties;

@buildnumber = baseVersion + (ENV["CCNetLabel"].nil? ? '0' : ENV["CCNetLabel"].to_s)
@properties['Version'] = @properties['InformationalVersion'] = buildnumber;
end



def write(file)
template = %q{
using System;
using System.Reflection;
using System.Runtime.InteropServices;
<% @properties.each {|k, v| %>
[assembly: Assembly<%=k%>Attribute("<%=v%>")]
<% } %>
}.gsub(/^ /, '')

erb = ERB.new(template, 0, "%<>")

File.open(file, 'w') do |file|
file.puts erb.result(binding)
end
end
end

require 'FileUtils'

class WebCopier

def initialize(exclude)
@exclude = exclude
end

def copy src, dest

stage dest

Dir.foreach(src) do |file|
next if exclude?(file)

s = File.join(src, file)
d = File.join(dest, file)

if File.directory?(s)
FileUtils.mkdir(d)
copy s, d
else
FileUtils.cp(s, d)
end

puts d
end
end

def stage dest
if File.directory?(dest)
FileUtils.rm_rf(dest)
end

FileUtils.mkdir(dest)
end

def exclude? file
@exclude.each do |s|
if file.match(/#{s}/i)
return true
end
end
false
end




end
30 changes: 30 additions & 0 deletions build_support/Ruby_Not_Installed.txt
@@ -0,0 +1,30 @@

**********************************************
WE'RE SORRY!
Ruby not installed?
**********************************************

It appears you do not have Ruby installed.
This project uses the "Rake" build system from Ruby.

If you *DO* have Ruby installed, please make sure the
Ruby\bin folder is in your PATH.

If you *DON'T* have Ruby installed then, in order to
run "Rake", please perform the following steps:

1.) Download and install Ruby 1.8.6 (or later --
"1.8.6. One-Click installer recommended for Windows)

- Main Download URL:
http://www.ruby-lang.org/en/downloads/

- 1.8.6 One-Click installer:
http://rubyforge.org/frs/download.php/29263/ruby186-26.exe
(md5: 00540689d1039964bc8d844b2b0c7db6)


2.) Install the Rake "Gem" and related "Gems" by running
InstallGems.bat in the same folder as this Build.bat file

**********************************************
77 changes: 77 additions & 0 deletions build_support/Tarantino.rb
@@ -0,0 +1,77 @@
require 'erb'
#TARANTINO = "lib\\tarantino\\Tarantino.DatabaseManager.Console.exe"
class Tarantino
def self.manageSQLDatabase(args)
@dbname = args.fetch(:dbname, '')
@dbserver = args.fetch(:dbserver, 'localhost')
@action = args.fetch(:action, '')
@scriptdir = args.fetch(:scriptdir, '')

Dir.mkdir @scriptdir unless exists?(@scriptdir)

#NOTE: TARANTINO is defined in the main rakefile.rb
system("#{TARANTINO} #{@action} #{@dbserver} #{@dbname} #{@scriptdir}")

end

def self.NextMigration(args)
@scriptdir = args.fetch(:scriptdir, '')
@scriptdir = @scriptdir + '\\update'

contains = Dir.new(@scriptdir).entries
lastfile = contains[contains.length-1]
counter = 1

if contains.length > 2 then
counter = Float(lastfile[0,4])
counter += 1

if counter % 2 == 0 then
counter +=1
end

end
return "%04d" % counter
end

def self.CompareDatabases(args)
@dbname = args.fetch(:dbname, '')
@dbserver = args.fetch(:dbserver, 'localhost')
@scriptdir = args.fetch(:scriptdir, '')

Dir.mkdir @scriptdir unless exists?(@scriptdir)

if File.file?("#{@scriptdir}\\_New_Script.sql") then
FileUtils.rm("#{@scriptdir}\\_New_Script.sql")
end
migrationScriptName = Tarantino.NextMigration( :scriptdir => @scriptdir) + '_AutoGeneratedMigration.sql'

#@scriptdir = @scriptdir + '\\update'
@nextscript = args.fetch(:nextscript, '')

@redgate = ""
if File.file?( 'c:\program files (x86)\red gate\SQL Compare 8\SQLCompare.exe' ) then
@redgate = 'c:\program files (x86)\red gate\SQL Compare 8\SQLCompare.exe'
end

if File.file?( 'c:\program files\red gate\SQL Compare 8\SQLCompare.exe' ) then
@redgate = 'c:\program files\red gate\SQL Compare 8\SQLCompare.exe'
end

params = "/f /v /server1:#{@dbserver} /server2:#{@dbserver} /database1:#{@dbname} /database2:#{@dbname}Versioned /scriptfile:#{@scriptdir}\\_New_Script.sql /exclude:Table:usd_AppliedDatabaseScript"

#puts "#{@redgate} #{params}"
system("#{@redgate} #{params}")

if File.file?("#{@scriptdir}\\_New_Script.sql") then
puts "Moving Migration scrpit"
FileUtils.mv("#{@scriptdir}\\_New_Script.sql", "#{@scriptdir}\\#{migrationScriptName}")
puts "Created Migration File #{@scriptdir}\\#{migrationScriptName}"
else
puts ""
puts "--------------------------------------------"
puts "No Migration Required"
end

end
end

0 comments on commit 2adc301

Please sign in to comment.