Sha256: 7f3751d1f1f073ffcda37bbd9c578c9d09bb2b82d346a9e899347c85aa988b5f

Contents?: true

Size: 1.88 KB

Versions: 2

Compression:

Stored size: 1.88 KB

Contents

require 'albacore/app_spec'

# note: this is a Windows provider

module Albacore
  # The default is to get the bin/ folder based on the configuration that you
  # have compiled the project with.
  #
  class AppSpec::Defaults
    include ::Albacore::Logging

    # location/folder inside nuget to place everything found in the
    # #relative_dir inside
    def nuget_contents
      'bin'
    end

    # Where to copy contents from
    def source_dir app_spec, configuration = 'Release'
      File.join(app_spec.proj.proj_path_base,
                app_spec.bin_folder(configuration),
                '.').
           gsub(/\//, '\\')
    end

    # create a chocolatey install script for a topshelf service on windows
    #
    # write tools/chocolateyInstall.ps1
    def install_script out, app_spec, &block
      debug { "installing into '#{out}' [app_spec/defaults#install_script]" }
      tools = "#{out}/#{app_spec.id}/tools"

      FileUtils.mkdir tools unless Dir.exists? tools
      File.open(File.join(tools, 'chocolateyInstall.ps1'), 'w+') do |io|
        contents = embedded_resource '../../../resources/chocolateyInstall.ps1'
        io.write contents
        write_invocation app_spec, io
      end
    end

    # Get the relative resource from 'albacore/app_spec/.' as a string.
    def embedded_resource relative_path
      File.open(embedded_resource_path(relative_path), 'r') { |io| io.read }
    end

    # Get the relative resource path from 'albacore/app_spec/.'
    def embedded_resource_path relative_path
      File.join(File.dirname(File.expand_path(__FILE__)), relative_path)
    end

    def write_invocation app_spec, io
      debug { 'writing default powershell invocation [app_spec/defaults#write_invocation]' }

      io.write %{
Install-Service `
  -ServiceExeName "#{app_spec.exe}" -ServiceDir "#{app_spec.deploy_dir}" `
  -CurrentPath (Split-Path $MyInvocation.MyCommand.Path)
}
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
albacore-2.0.0.rc.20 lib/albacore/app_spec/defaults.rb
albacore-2.0.0.rc.19 lib/albacore/app_spec/defaults.rb