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



93
94
95
# File 'lib/fastlane/plugin/xamarin_build/actions/xamarin_update_configuration.rb', line 93

def self.authors
  ['punksta']
end

.available_optionsObject



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

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



34
35
36
# File 'lib/fastlane/plugin/xamarin_build/actions/xamarin_update_configuration.rb', line 34

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

.detailsObject



38
39
40
# File 'lib/fastlane/plugin/xamarin_build/actions/xamarin_update_configuration.rb', line 38

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

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


97
98
99
# File 'lib/fastlane/plugin/xamarin_build/actions/xamarin_update_configuration.rb', line 97

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

.outputObject



86
87
# File 'lib/fastlane/plugin/xamarin_build/actions/xamarin_update_configuration.rb', line 86

def self.output
end

.return_valueObject



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

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

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

  File.new(project_path) do |file|
    doc = Nokogiri::XML(file)
  end

  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

  File.write(project_path, doc.to_xml)
end