Class: Fastlane::Actions::MsbuildAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



58
59
60
# File 'lib/fastlane/plugin/xamarin/actions/msbuild_action.rb', line 58

def self.authors
  ["Thomas Charriere"]
end

.available_optionsObject



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/fastlane/plugin/xamarin/actions/msbuild_action.rb', line 76

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :project,
                                 env_name: "MSBUILD_SOLUTION",
                                 description: "Path to Solution (.sln) to compile",
                                 optional: false,
                                 type: String),

    FastlaneCore::ConfigItem.new(key: :target,
                                 env_name: "MSBUILD_TARGET",
                                 description: "Specifies the Build Targets: Build",
                                 default_value: 'Build',
                                 optional: true,
                                 type: String),

    FastlaneCore::ConfigItem.new(key: :configuration,
                                 env_name: "MSBUILD_CONFIGURATION",
                                 description: "Specifies the build configuration to use, such as 'Debug' or 'Release'. The Configuration property is used to determine default values for other properties which determine target behavior. Additional configurations may be created within your IDE",
                                 default_value: 'Release',
                                 optional: true,
                                 type: String),

    FastlaneCore::ConfigItem.new(key: :msbuild,
                                 env_name: "MSBUILD_MSBUILD",
                                 description: "Path to `msbuild`. Default value is found by using `which msbuild`",
                                 optional: true,
                                 type: String),

    FastlaneCore::ConfigItem.new(key: :debug_type,
                                 env_name: "MSBUILD_DEBUGTYPE",
                                 description: "Specifies the type of debug symbols to generate as part of the build, which also impacts whether the Application is debuggable. Possible values include: Full, PdbOnly",
                                 optional: true,
                                 type: String),

    FastlaneCore::ConfigItem.new(key: :define_constants,
                                 env_name: "MSBUILD_DEFINECONSTANTS",
                                 description: "Defines conditional compiler constants",
                                 optional: true,
                                 type: String)
  ]

end

.descriptionObject



54
55
56
# File 'lib/fastlane/plugin/xamarin/actions/msbuild_action.rb', line 54

def self.description
  "Build Solutions with msbuild"
end

.detailsObject



66
67
68
69
# File 'lib/fastlane/plugin/xamarin/actions/msbuild_action.rb', line 66

def self.details
  # Optional:
  "Build Solutions with msbuild"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


119
120
121
# File 'lib/fastlane/plugin/xamarin/actions/msbuild_action.rb', line 119

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

.outputObject



71
72
73
74
# File 'lib/fastlane/plugin/xamarin/actions/msbuild_action.rb', line 71

def self.output
  [
  ]
end

.return_valueObject



62
63
64
# File 'lib/fastlane/plugin/xamarin/actions/msbuild_action.rb', line 62

def self.return_value
  # If your method provides a return value, you can describe here what it does
end

.run(params) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fastlane/plugin/xamarin/actions/msbuild_action.rb', line 5

def self.run(params)
  
  msbuild = params[:msbuild] || FastlaneCore::CommandExecutor.which('msbuild')

  if msbuild.nil?
      UI.error("Could not find msbuild")
      return
  end

  if FastlaneCore::Globals.verbose?
    FastlaneCore::PrintTable.print_values(
      config: params,
      title: "Summary of parameters passed"
    )
  end        
  command = Array.new

  command.push(msbuild)
  command.push(params[:project])
  command.push("/t:#{params[:target]}")
  command.push("/p:Configuration=#{params[:configuration]}") unless params[:configuration].nil?
  command.push("/p:DefineConstants=#{params[:define_constants]}") unless params[:define_constants].nil?
  command.push("/p:DebugType=#{params[:debug_type]}") unless params[:debug_type].nil?

  if FastlaneCore::Globals.verbose?
    command.push("/v:d")
  else
    command.push("/v:m")
  end

  
  exit_status = 0
  result = FastlaneCore::CommandExecutor.execute(command: command,
                                  print_command: true,
                                  print_all: FastlaneCore::Globals.verbose?,
                                  error: proc do |error_output|
                                    exit_status = $?.exitstatus
                                    UI.error("Wups, invalid")
                                  end)

  if exit_status == 0
    UI.success("Successfully executed msbuild")
  else
    UI.error!("Unable to build - see log for more info")
  end
  

end