class Fastlane::Actions::XamarinUpdateConfigurationAction

Constants

PLATFORM
TARGET

Public Class Methods

authors() click to toggle source
# File lib/fastlane/plugin/xamarin_build/actions/xamarin_update_configuration.rb, line 92
def self.authors
  ['punksta']
end
available_options() click to toggle source
# 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: :build_type,
                                 env_name: 'FL_XAMARIN_UPDATE_CONFIGURATION_TARGET',
                                 description: 'Target of configuration PropertyGroup',
                                 is_string: true),

    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
description() click to toggle source

@!group Documentation

# 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
details() click to toggle source
# 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) click to toggle source
# File lib/fastlane/plugin/xamarin_build/actions/xamarin_update_configuration.rb, line 96
def self.is_supported?(platform)
  platform == :ios || platform == :android
end
output() click to toggle source
# File lib/fastlane/plugin/xamarin_build/actions/xamarin_update_configuration.rb, line 85
def self.output
end
return_value() click to toggle source
# File lib/fastlane/plugin/xamarin_build/actions/xamarin_update_configuration.rb, line 88
def self.return_value
  'build artifact dir path or null if can not find it'
end
run(params) click to toggle source
# 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[:build_type]}|#{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