Class: Fastlane::Actions::XamarinBuildAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/xamarin_build/actions/xamarin_build_action.rb

Constant Summary collapse

MDTOOL =
'/Applications/Xamarin\ Studio.app/Contents/MacOS/mdtool'.freeze
TARGET_TYPES =
%w(Release Debug).freeze
[true, false].freeze

Class Method Summary collapse

Class Method Details

.authorsObject



39
40
41
# File 'lib/fastlane/plugin/xamarin_build/actions/xamarin_build_action.rb', line 39

def self.authors
  ['punksta']
end

.available_optionsObject



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
# File 'lib/fastlane/plugin/xamarin_build/actions/xamarin_build_action.rb', line 46

def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      key: :solution,
        env_name: 'FL_XAMARIN_BUILD_SOLUTION',
        description: 'path to Xamarin .sln file',
        verify_block: proc do |value|
          UI.user_error!('File not found'.red) unless File.file? value
        end
    ),

    FastlaneCore::ConfigItem.new(
      key: :platform,
      env_name: 'FL_XAMARIN_BUILD_PLATFORM',
      description: 'build platform',
      type: String
    ),

    FastlaneCore::ConfigItem.new(
      key: :target,
      env_name: 'FL_XAMARIN_BUILD_TARGET',
      description: 'Target build type',
      type: String,
      verify_block: proc do |value|
        UI.user_error!("Unsupported platform. Use one of #{TARGET_TYPES.join '\' '}".red) unless TARGET_TYPES.include? value
      end
    ),

    FastlaneCore::ConfigItem.new(
      key: :print_all,
      env_name: 'FL_XAMARIN_BUILD_PRINT_ALL',
      description: 'Print std out',
      default_value: true,
      is_string: false,
      optional: true,
      verify_block: proc do |value|
        UI.user_error!("Unsupported print all Use one of #{PRINT_ALL.join '\' '}".red) unless PRINT_ALL.include? value
      end
    )
  ]
end

.descriptionObject



35
36
37
# File 'lib/fastlane/plugin/xamarin_build/actions/xamarin_build_action.rb', line 35

def self.description
  'Build xamarin android and ios projects'
end

.get_build_path(platform, build_type, solution) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fastlane/plugin/xamarin_build/actions/xamarin_build_action.rb', line 21

def self.get_build_path(platform, build_type, solution)
  root = File.dirname(solution)

  build = Dir.glob(File.join(root, "*/bin/#{platform}/#{build_type}/"))

  if build.size > 0
    b = build[0]
    UI.message("build artifact path #{b}".blue)
    return b
  else
    return nil
  end
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


88
89
90
# File 'lib/fastlane/plugin/xamarin_build/actions/xamarin_build_action.rb', line 88

def self.is_supported?(platform)
  [:ios, :android].include?(platform)
end

.run(params) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fastlane/plugin/xamarin_build/actions/xamarin_build_action.rb', line 6

def self.run(params)
  platform = params[:platform]
  build_type = params[:target]

  configuration = "--configuration:#{build_type}|#{platform}"
  xamarin_command = "#{MDTOOL} build #{params[:solution]} \"#{configuration}\""

  Helper::XamarinBuildHelper.bash(xamarin_command, !params[:print_all])

  # it store logs in ram. Bad practive
  # FastlaneCore::CommandExecutor.execute(command: xamarin_command, print_all: params[:print_all],  print_command: true)

  get_build_path(platform, build_type, params[:solution])
end