Class: Fastlane::Actions::XamarinUpdateConfigurationAction

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

Documentation collapse

TARGET =
['Release', 'Debug', 'Ad-Hoc', 'AppStore'].freeze
PLATFORM =
%w(iPhone iPhoneSimulator AnyCPU).freeze

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



95
96
97
# File 'lib/fastlane/plugin/xamarin_build/actions/xamarin_update_configuration.rb', line 95

def self.authors
  ['punksta']
end

.available_optionsObject



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_update_configuration.rb', line 47

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :xamarin_project_file,
                                 env_name: 'FL_XAMARIN_UPDATE_CONFIGURATION_XAMARIN_PROJECT',
                                 description: 'path to xamarin .csproj project file',
                                 is_string: true,
                                 verify_block: proc do |value|
                                   UI.user_error!('Project file not found') unless File.exist? value
                                 end),

    FastlaneCore::ConfigItem.new(key: :target,
                                 env_name: 'FL_XAMARIN_UPDATE_CONFIGURATION_TARGET',
                                 description: 'Target of configuration PropertyGroup',
                                 is_string: true,
                                 verify_block: proc do |value|
                                   UI.user_error!("Unsupported target! Use one of #{TARGET}") unless TARGET.include? value
                                 end),

    FastlaneCore::ConfigItem.new(key: :platform,
                                 env_name: 'FL_XAMARIN_UPDATE_CONFIGURATION_PLATFORM',
                                 description: 'platform of configuration PropertyGroup',
                                 is_string: true,
                                 verify_block: proc do |value|
                                   UI.user_error!("Unsupported platform! use one of #{PLATFORM}") unless PLATFORM.include? value
                                 end),

    FastlaneCore::ConfigItem.new(key: :property,
                                 env_name: 'FL_XAMARIN_UPDATE_CONFIGURATION_PROPERTY',
                                 description: 'property in PropertyGroup',
                                 is_string: true),

    FastlaneCore::ConfigItem.new(key: :value,
                                 env_name: 'FL_XAMARIN_UPDATE_CONFIGURATION_VALUE',
                                 description: 'value of property',
                                 is_string: true,
                                 verify_block: proc do |value|
                                   UI.user_error!('Empty value') if value.nil?
                                 end)
  ]
end

.descriptionObject



36
37
38
# File 'lib/fastlane/plugin/xamarin_build/actions/xamarin_update_configuration.rb', line 36

def self.description
  'Set properties of specific build configuration in Xamarin configuration file'
end

.detailsObject



40
41
42
# File 'lib/fastlane/plugin/xamarin_build/actions/xamarin_update_configuration.rb', line 40

def self.details
  "You can use set properties like provision profile(CodesignProvision) and certificate name(CodesignKey)" \
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


99
100
101
# File 'lib/fastlane/plugin/xamarin_build/actions/xamarin_update_configuration.rb', line 99

def self.is_supported?(platform)
  platform == :ios || platform == :android
end

.outputObject



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

def self.output
end

.return_valueObject



91
92
93
# File 'lib/fastlane/plugin/xamarin_build/actions/xamarin_update_configuration.rb', line 91

def self.return_value
  'build artifact dir path or null if can not find it'
end

.run(params) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/fastlane/plugin/xamarin_build/actions/xamarin_update_configuration.rb', line 9

def self.run(params)
  project_path = params[:xamarin_project_file]


  file = File.new(project_path)
  doc = Nokogiri::XML(file.read)
  file.close

  configuration = "'#{params[:target]}|#{params[:platform]}'"

  doc.search('PropertyGroup').each do |group|
    next unless !group['Condition'].nil? && group['Condition'].include?(configuration)
    propery = group.search(params[:property])
    if propery.size > 0
      propery[0].content = params[:value]
    end
  end

  xml = doc.to_xml
  UI.command_output(xml) if $verbose
  File.write(project_path, xml)
end