Permalink
Browse files

Topshelf v4 update to .NET 4.5.2, AppVeyor build, FAKE build script

  • Loading branch information...
1 parent d8daba3 commit fb7f016a3490f96a94a385c55fab085c46e79479 @phatboyg phatboyg committed Apr 12, 2016
Showing with 1,663 additions and 902 deletions.
  1. +2 −0 .gitignore
  2. +0 −3 .gitmodules
  3. +0 −6 .semver
  4. +0 −6 Gemfile
  5. +5 −0 build.bat
  6. +194 −0 build.fsx
  7. +0 −112 build_support/BuildUtils.rb
  8. +0 −22 build_support/util.rb
  9. +0 −30 build_support/versioning.rb
  10. +0 −342 rakefile.rb
  11. +4 −2 src/SampleTopshelfRehabService/SampleTopshelfRehabService.csproj
  12. +2 −2 src/SampleTopshelfRehabService/app.config
  13. +1 −1 src/SampleTopshelfRehabService/packages.config
  14. +0 −3 src/SampleTopshelfService/AssemblyInfo.cs
  15. +1 −1 src/SampleTopshelfService/Program.cs
  16. +9 −7 src/SampleTopshelfService/SampleTopshelfService.csproj
  17. +2 −2 src/SampleTopshelfService/app.config
  18. +1 −1 src/SampleTopshelfService/packages.config
  19. +4 −6 src/SampleTopshelfSuperviseService/SampleTopshelfSuperviseService.csproj
  20. +2 −2 src/SampleTopshelfSuperviseService/app.config
  21. +1 −1 src/SampleTopshelfSuperviseService/packages.config
  22. +13 −10 src/SolutionVersion.cs
  23. +5 −6 src/Topshelf.Elmah/Topshelf.Elmah.csproj
  24. +3 −3 src/Topshelf.Elmah/packages.config
  25. +9 −15 src/Topshelf.Log4Net/Topshelf.Log4Net.csproj
  26. +1 −1 src/Topshelf.Log4Net/packages.config
  27. +31 −27 src/Topshelf.NLog/Logging/NLogLogWriter.cs
  28. +1 −1 src/Topshelf.NLog/Logging/NLogLogWriterFactory.cs
  29. +9 −15 src/Topshelf.NLog/Topshelf.NLog.csproj
  30. +1 −1 src/Topshelf.NLog/packages.config
  31. +9 −5 src/Topshelf.Rehab/Topshelf.Rehab.csproj
  32. +6 −12 src/Topshelf.Serilog/Topshelf.Serilog.csproj
  33. +1 −1 src/Topshelf.Serilog/packages.config
  34. +7 −6 src/Topshelf.Supervise/Topshelf.Supervise.csproj
  35. +0 −45 src/Topshelf.Tests/Supervise_Specs.cs
  36. +5 −7 src/Topshelf.Tests/Topshelf.Tests.csproj
  37. +2 −122 src/Topshelf.sln
  38. +1 −0 src/Topshelf.sln.DotSettings
  39. +152 −0 src/Topshelf/Caching/Cache.cs
  40. +4 −0 src/Topshelf/Caching/CacheItemCallback.cs
  41. +326 −0 src/Topshelf/Caching/ConcurrentCache.cs
  42. +356 −0 src/Topshelf/Caching/DictionaryCache.cs
  43. +215 −0 src/Topshelf/Caching/GenericTypeCache.cs
  44. +4 −0 src/Topshelf/Caching/KeySelector.cs
  45. +4 −0 src/Topshelf/Caching/MissingValueProvider.cs
  46. +74 −0 src/Topshelf/Caching/ReadCache.cs
  47. +1 −1 src/Topshelf/Configuration/Builders/CommandBuilder.cs
  48. +2 −4 src/Topshelf/Configuration/CommandLineParser/ArgumentElement.cs
  49. +1 −1 src/Topshelf/Configuration/CommandLineParser/CommandLine.cs
  50. +3 −7 src/Topshelf/Configuration/CommandLineParser/DefinitionElement.cs
  51. +3 −5 src/Topshelf/Configuration/CommandLineParser/SwitchElement.cs
  52. +2 −4 src/Topshelf/Configuration/CommandLineParser/TokenElement.cs
  53. +9 −16 src/Topshelf/Configuration/Configurators/ValidateConfigurationResult.cs
  54. +2 −2 src/Topshelf/Configuration/HostConfigurators/HostConfigurator.cs
  55. +0 −1 src/Topshelf/Configuration/ServiceConfigurators/ControlServiceConfigurator.cs
  56. +0 −1 src/Topshelf/Internals
  57. +0 −1 src/Topshelf/Logging/HostLogger.cs
  58. +1 −1 src/Topshelf/Logging/TraceLogWriterFactory.cs
  59. +15 −0 src/Topshelf/Logging/TypeExtensions.cs
  60. +110 −0 src/Topshelf/Logging/TypeNameFormatter.cs
  61. +1 −1 src/Topshelf/Runtime/Windows/WindowsHostEnvironment.cs
  62. +1 −1 src/Topshelf/Runtime/Windows/WindowsHostEnvironmentBuilder.cs
  63. +2 −6 src/Topshelf/Runtime/Windows/WindowsServiceHost.cs
  64. +3 −11 src/Topshelf/Runtime/Windows/WindowsUserAccessControl.cs
  65. +17 −13 src/Topshelf/Topshelf.csproj
  66. +3 −0 src/Topshelf/packages.config
  67. +20 −0 template.nuspec
View
@@ -10,6 +10,8 @@ packages
*.dotCover
*.dotSettings
+.fake
+
bin
obj
_ReSharper*
View
@@ -1,3 +0,0 @@
-[submodule "src/Topshelf/Internals"]
- path = src/Topshelf/Internals
- url = https://github.com/phatboyg/Internals.git
View
@@ -1,6 +0,0 @@
----
-:major: 3
-:minor: 3
-:patch: 1
-:special: ''
-:metadata: ''
View
@@ -1,6 +0,0 @@
-#ruby=1.9.3
-#gemset=topshelf
-source 'http://rubygems.org'
-gem 'albacore', '~> 1.0.0'
-gem 'rake'
-gem 'semver2'
View
@@ -0,0 +1,5 @@
+@echo off
+cls
+If Not Exist src\.nuget\nuget.exe msbuild src\.nuget\NuGet.targets -Target:RestorePackages
+If Not Exist src\packages\FAKE\tools\fake.exe src\.nuget\nuget.exe Install FAKE -OutputDirectory "src\packages" -ExcludeVersion
+src\packages\FAKE\tools\fake.exe build.fsx %*
View
@@ -0,0 +1,194 @@
+#r @"src/packages/FAKE/tools/FakeLib.dll"
+open System.IO
+open Fake
+open Fake.AssemblyInfoFile
+open Fake.Git.Information
+open Fake.SemVerHelper
+
+let buildOutputPath = "./build_output"
+let buildArtifactPath = "./build_artifacts"
+let nugetWorkingPath = FullName "./build_temp"
+let packagesPath = FullName "./src/packages"
+let keyFile = FullName "./Topshelf.snk"
+
+let assemblyVersion = "4.0.0.0"
+let baseVersion = "4.0.0"
+
+let semVersion : SemVerInfo = parse baseVersion
+
+let Version = semVersion.ToString()
+
+let branch = (fun _ ->
+ (environVarOrDefault "APPVEYOR_REPO_BRANCH" (getBranchName "."))
+)
+
+let FileVersion = (environVarOrDefault "APPVEYOR_BUILD_VERSION" (Version + "." + "0"))
+
+let informationalVersion = (fun _ ->
+ let branchName = (branch ".")
+ let label = if branchName="master" then "" else " (" + branchName + "/" + (getCurrentSHA1 ".").[0..7] + ")"
+ (FileVersion + label)
+)
+
+let nugetVersion = (fun _ ->
+ let branchName = (branch ".")
+ let label = if branchName="master" then "" else "-" + (if branchName="mt3" then "beta" else branchName)
+ (Version + label)
+)
+
+let InfoVersion = informationalVersion()
+let NuGetVersion = nugetVersion()
+
+
+printfn "Using version: %s" Version
+
+Target "Clean" (fun _ ->
+ ensureDirectory buildOutputPath
+ ensureDirectory buildArtifactPath
+ ensureDirectory nugetWorkingPath
+
+ CleanDir buildOutputPath
+ CleanDir buildArtifactPath
+ CleanDir nugetWorkingPath
+)
+
+Target "RestorePackages" (fun _ ->
+ "./src/Topshelf.sln"
+ |> RestoreMSSolutionPackages (fun p ->
+ { p with
+ OutputPath = packagesPath
+ Retries = 4 })
+)
+
+Target "Build" (fun _ ->
+
+ CreateCSharpAssemblyInfo @".\src\SolutionVersion.cs"
+ [ Attribute.Title "Topshelf"
+ Attribute.Description "Topshelf is an open source project for hosting services without friction. By referencing Topshelf, your console application *becomes* a service installer with a comprehensive set of command-line options for installing, configuring, and running your application as a service."
+ Attribute.Product "Topshelf"
+ Attribute.Version assemblyVersion
+ Attribute.FileVersion FileVersion
+ Attribute.InformationalVersion InfoVersion
+ Attribute.Copyright "Copyright 2012 Chris Patterson, Dru Sellers, Travis Smith, All rights reserved."
+ ]
+
+ let buildMode = getBuildParamOrDefault "buildMode" "Release"
+ let setParams defaults = {
+ defaults with
+ Verbosity = Some(Quiet)
+ Targets = ["Clean"; "Build"]
+ Properties =
+ [
+ "Optimize", "True"
+ "DebugSymbols", "True"
+ "Configuration", buildMode
+ "TargetFrameworkVersion", "v4.5.2"
+ "Platform", "Any CPU"
+ ]
+ }
+
+ build setParams @".\src\Topshelf.sln"
+ |> DoNothing
+
+ let unsignedSetParams defaults = {
+ defaults with
+ Verbosity = Some(Quiet)
+ Targets = ["Build"]
+ Properties =
+ [
+ "Optimize", "True"
+ "DebugSymbols", "True"
+ "Configuration", "ReleaseUnsigned"
+ "TargetFrameworkVersion", "v4.5.2"
+ "Platform", "Any CPU"
+ ]
+ }
+
+ build unsignedSetParams @".\src\Topshelf.sln"
+ |> DoNothing
+)
+
+let testDlls = !! ("./src/Topshelf.Tests/bin/Release/*.Tests.dll")
+
+Target "UnitTests" (fun _ ->
+ testDlls
+ |> NUnit (fun p ->
+ {p with
+ Framework = "v4.0.30319"
+ DisableShadowCopy = true;
+ OutputFile = buildArtifactPath + "/nunit-test-results.xml"})
+)
+
+type packageInfo = {
+ Project: string
+ PackageFile: string
+ Summary: string
+ Files: list<string*string option*string option>
+}
+
+Target "Package" (fun _ ->
+
+ let nugs = [| { Project = "Topshelf"
+ Summary = "Topshelf Service Library"
+ PackageFile = @".\src\Topshelf\packages.config"
+ Files = [ (@"..\src\Topshelf\bin\Release\Topshelf.*", Some @"lib\net452", None);
+ (@"..\src\Topshelf\**\*.cs", Some "src", None) ] }
+ { Project = "Topshelf.Log4Net"
+ Summary = "Topshelf Log4Net Integration."
+ PackageFile = @".\src\Topshelf.Log4Net\packages.config"
+ Files = [ (@"..\src\Topshelf.Log4Net\bin\Release\Topshelf.Log4Net.*", Some @"lib\net452", None);
+ (@"..\src\Topshelf.Log4Net\**\*.cs", Some @"src", None) ] }
+ { Project = "Topshelf.NLog"
+ Summary = "Topshelf NLog Integration."
+ PackageFile = @".\src\Topshelf.NLog\packages.config"
+ Files = [ (@"..\src\Topshelf.NLog\bin\Release\Topshelf.NLog.*", Some @"lib\net452", None);
+ (@"..\src\Topshelf.NLog\**\*.cs", Some @"src", None) ] }
+ { Project = "Topshelf.Elmah"
+ Summary = "Topshelf Elmah Integration."
+ PackageFile = @".\src\Topshelf.Elmah\packages.config"
+ Files = [ (@"..\src\Topshelf.Elmah\bin\Release\Topshelf.Elmah.*", Some @"lib\net452", None);
+ (@"..\src\Topshelf.Elmah\**\*.cs", Some @"src", None) ] }
+ { Project = "Topshelf.Serilog"
+ Summary = "Topshelf Serilog Integration."
+ PackageFile = @".\src\Topshelf.Serilog\packages.config"
+ Files = [ (@"..\src\Topshelf.Serilog\bin\Release\Topshelf.Serilog.*", Some @"lib\net452", None);
+ (@"..\src\Topshelf.Serilog\**\*.cs", Some @"src", None) ] }
+ |]
+
+ nugs
+ |> Array.iter (fun nug ->
+
+ let getDeps daNug : NugetDependencies =
+ if daNug.Project = "Topshelf" then (getDependencies daNug.PackageFile)
+ else ("Topshelf", NuGetVersion) :: (getDependencies daNug.PackageFile)
+
+ let setParams defaults = {
+ defaults with
+ Authors = ["Chris Patterson"; "Dru Sellers"; "Travis Smith"; "Brian Wilson"; "Mogens Heller Grabe"]
+ Description = "Topshelf is an open source project for hosting services without friction. By referencing Topshelf, your console application *becomes* a service installer with a comprehensive set of command-line options for installing, configuring, and running your application as a service."
+ OutputPath = buildArtifactPath
+ Project = nug.Project
+ Dependencies = (getDeps nug)
+ Summary = nug.Summary
+ SymbolPackage = NugetSymbolPackage.Nuspec
+ Version = NuGetVersion
+ WorkingDir = nugetWorkingPath
+ Files = nug.Files
+ }
+
+ NuGet setParams (FullName "./template.nuspec")
+ )
+)
+
+Target "Default" (fun _ ->
+ trace "Build starting..."
+)
+
+"Clean"
+ ==> "RestorePackages"
+ ==> "Build"
+ ==> "UnitTests"
+ ==> "Package"
+ ==> "Default"
+
+RunTargetOrDefault "Default"
@@ -1,112 +0,0 @@
-require 'erb'
-
-class NUnitRunner
- include FileTest
-
- def initialize(command, working_directory, framework, flags)
- @command = command
- @working_directory = working_directory
- @framework = framework || 'v4.0'
- @flags = flags
-
- # prepare the command
- @cmd = "#{command} /framework=#{@framework}"
- @cmd += ' ' + @flags.join(' ') unless @flags.nil?
- end
-
- def run(assemblies)
- assemblies.each do |assem|
- file = File.expand_path("#{@working_directory}/#{assem}")
- Kernel::system("#{@cmd} \"#{file}\"")
- end
- end
-end
-
-class MSBuildRunner
- def self.compile(attributes)
- build_config = attributes.fetch(:build_config)
- solutionFile = attributes[:solutionfile]
-
- attributes[:projFile] = solutionFile
- attributes[:properties] ||= []
- attributes[:properties] << "Configuration=#{build_config}"
- attributes[:extraSwitches] = ["maxcpucount:2", "v:m", "t:rebuild"]
-
- self.runProjFile(attributes);
- end
-
- def self.runProjFile(attributes)
- version = attributes.fetch(:clrversion, 'v4.0.30319')
- build_config = attributes.fetch(:build_config, 'debug')
- projFile = attributes[:projFile]
-
- frameworkDir = File.join(ENV['windir'].dup, 'Microsoft.NET', 'Framework', version)
- msbuildFile = File.join(frameworkDir, 'msbuild.exe')
-
- properties = attributes.fetch(:properties, [])
-
- switchesValue = ""
-
- properties.each do |prop|
- switchesValue += " /property:#{prop}"
- end
-
- extraSwitches = attributes.fetch(:extraSwitches, [])
-
- extraSwitches.each do |switch|
- switchesValue += " /#{switch}"
- end
-
- targets = attributes.fetch(:targets, [])
- targetsValue = ""
- targets.each do |target|
- targetsValue += " /t:#{target}"
- end
-
- Kernel::system("#{msbuildFile} #{projFile} #{targetsValue} #{switchesValue}")
- end
-end
-
-class AspNetCompilerRunner
- def self.compile(attributes)
-
- webPhysDir = attributes.fetch(:webPhysDir, '')
- webVirDir = attributes.fetch(:webVirDir, 'This_Value_Is_Not_Used')
-
- frameworkDir = File.join(ENV['windir'].dup, 'Microsoft.NET', 'Framework', 'v4.0.30319')
- aspNetCompiler = File.join(frameworkDir, 'aspnet_compiler.exe')
-
- Kernel::system("#{aspNetCompiler} -nologo -errorstack -c -p #{webPhysDir} -v #{webVirDir}")
- 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
View
@@ -1,22 +0,0 @@
-def waitfor(&block)
- checks = 0
-
- until block.call || checks >10
- sleep 0.5
- checks += 1
- end
-
- raise 'Waitfor timeout expired. Make sure that you aren\'t running something from the build output folders, or that you have browsed to it through Explorer.' if checks > 10
-end
-
-def get_commit_hash_and_date
- begin
- commit = `git log -1 --pretty=format:%H`
- git_date = `git log -1 --date=iso --pretty=format:%ad`
- commit_date = DateTime.parse( git_date ).strftime("%Y-%m-%d %H%M%S")
- rescue
- commit = "git unavailable"
- end
-
- [commit, commit_date]
-end
@@ -1,30 +0,0 @@
-require 'semver'
-
-def commit_data
- begin
- commit = `git rev-parse --short HEAD`.chomp()[0,6]
- git_date = `git log -1 --date=iso --pretty=format:%ad`
- commit_date = DateTime.parse( git_date ).strftime("%Y-%m-%d %H%M%S")
- rescue Exception => e
- puts e.inspect
- commit = (ENV['BUILD_VCS_NUMBER'] || "000000")[0,6]
- commit_date = Time.new.strftime("%Y-%m-%d %H%M%S")
- end
- [commit, commit_date]
-end
-
-task :versioning do
- ver = SemVer.find
- revision = (ENV['BUILD_NUMBER'] || ver.patch).to_i
- var = SemVer.new(ver.major, ver.minor, revision, ver.special)
-
- # extensible number w/ git hash
- ENV['BUILD_VERSION'] = BUILD_VERSION = ver.format("%M.%m.%p%s") + ".#{commit_data()[0]}"
-
- # nuget (not full semver 2.0.0-rc.1 support) see http://nuget.codeplex.com/workitem/1796
- ENV['NUGET_VERSION'] = NUGET_VERSION = ver.format("%M.%m.%p%s")
-
- # purely M.m.p format
- ENV['FORMAL_VERSION'] = FORMAL_VERSION = "#{ SemVer.new(ver.major, ver.minor, revision).format "%M.%m.%p"}"
- puts "##teamcity[buildNumber '#{BUILD_VERSION}']" # tell teamcity our decision
-end
Oops, something went wrong.

0 comments on commit fb7f016

Please sign in to comment.