albacore 1.0.0 → 2.0.0.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -21
- data/.travis.yml +31 -12
- data/Gemfile +14 -6
- data/Guardfile +1 -3
- data/README.md +200 -47
- data/Rakefile +9 -19
- data/albacore.gemspec +33 -23
- data/lib/albacore.rb +3 -47
- data/lib/albacore/albacore_module.rb +57 -0
- data/lib/albacore/application.rb +43 -0
- data/lib/albacore/cmd_config.rb +66 -0
- data/lib/albacore/config_dsl.rb +55 -0
- data/lib/albacore/cross_platform_cmd.rb +291 -0
- data/lib/albacore/dsl.rb +90 -0
- data/lib/albacore/errors/command_failed_error.rb +11 -0
- data/lib/albacore/errors/command_not_found_error.rb +13 -0
- data/lib/albacore/errors/unfilled_property_error.rb +14 -0
- data/lib/albacore/ext/README.md +12 -0
- data/lib/albacore/ext/teamcity.rb +64 -0
- data/lib/albacore/facts.rb +25 -0
- data/lib/albacore/logging.rb +32 -0
- data/lib/albacore/nuget_model.rb +387 -0
- data/lib/albacore/paths.rb +34 -0
- data/lib/albacore/project.rb +141 -0
- data/lib/albacore/semver.rb +5 -0
- data/lib/albacore/task_types/asmver.rb +72 -0
- data/lib/albacore/task_types/asmver/cpp.rb +20 -0
- data/lib/albacore/task_types/asmver/cs.rb +17 -0
- data/lib/albacore/task_types/asmver/engine.rb +126 -0
- data/lib/albacore/task_types/asmver/file_generator.rb +45 -0
- data/lib/albacore/task_types/asmver/fs.rb +37 -0
- data/lib/albacore/task_types/asmver/vb.rb +27 -0
- data/lib/albacore/task_types/build.rb +192 -0
- data/lib/albacore/task_types/nugets_authentication.rb +9 -0
- data/lib/albacore/task_types/nugets_pack.rb +378 -0
- data/lib/albacore/task_types/nugets_restore.rb +138 -0
- data/lib/albacore/task_types/test_runner.rb +39 -0
- data/lib/albacore/tasks/README.md +16 -0
- data/lib/albacore/tasks/albasemver.rb +49 -0
- data/lib/albacore/tasks/projectlint.rb +81 -0
- data/lib/albacore/tasks/versionizer.rb +65 -0
- data/lib/albacore/tools/fluent_migrator.rb +177 -0
- data/lib/albacore/tools/restore_hint_paths.rb +112 -0
- data/lib/albacore/version.rb +3 -3
- data/spec/Rakefile +5 -0
- data/spec/albacore_spec.rb +12 -0
- data/spec/asmver_spec.rb +151 -0
- data/spec/asmver_task_spec.rb +32 -0
- data/spec/build_spec.rb +60 -0
- data/spec/config_dsl_spec.rb +83 -0
- data/spec/cross_platform_cmd_spec.rb +65 -0
- data/spec/dsl_spec.rb +39 -0
- data/spec/ext_teamcity_spec.rb +71 -0
- data/spec/facts_spec.rb +7 -0
- data/spec/nuget_model_spec.rb +401 -0
- data/spec/nugets_pack_spec.rb +231 -0
- data/spec/nugets_restore_spec.rb +55 -0
- data/spec/project_spec.rb +26 -0
- data/spec/projectlint/added_but_not_on_filesystem/aproject.csproj +29 -0
- data/spec/projectlint/correct/File.cs +1 -0
- data/spec/projectlint/correct/Image.txt +1 -0
- data/spec/projectlint/correct/MyHeavy.heavy +1 -0
- data/spec/projectlint/correct/Schema.xsd +1 -0
- data/spec/projectlint/correct/SubFolder/AnotherFile.cs +1 -0
- data/spec/projectlint/correct/aproject.csproj +29 -0
- data/spec/projectlint/on_filesystem_but_not_added/File.cs +1 -0
- data/spec/projectlint/on_filesystem_but_not_added/Image.txt +1 -0
- data/spec/projectlint/on_filesystem_but_not_added/aproject.csproj +11 -0
- data/spec/projectlint_spec.rb +77 -0
- data/spec/smoke_spec.rb +55 -0
- data/spec/spec_helper.rb +19 -20
- data/spec/support/Nuget/NuGet.exe +0 -0
- data/spec/support/echo/FSharp.Core.dll +0 -0
- data/spec/support/echo/FSharp.Core.xml +10517 -0
- data/spec/support/echo/echo.XML +12 -0
- data/spec/support/echo/echo.exe +0 -0
- data/spec/support/echo/echo.exe.config +17 -0
- data/spec/support/echo/echo.pdb +0 -0
- data/spec/support/returnstatus/FSharp.Core.dll +0 -0
- data/spec/support/returnstatus/FSharp.Core.xml +10517 -0
- data/spec/support/returnstatus/returnstatus.XML +12 -0
- data/spec/support/returnstatus/returnstatus.exe +0 -0
- data/spec/support/returnstatus/returnstatus.exe.config +17 -0
- data/spec/support/returnstatus/returnstatus.pdb +0 -0
- data/spec/support/sh_interceptor.rb +83 -0
- data/spec/testdata/.gitignore +5 -0
- data/spec/testdata/DebugProject/.gitignore +1 -0
- data/spec/testdata/DebugProject/Degbu.fsproj +57 -0
- data/spec/testdata/DebugProject/Degbu.sln +20 -0
- data/spec/testdata/DebugProject/Gemfile +1 -0
- data/spec/testdata/DebugProject/Library1.fs +4 -0
- data/spec/testdata/DebugProject/Rakefile +22 -0
- data/spec/testdata/EmptyProject/EmptyProject.csproj +39 -0
- data/spec/{assemblyinfo → testdata/EmptyProject/Properties}/AssemblyInfo.cs +5 -5
- data/spec/testdata/Gemfile +1 -0
- data/spec/testdata/NuGet.exe +0 -0
- data/spec/testdata/Project/Library1.fs +4 -0
- data/spec/testdata/Project/Project.fsproj +52 -0
- data/spec/testdata/Project/Project.sln +20 -0
- data/spec/testdata/Project/packages.config +6 -0
- data/spec/testdata/Rakefile +22 -0
- data/spec/testdata/TestingDependencies/Sample.Commands/Library.fs +6 -0
- data/spec/testdata/TestingDependencies/Sample.Commands/Sample.Commands.fsproj +78 -0
- data/spec/testdata/TestingDependencies/Sample.Commands/Script.fsx +8 -0
- data/spec/testdata/TestingDependencies/Sample.Commands/packages.config +6 -0
- data/spec/testdata/TestingDependencies/Sample.Core/Library.fs +3 -0
- data/spec/testdata/TestingDependencies/Sample.Core/Sample.Core.fsproj +59 -0
- data/spec/testdata/TestingDependencies/Sample.Core/Script.fsx +8 -0
- data/spec/testdata/TestingDependencies/Sample.Core/packages.config +4 -0
- data/spec/testdata/TestingDependencies/Sample.sln +26 -0
- data/spec/testdata/TestingDependencies/vendor/FSharp.Core.dll +0 -0
- data/spec/testdata/TestingDependencies/vendor/FSharp.Core.optdata +0 -0
- data/spec/testdata/TestingDependencies/vendor/FSharp.Core.sigdata +0 -0
- data/spec/testdata/TestingDependencies/vendor/FSharp.Core.xml +8748 -0
- data/spec/testdata/example.nuspec +14 -0
- data/spec/testdata/example.symbols.nuspec +21 -0
- data/spec/tools/fluent_migrator_spec.rb +80 -0
- metadata +303 -212
- data/.bundle/config +0 -2
- data/.rspec +0 -2
- data/CONTRIBUTING.md +0 -87
- data/LICENSE +0 -21
- data/lib/albacore/albacoretask.rb +0 -50
- data/lib/albacore/aspnetcompiler.rb +0 -80
- data/lib/albacore/assemblyinfo.rb +0 -163
- data/lib/albacore/assemblyinfolanguages/assemblyinfoengine.rb +0 -54
- data/lib/albacore/assemblyinfolanguages/cppcliengine.rb +0 -18
- data/lib/albacore/assemblyinfolanguages/csharpengine.rb +0 -15
- data/lib/albacore/assemblyinfolanguages/fsharpengine.rb +0 -23
- data/lib/albacore/assemblyinfolanguages/vbnetengine.rb +0 -15
- data/lib/albacore/config/aspnetcompilerconfig.rb +0 -30
- data/lib/albacore/config/assemblyinfoconfig.rb +0 -18
- data/lib/albacore/config/config.rb +0 -22
- data/lib/albacore/config/cscconfig.rb +0 -28
- data/lib/albacore/config/docuconfig.rb +0 -19
- data/lib/albacore/config/execconfig.rb +0 -19
- data/lib/albacore/config/fluentmigratorconfig.rb +0 -19
- data/lib/albacore/config/ilmergeconfig.rb +0 -19
- data/lib/albacore/config/msbuildconfig.rb +0 -29
- data/lib/albacore/config/mspecconfig.rb +0 -19
- data/lib/albacore/config/mstestconfig.rb +0 -19
- data/lib/albacore/config/nantconfig.rb +0 -18
- data/lib/albacore/config/nchurnconfig.rb +0 -19
- data/lib/albacore/config/ncoverconsoleconfig.rb +0 -19
- data/lib/albacore/config/ncoverreportconfig.rb +0 -18
- data/lib/albacore/config/ndependconfig.rb +0 -19
- data/lib/albacore/config/netversion.rb +0 -28
- data/lib/albacore/config/nugetinstallconfig.rb +0 -18
- data/lib/albacore/config/nugetpackconfig.rb +0 -18
- data/lib/albacore/config/nugetpushconfig.rb +0 -18
- data/lib/albacore/config/nugetupdateconfig.rb +0 -18
- data/lib/albacore/config/nunitconfig.rb +0 -19
- data/lib/albacore/config/nuspecconfig.rb +0 -18
- data/lib/albacore/config/plinkconfig.rb +0 -18
- data/lib/albacore/config/specflowconfig.rb +0 -18
- data/lib/albacore/config/sqlcmdconfig.rb +0 -18
- data/lib/albacore/config/unzipconfig.rb +0 -19
- data/lib/albacore/config/xbuildconfig.rb +0 -18
- data/lib/albacore/config/xunitconfig.rb +0 -18
- data/lib/albacore/config/zipdirectoryconfig.rb +0 -18
- data/lib/albacore/csc.rb +0 -77
- data/lib/albacore/docu.rb +0 -38
- data/lib/albacore/exec.rb +0 -20
- data/lib/albacore/fluentmigrator.rb +0 -69
- data/lib/albacore/ilmerge.rb +0 -38
- data/lib/albacore/msbuild.rb +0 -55
- data/lib/albacore/mspec.rb +0 -39
- data/lib/albacore/mstest.rb +0 -47
- data/lib/albacore/nant.rb +0 -41
- data/lib/albacore/nchurn.rb +0 -49
- data/lib/albacore/ncoverconsole.rb +0 -56
- data/lib/albacore/ncoverreport.rb +0 -40
- data/lib/albacore/ncoverreports.rb +0 -16
- data/lib/albacore/ncoverreports/assemblyfilter.rb +0 -10
- data/lib/albacore/ncoverreports/branchcoverage.rb +0 -10
- data/lib/albacore/ncoverreports/classfilter.rb +0 -9
- data/lib/albacore/ncoverreports/codecoveragebase.rb +0 -27
- data/lib/albacore/ncoverreports/cyclomaticcomplexity.rb +0 -23
- data/lib/albacore/ncoverreports/documentfilter.rb +0 -9
- data/lib/albacore/ncoverreports/fullcoveragereport.rb +0 -9
- data/lib/albacore/ncoverreports/methodcoverage.rb +0 -10
- data/lib/albacore/ncoverreports/methodfilter.rb +0 -9
- data/lib/albacore/ncoverreports/namespacefilter.rb +0 -9
- data/lib/albacore/ncoverreports/reportbase.rb +0 -23
- data/lib/albacore/ncoverreports/reportfilterbase.rb +0 -29
- data/lib/albacore/ncoverreports/summaryreport.rb +0 -9
- data/lib/albacore/ncoverreports/symbolcoverage.rb +0 -9
- data/lib/albacore/ndepend.rb +0 -33
- data/lib/albacore/nugetinstall.rb +0 -62
- data/lib/albacore/nugetpack.rb +0 -50
- data/lib/albacore/nugetpush.rb +0 -40
- data/lib/albacore/nugetupdate.rb +0 -50
- data/lib/albacore/nunit.rb +0 -46
- data/lib/albacore/nuspec.rb +0 -180
- data/lib/albacore/output.rb +0 -105
- data/lib/albacore/plink.rb +0 -50
- data/lib/albacore/specflow.rb +0 -30
- data/lib/albacore/sqlcmd.rb +0 -67
- data/lib/albacore/support/attrmethods.rb +0 -33
- data/lib/albacore/support/createtask.rb +0 -50
- data/lib/albacore/support/failure.rb +0 -15
- data/lib/albacore/support/logging.rb +0 -38
- data/lib/albacore/support/openstruct.rb +0 -13
- data/lib/albacore/support/platform.rb +0 -25
- data/lib/albacore/support/runcommand.rb +0 -45
- data/lib/albacore/support/updateattributes.rb +0 -13
- data/lib/albacore/support/yamlconfig.rb +0 -18
- data/lib/albacore/unzip.rb +0 -42
- data/lib/albacore/xbuild.rb +0 -41
- data/lib/albacore/xunit.rb +0 -44
- data/lib/albacore/zipdirectory.rb +0 -106
- data/spec/albacoremodel_spec.rb +0 -52
- data/spec/aspnetcompiler_spec.rb +0 -84
- data/spec/assemblyinfo_spec.rb +0 -209
- data/spec/attrmethods_spec.rb +0 -135
- data/spec/config_spec.rb +0 -32
- data/spec/createtask_spec.rb +0 -234
- data/spec/csc_spec.rb +0 -86
- data/spec/docu_spec.rb +0 -31
- data/spec/exec_spec.rb +0 -25
- data/spec/fluentmigrator_spec.rb +0 -88
- data/spec/ilmerge_spec.rb +0 -35
- data/spec/msbuild_spec.rb +0 -55
- data/spec/mspec_spec.rb +0 -30
- data/spec/mstest_spec.rb +0 -35
- data/spec/nant_spec.rb +0 -40
- data/spec/nchurn_spec.rb +0 -80
- data/spec/ncoverconsole_spec.rb +0 -80
- data/spec/ncoverreport_spec.rb +0 -139
- data/spec/ndepend_spec.rb +0 -26
- data/spec/netversion_spec.rb +0 -51
- data/spec/nugetinstall_spec.rb +0 -59
- data/spec/nugetpack_spec.rb +0 -49
- data/spec/nugetpush_spec.rb +0 -39
- data/spec/nugetupdate_spec.rb +0 -49
- data/spec/nunit_spec.rb +0 -35
- data/spec/nuspec/nuspec.xsd +0 -84
- data/spec/nuspec_spec.rb +0 -74
- data/spec/output/bar/bar.txt +0 -0
- data/spec/output/baz.txt +0 -0
- data/spec/output/erb.txt +0 -1
- data/spec/output/foo/foo/foo.txt +0 -0
- data/spec/output_spec.rb +0 -85
- data/spec/patch/system_patch.rb +0 -12
- data/spec/platform_spec.rb +0 -15
- data/spec/plink_spec.rb +0 -56
- data/spec/runcommand_spec.rb +0 -92
- data/spec/specflow_spec.rb +0 -30
- data/spec/sqlcmd_spec.rb +0 -66
- data/spec/unzip_spec.rb +0 -56
- data/spec/xbuild_spec.rb +0 -40
- data/spec/xunit_spec.rb +0 -30
- data/spec/yaml/test.yml +0 -3
- data/spec/yamlconfig_spec.rb +0 -53
- data/spec/zip/baz.txt +0 -0
- data/spec/zip/foo/bar/bar.txt +0 -0
- data/spec/zip/foo/foo.txt +0 -0
- data/spec/zip_spec.rb +0 -97
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'albacore/task_types/asmver/engine'
|
2
|
+
|
3
|
+
module Albacore::Asmver
|
4
|
+
class Fs < Engine
|
5
|
+
def initialize
|
6
|
+
@using = "open"
|
7
|
+
@start_token = "[<"
|
8
|
+
@end_token = ">]"
|
9
|
+
@assignment = "="
|
10
|
+
@statement_terminator = ""
|
11
|
+
end
|
12
|
+
|
13
|
+
def build_attribute_re(attr_name)
|
14
|
+
/^\[\<assembly: #{attr_name}(.+)/
|
15
|
+
end
|
16
|
+
|
17
|
+
# namespaces
|
18
|
+
|
19
|
+
def namespace_start ns
|
20
|
+
"namespace #{ns}"
|
21
|
+
end
|
22
|
+
|
23
|
+
def namespace_end
|
24
|
+
"()\n"
|
25
|
+
end
|
26
|
+
|
27
|
+
# comments
|
28
|
+
|
29
|
+
def comment_multiline_start
|
30
|
+
'(*'
|
31
|
+
end
|
32
|
+
|
33
|
+
def comment_multiline_end
|
34
|
+
'*)'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'albacore/task_types/asmver/engine'
|
2
|
+
|
3
|
+
module Albacore::Asmver
|
4
|
+
class Vb < Engine
|
5
|
+
def initialize
|
6
|
+
@using = "Imports"
|
7
|
+
@start_token = "<"
|
8
|
+
@end_token = ">"
|
9
|
+
@assignment = ":="
|
10
|
+
@statement_terminator = ""
|
11
|
+
end
|
12
|
+
|
13
|
+
def build_attribute_re(attr_name)
|
14
|
+
/^\<assembly: #{attr_name}(.+)/i
|
15
|
+
end
|
16
|
+
|
17
|
+
# override
|
18
|
+
def comment_singleline_token
|
19
|
+
'\''
|
20
|
+
end
|
21
|
+
|
22
|
+
# override
|
23
|
+
def build_multiline_comment string_data
|
24
|
+
string_data.split(NL).map { |s| "' " + s }.join("\n")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,192 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'rake'
|
4
|
+
require 'albacore/paths'
|
5
|
+
require 'albacore/cmd_config'
|
6
|
+
require 'albacore/cross_platform_cmd'
|
7
|
+
require 'albacore/logging'
|
8
|
+
require 'albacore/facts'
|
9
|
+
|
10
|
+
module Albacore
|
11
|
+
module Build
|
12
|
+
class Cmd
|
13
|
+
include CrossPlatformCmd
|
14
|
+
def initialize work_dir, executable, parameters
|
15
|
+
@work_dir = work_dir
|
16
|
+
@executable = executable
|
17
|
+
@parameters = (parameters === Array) ? parameters : parameters.to_a
|
18
|
+
end
|
19
|
+
def execute
|
20
|
+
system @executable, @parameters, :work_dir => @work_dir
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# The configuration class for xbuild and msbuild. MSDN docs at: http://msdn.microsoft.com/en-us/library/vstudio/ms164311.aspx
|
25
|
+
class Config
|
26
|
+
include CmdConfig
|
27
|
+
self.extend ConfigDSL
|
28
|
+
include Logging
|
29
|
+
|
30
|
+
# TODO: move towards #opts() for all task types rather than
|
31
|
+
# reading these public properties.
|
32
|
+
|
33
|
+
# this is the target of the compilation with MsBuild/XBuild
|
34
|
+
attr_reader :target
|
35
|
+
|
36
|
+
# any properties you want to set
|
37
|
+
attr_accessor :properties
|
38
|
+
|
39
|
+
def initialize
|
40
|
+
@parameters = Set.new
|
41
|
+
|
42
|
+
w = lambda { |e| CrossPlatformCmd.which(e) ? e : nil }
|
43
|
+
|
44
|
+
@exe = w.call( "msbuild" ) ||
|
45
|
+
w.call( "xbuild" ) ||
|
46
|
+
heuristic_executable
|
47
|
+
|
48
|
+
debug { "build using '#{@exe}'" }
|
49
|
+
set_logging 'minimal'
|
50
|
+
end
|
51
|
+
|
52
|
+
# this is the solution file to build (or the project files themselves)
|
53
|
+
attr_path_accessor :sln, :file do |val|
|
54
|
+
@parameters.add val
|
55
|
+
end
|
56
|
+
|
57
|
+
# Call for each target that you want to add, or pass an array or
|
58
|
+
# strings. Only unique targets will be passed to MsBuild.
|
59
|
+
#
|
60
|
+
# From MSDN:
|
61
|
+
#
|
62
|
+
# "Build the specified targets in the project. Specify each target separately, or use a semicolon or comma to separate multiple targets, as the following example shows:
|
63
|
+
# /target:Resources;Compile
|
64
|
+
# If you specify any targets by using this switch, they are run instead of any targets in the DefaultTargets attribute in the project file. For more information, see Target Build Order (http://msdn.microsoft.com/en-us/library/vstudio/ee216359.aspx) and How to: Specify Which Target to Build First (http://msdn.microsoft.com/en-us/library/vstudio/ms171463.aspx).
|
65
|
+
# A target is a group of tasks. For more information, see MSBuild Targets (http://msdn.microsoft.com/en-us/library/vstudio/ms171462.aspx)."
|
66
|
+
#
|
67
|
+
# t :: the array or string target to add to the list of tarets to build
|
68
|
+
attr_path_accessor :target do |t|
|
69
|
+
update_array_prop "target", method(:make_target), :targets, t
|
70
|
+
end
|
71
|
+
|
72
|
+
# Allows you to add properties to MsBuild; example:
|
73
|
+
#
|
74
|
+
# b.prop 'WarningLevel', 2
|
75
|
+
# b.prop 'BuildVersion', '3.5.0'
|
76
|
+
#
|
77
|
+
# From MSDN:
|
78
|
+
#
|
79
|
+
# "Set or override the specified project-level properties, where name is the property name and value is the property value. Specify each property separately, or use a semicolon or comma to separate multiple properties, as the following example shows:
|
80
|
+
# /property:WarningLevel=2;OutputDir=bin\Debug"
|
81
|
+
#
|
82
|
+
# The properties will be automatically converted to the correct syntax
|
83
|
+
def prop k, v
|
84
|
+
@properties ||= Hash.new
|
85
|
+
@parameters.delete "/property:#{make_props}" if @properties.any?
|
86
|
+
@properties[k] = v
|
87
|
+
@parameters.add "/property:#{make_props}"
|
88
|
+
end
|
89
|
+
|
90
|
+
# Specifies the amount of information to display in the build log.
|
91
|
+
# Each logger displays events based on the verbosity level that you set for that logger.
|
92
|
+
# You can specify the following verbosity levels: q[uiet], m[inimal],
|
93
|
+
# n[ormal], d[etailed], and diag[nostic].
|
94
|
+
attr_path_accessor :logging do |mode|
|
95
|
+
set_logging mode
|
96
|
+
end
|
97
|
+
|
98
|
+
# Specifies the number of parallel worker processes to build with
|
99
|
+
# Defaults to the number of logical cores
|
100
|
+
attr_path_accessor :cores do |num|
|
101
|
+
@parameters.add "/maxcpucount:#{num}"
|
102
|
+
end
|
103
|
+
|
104
|
+
# Pass the parameters that you specify to the console logger, which displays build information in the console window. You can specify the following parameters:
|
105
|
+
# * PerformanceSummary. Show the time that’s spent in tasks, targets, and projects.
|
106
|
+
# * Summary. Show the error and warning summary at the end.
|
107
|
+
# * NoSummary. Don't show the error and warning summary at the end.
|
108
|
+
# * ErrorsOnly. Show only errors.
|
109
|
+
# * WarningsOnly. Show only warnings.
|
110
|
+
# * NoItemAndPropertyList. Don't show the list of items and properties that would appear at the start of each project build if the verbosity level is set to diagnostic.
|
111
|
+
# * ShowCommandLine. Show TaskCommandLineEvent messages.
|
112
|
+
# * ShowTimestamp. Show the timestamp as a prefix to any message.
|
113
|
+
# * ShowEventId. Show the event ID for each started event, finished event, and message.
|
114
|
+
# * ForceNoAlign. Don't align the text to the size of the console buffer.
|
115
|
+
# * DisableConsoleColor. Use the default console colors for all logging messages.
|
116
|
+
# * DisableMPLogging. Disable the multiprocessor logging style of output when running in non-multiprocessor mode.
|
117
|
+
# * EnableMPLogging. Enable the multiprocessor logging style even when running in non-multiprocessor mode. This logging style is on by default.
|
118
|
+
# * Verbosity. Override the /verbosity setting for this logger.
|
119
|
+
def clp param
|
120
|
+
update_array_prop "consoleloggerparameters", method(:make_clp), :clp, param
|
121
|
+
end
|
122
|
+
|
123
|
+
# Set logging verbosity to quiet
|
124
|
+
def be_quiet
|
125
|
+
logging = "quiet"
|
126
|
+
end
|
127
|
+
|
128
|
+
# Don't display the startup banner or the copyright message.
|
129
|
+
def nologo
|
130
|
+
@parameters.add "/nologo"
|
131
|
+
end
|
132
|
+
|
133
|
+
private
|
134
|
+
def set_logging mode
|
135
|
+
modes = %w{quiet minimal normal detailed diagnostic}.collect{ |m| "/verbosity:#{m}" }
|
136
|
+
@parameters.subtract modes
|
137
|
+
@parameters.add "/verbosity:#{mode}"
|
138
|
+
end
|
139
|
+
|
140
|
+
def update_array_prop prop_name, callable_prop_val, field_sym, value
|
141
|
+
field = :"@#{field_sym}"
|
142
|
+
# @targets ||= []
|
143
|
+
instance_variable_set field, [] unless instance_variable_defined? field
|
144
|
+
# parameters.delete "/target:#{make_target}" if @targets.any?
|
145
|
+
@parameters.delete "/#{prop_name}:#{callable_prop_val.call}" if
|
146
|
+
instance_variable_get(field).any?
|
147
|
+
if value.respond_to? 'each'
|
148
|
+
value.each { |v| instance_variable_get(field) << v }
|
149
|
+
else
|
150
|
+
instance_variable_get(field) << value
|
151
|
+
end
|
152
|
+
instance_variable_get(field).uniq!
|
153
|
+
# @parameters.add "/target:#{make_target}"
|
154
|
+
@parameters.add "/#{prop_name}:#{callable_prop_val.call}"
|
155
|
+
end
|
156
|
+
|
157
|
+
def make_target
|
158
|
+
@targets.join(';')
|
159
|
+
end
|
160
|
+
|
161
|
+
def make_props
|
162
|
+
@properties.collect { |k, v|
|
163
|
+
"#{k}=#{v}"
|
164
|
+
}.join(';')
|
165
|
+
end
|
166
|
+
|
167
|
+
def make_clp
|
168
|
+
@clp.join(';')
|
169
|
+
end
|
170
|
+
|
171
|
+
def heuristic_executable
|
172
|
+
if ::Rake::Win32.windows?
|
173
|
+
trace 'build tasktype finding msbuild.exe'
|
174
|
+
%w{v4.0.30319 v4.0 v3.5 v2.0}.collect { |fw_ver|
|
175
|
+
msb = File.join ENV['WINDIR'], 'Microsoft.NET', 'Framework', fw_ver, 'msbuild.exe'
|
176
|
+
CrossPlatformCmd.which(msb) ? msb : nil
|
177
|
+
}.first
|
178
|
+
else
|
179
|
+
nil
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
class Task
|
184
|
+
def initialize command_line
|
185
|
+
@command_line = command_line
|
186
|
+
end
|
187
|
+
def execute
|
188
|
+
@command_line.execute
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
@@ -0,0 +1,378 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'albacore'
|
5
|
+
require 'albacore/paths'
|
6
|
+
require 'albacore/cmd_config'
|
7
|
+
require 'albacore/config_dsl'
|
8
|
+
require 'albacore/cross_platform_cmd'
|
9
|
+
require 'albacore/project'
|
10
|
+
require 'albacore/logging'
|
11
|
+
require 'albacore/nuget_model'
|
12
|
+
|
13
|
+
module Albacore
|
14
|
+
module NugetsPack
|
15
|
+
# the nuget command
|
16
|
+
class Cmd
|
17
|
+
include CrossPlatformCmd
|
18
|
+
|
19
|
+
# executable => the nuget executable
|
20
|
+
def initialize executable, *args
|
21
|
+
opts = Map.options args
|
22
|
+
raise ArgumentError, 'out is nil' if opts.getopt(:out).nil?
|
23
|
+
|
24
|
+
@work_dir = opts.getopt :work_dir, default: nil
|
25
|
+
@executable = executable
|
26
|
+
@parameters = [%W{Pack -OutputDirectory #{opts.get(:out)}}].flatten
|
27
|
+
@opts = opts
|
28
|
+
|
29
|
+
mono_command
|
30
|
+
end
|
31
|
+
|
32
|
+
# run nuget on the nuspec to create a new package
|
33
|
+
# returns: a tuple-array of the package and the symbol package
|
34
|
+
# of which the symbol package is nil if it was not generated
|
35
|
+
def execute nuspec_file, nuspec_symbols_file = nil
|
36
|
+
debug "NugetsPack::Cmd#execute, opts: #{@opts} [nugets pack: cmd]"
|
37
|
+
original_pars = @parameters.dup
|
38
|
+
|
39
|
+
pars = original_pars.dup
|
40
|
+
pars << nuspec_file
|
41
|
+
pkg = get_nuget_path_of do
|
42
|
+
system @executable, pars, :work_dir => @work_dir
|
43
|
+
end
|
44
|
+
|
45
|
+
debug "package at '#{pkg}'"
|
46
|
+
|
47
|
+
# if the symbols flag is set and there's a symbols file specified
|
48
|
+
# then run NuGet.exe to generate the .symbols.nupkg file
|
49
|
+
if nuspec_symbols_file
|
50
|
+
pars = original_pars.dup
|
51
|
+
pars << '-Symbols'
|
52
|
+
pars << nuspec_symbols_file
|
53
|
+
spkg = with_subterfuge pkg do
|
54
|
+
get_nuget_path_of do
|
55
|
+
system @executable, pars, :work_dir => @work_dir
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
debug "symbol package at '#{spkg}'"
|
60
|
+
|
61
|
+
[pkg, spkg]
|
62
|
+
else
|
63
|
+
info "symbols not configured for generation, use Config#gen_symbols to do so [nugets pack: cmd]"
|
64
|
+
[pkg, nil]
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
# regexpes the package path from the output
|
71
|
+
def get_nuget_path_of
|
72
|
+
out = yield
|
73
|
+
out.match /Successfully created package '([:\s\w\\\/\d\.]+\.symbols\.nupkg)'./i if out.respond_to? :match
|
74
|
+
trace "Got symbols return value: '#{out}', matched: '#{$1}'" if $1
|
75
|
+
return $1 if $1
|
76
|
+
|
77
|
+
out.match /Successfully created package '([:\s\w\\\/\d\.]+\.nupkg)'./i if out.respond_to? :match
|
78
|
+
trace "Got NOT-symbols return value: '#{out}', matched: '#{$1}'"
|
79
|
+
$1
|
80
|
+
end
|
81
|
+
|
82
|
+
# hide the original like a ninja while NuGet whimpers in a corner
|
83
|
+
def with_subterfuge pkg
|
84
|
+
FileUtils.mv pkg, "#{pkg}.tmp" if pkg && File.exists?(pkg)
|
85
|
+
res = yield
|
86
|
+
FileUtils.mv "#{pkg}.tmp", pkg if pkg && File.exists?("#{pkg}.tmp")
|
87
|
+
res
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# This tasktype allows you to quickly package project files to nuget
|
92
|
+
# packages.
|
93
|
+
#
|
94
|
+
# Point files to the project files, that should be in MsBuild XML.
|
95
|
+
#
|
96
|
+
# Examples
|
97
|
+
#
|
98
|
+
# nugets_pack :pack => ['build/pkg', :versioning] do |p|
|
99
|
+
# p.files = FileList['src/**/*.csproj']
|
100
|
+
# p.out = 'build/pkg'
|
101
|
+
# p.exe = 'buildsupport/NuGet.exe'
|
102
|
+
# p.version = ENV['NUGET_VERSION']
|
103
|
+
# p.gen_symbols
|
104
|
+
# end
|
105
|
+
class Config
|
106
|
+
include CmdConfig
|
107
|
+
self.extend ConfigDSL
|
108
|
+
|
109
|
+
# the output directory to place the newfangled nugets in
|
110
|
+
attr_path :out
|
111
|
+
|
112
|
+
# the .net target (e.g. net40, mono2.0)
|
113
|
+
attr_writer :target
|
114
|
+
|
115
|
+
# sets the files to search
|
116
|
+
attr_writer :files
|
117
|
+
|
118
|
+
# sets the MsBuild configuration that is used to produce the output into
|
119
|
+
# <OutputPath>...</OutputPath>
|
120
|
+
attr_writer :configuration
|
121
|
+
|
122
|
+
def initialize
|
123
|
+
@package = Albacore::NugetModel::Package.new
|
124
|
+
@target = 'net40'
|
125
|
+
@symbols = false
|
126
|
+
fill_required
|
127
|
+
end
|
128
|
+
|
129
|
+
def with_metadata &block
|
130
|
+
yield @package.metadata
|
131
|
+
end
|
132
|
+
|
133
|
+
# configure the package with a block
|
134
|
+
def with_package &block
|
135
|
+
yield @package
|
136
|
+
end
|
137
|
+
|
138
|
+
# generate symbols for the nugets: just call this method to
|
139
|
+
# enable generation
|
140
|
+
def gen_symbols
|
141
|
+
@symbols = true
|
142
|
+
end
|
143
|
+
|
144
|
+
# gets the options specified for the task, used from the task
|
145
|
+
def opts
|
146
|
+
files = @files.respond_to?(:each) ? @files : [@files]
|
147
|
+
|
148
|
+
[:authors, :description, :version].each do |required|
|
149
|
+
warn "metadata##{required} is missing from nugets_pack [nugets pack: config]" if @package.metadata.send(required) == 'MISSING'
|
150
|
+
end
|
151
|
+
|
152
|
+
Map.new({
|
153
|
+
:out => @out,
|
154
|
+
:exe => @exe,
|
155
|
+
:symbols => @symbols,
|
156
|
+
:package => @package,
|
157
|
+
:target => @target,
|
158
|
+
:files => @files,
|
159
|
+
:configuration => @configuration,
|
160
|
+
:original_path => FileUtils.pwd
|
161
|
+
})
|
162
|
+
end
|
163
|
+
|
164
|
+
private
|
165
|
+
|
166
|
+
def fill_required
|
167
|
+
# see http://docs.nuget.org/docs/reference/nuspec-reference
|
168
|
+
with_metadata do |m|
|
169
|
+
m.authors = m.description = m.version = 'MISSING'
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
# a task that handles the generation of nugets from projects or nuspecs.
|
175
|
+
class ProjectTask
|
176
|
+
include Logging
|
177
|
+
|
178
|
+
def initialize opts, &before_execute
|
179
|
+
raise ArgumentError, 'opts is not a map' unless opts.is_a? Map
|
180
|
+
raise ArgumentError, 'no files given' unless opts.get(:files).length > 0
|
181
|
+
@opts = opts.apply :out => '.'
|
182
|
+
@files = opts.get :files
|
183
|
+
@before_execute = before_execute
|
184
|
+
end
|
185
|
+
|
186
|
+
def execute
|
187
|
+
knowns = compute_knowns
|
188
|
+
@files.each do |p|
|
189
|
+
proj, n, ns = generate_nuspec p, knowns
|
190
|
+
execute_inner! proj, n, ns
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
def path_to relative_file_path, cwd
|
195
|
+
File.expand_path( File.join(@opts.get(:original_path), relative_file_path), cwd )
|
196
|
+
end
|
197
|
+
|
198
|
+
# generate all nuspecs
|
199
|
+
def generate_nuspecs
|
200
|
+
nuspecs = {}
|
201
|
+
knowns = compute_knowns
|
202
|
+
@files.each do |p|
|
203
|
+
proj, n, ns = generate_nuspec p, knowns
|
204
|
+
nuspecs[proj.name] = OpenStruct.new({:proj => proj, :nuspec => n, :nuspec_symbols => ns })
|
205
|
+
end
|
206
|
+
nuspecs
|
207
|
+
end
|
208
|
+
|
209
|
+
private
|
210
|
+
|
211
|
+
def compute_knowns
|
212
|
+
Set.new(@files.map { |f| Albacore::Project.new f }.map { |p| p.name })
|
213
|
+
end
|
214
|
+
|
215
|
+
def generate_nuspec p, knowns
|
216
|
+
proj = Albacore::Project.new p
|
217
|
+
nuspec, nuspec_symbols = create_nuspec proj, knowns
|
218
|
+
[proj, nuspec, nuspec_symbols]
|
219
|
+
end
|
220
|
+
|
221
|
+
# execute, for each project file
|
222
|
+
def execute_inner! proj, nuspec, nuspec_symbols
|
223
|
+
nuspec_path = write_nuspec! proj, nuspec, false
|
224
|
+
nuspec_symbols_path = write_nuspec! proj, nuspec_symbols, true if nuspec_symbols
|
225
|
+
|
226
|
+
create_nuget! proj.proj_path_base, nuspec_path, nuspec_symbols_path
|
227
|
+
rescue => e
|
228
|
+
err (e.inspect)
|
229
|
+
raise $!
|
230
|
+
ensure
|
231
|
+
trace do
|
232
|
+
%{
|
233
|
+
PROJECT #{proj.name} nuspec:
|
234
|
+
|
235
|
+
#{nuspec.to_xml}
|
236
|
+
|
237
|
+
PROJECT #{proj.name} symbol nuspec:
|
238
|
+
|
239
|
+
#{if nuspec_symbols then nuspec_symbols.to_xml else 'NO SYMBOLS' end}}
|
240
|
+
end
|
241
|
+
|
242
|
+
# now remove them all
|
243
|
+
[nuspec_path, nuspec_symbols_path].each{|n| cleanup_nuspec n}
|
244
|
+
end
|
245
|
+
|
246
|
+
## Creating
|
247
|
+
|
248
|
+
def create_nuspec proj, knowns
|
249
|
+
version = @opts.get(:package).metadata.version
|
250
|
+
|
251
|
+
trace "creating NON-SYMBOL package for #{proj.name} [nugets pack: task]"
|
252
|
+
nuspec = Albacore::NugetModel::Package.from_xxproj proj,
|
253
|
+
symbols: false,
|
254
|
+
verify_files: true,
|
255
|
+
known_projects: knowns,
|
256
|
+
version: version,
|
257
|
+
configuration: (@opts.get(:configuration))
|
258
|
+
|
259
|
+
# take data from package as configured in Rakefile, choosing what is in
|
260
|
+
# Rakefile over what is in projfile.
|
261
|
+
nuspec = nuspec.merge_with @opts.get(:package)
|
262
|
+
trace { "nuspec: #{nuspec.to_s} [nugets pack: task]" }
|
263
|
+
|
264
|
+
if @opts.get(:symbols)
|
265
|
+
trace { "creating SYMBOL package for #{proj.name} [nugets pack: task]" }
|
266
|
+
nuspec_symbols = Albacore::NugetModel::Package.from_xxproj proj,
|
267
|
+
symbols: true,
|
268
|
+
verify_files: true,
|
269
|
+
known_projects: knowns,
|
270
|
+
version: version,
|
271
|
+
configuration: (@opts.get(:configuration))
|
272
|
+
|
273
|
+
nuspec_symbols = nuspec_symbols.merge_with @opts.get(:package)
|
274
|
+
trace { "nuspec symbols: #{nuspec_symbols.to_s} [nugets pack: task]" }
|
275
|
+
|
276
|
+
[nuspec, nuspec_symbols]
|
277
|
+
else
|
278
|
+
trace { "skipping SYMBOL package for #{proj.name} [nugets pack: task]" }
|
279
|
+
[nuspec, nil]
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
def write_nuspec! proj, nuspec, symbols
|
284
|
+
nuspec_path = File.join(proj.proj_path_base, nuspec.metadata.id + "#{ symbols ? '.symbols' : '' }.nuspec")
|
285
|
+
|
286
|
+
File.write(nuspec_path, nuspec.to_xml)
|
287
|
+
|
288
|
+
nuspec_path
|
289
|
+
end
|
290
|
+
|
291
|
+
def create_nuget! cwd, nuspec, nuspec_symbols = nil
|
292
|
+
# create the command
|
293
|
+
exe = path_to(@opts.get(:exe), cwd)
|
294
|
+
out = path_to(@opts.get(:out), cwd)
|
295
|
+
nuspec = path_to nuspec, cwd
|
296
|
+
nuspec_symbols = path_to nuspec_symbols, cwd if nuspec_symbols
|
297
|
+
cmd = Albacore::NugetsPack::Cmd.new exe,
|
298
|
+
work_dir: cwd,
|
299
|
+
out: out
|
300
|
+
|
301
|
+
# run any concerns that modify the command
|
302
|
+
@before_execute.call cmd if @before_execute
|
303
|
+
|
304
|
+
debug { "generating nuspec at #{nuspec}, and symbols (possibly) at '#{nuspec_symbols}' [nugets pack: task]" }
|
305
|
+
|
306
|
+
# run the command for the file
|
307
|
+
pkg, spkg = cmd.execute nuspec, nuspec_symbols
|
308
|
+
|
309
|
+
publish_artifact nuspec, pkg
|
310
|
+
publish_artifact nuspec_symbols, spkg if spkg && nuspec_symbols
|
311
|
+
end
|
312
|
+
|
313
|
+
## Cleaning up after generation
|
314
|
+
|
315
|
+
def cleanup_nuspec nuspec
|
316
|
+
return if nuspec.nil? or not File.exists? nuspec
|
317
|
+
File.delete nuspec
|
318
|
+
end
|
319
|
+
|
320
|
+
def publish_artifact nuspec, nuget
|
321
|
+
Albacore.publish :artifact, OpenStruct.new(
|
322
|
+
:nuspec => nuspec,
|
323
|
+
:nupkg => nuget,
|
324
|
+
:location => nuget
|
325
|
+
)
|
326
|
+
end
|
327
|
+
|
328
|
+
def self.accept? f
|
329
|
+
File.extname(f).downcase != '.nuspec'
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
# generate a nuget from a nuspec
|
334
|
+
class NuspecTask
|
335
|
+
include Logging
|
336
|
+
|
337
|
+
def initialize command_line, config, nuspec
|
338
|
+
@config = config
|
339
|
+
@nuspec = nuspec
|
340
|
+
# is a NuspecPack::Cmd
|
341
|
+
@command_line = command_line
|
342
|
+
end
|
343
|
+
|
344
|
+
def read_version_from_nuspec
|
345
|
+
begin
|
346
|
+
nuspec_file = File.open(@nuspec)
|
347
|
+
xml = Nokogiri::XML(nuspec_file)
|
348
|
+
nuspec_file.close
|
349
|
+
nodes = xml.xpath('.//metadata/version')
|
350
|
+
raise "No <version/> found" if nodes.empty?
|
351
|
+
nodes.first.text()
|
352
|
+
rescue => error
|
353
|
+
err "Error reading package version from file: #{error}"
|
354
|
+
raise
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
358
|
+
def execute
|
359
|
+
version = read_version_from_nuspec
|
360
|
+
filename = File.basename(@nuspec, File.extname(@nuspec))
|
361
|
+
|
362
|
+
@command_line.execute @nuspec
|
363
|
+
|
364
|
+
path = File.join(@config.opts.get(:out), "#{filename}.#{version}.nupkg")
|
365
|
+
|
366
|
+
Albacore.publish :artifact, OpenStruct.new(
|
367
|
+
:nuspec => @nuspec,
|
368
|
+
:nupkg => path,
|
369
|
+
:location => path
|
370
|
+
)
|
371
|
+
end
|
372
|
+
|
373
|
+
def self.accept? file
|
374
|
+
File.extname(file).downcase == '.nuspec'
|
375
|
+
end
|
376
|
+
end
|
377
|
+
end
|
378
|
+
end
|