physique 0.3.10 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/FLUENT_MIGRATOR.md +300 -300
  3. data/Gemfile +3 -3
  4. data/Gemfile.lock +51 -11
  5. data/Guardfile +34 -0
  6. data/README.md +368 -368
  7. data/RUBY_SETUP.md +14 -14
  8. data/Rakefile +1 -1
  9. data/lib/physique.rb +22 -22
  10. data/lib/physique/config.rb +23 -23
  11. data/lib/physique/dsl.rb +46 -46
  12. data/lib/physique/project_path_resolver.rb +45 -45
  13. data/lib/physique/solution.rb +72 -72
  14. data/lib/physique/task_builders/build.rb +76 -69
  15. data/lib/physique/task_builders/default.rb +19 -19
  16. data/lib/physique/task_builders/fluent_migrator.rb +302 -299
  17. data/lib/physique/task_builders/nuget.rb +18 -6
  18. data/lib/physique/task_builders/octopus.rb +4 -2
  19. data/lib/physique/task_builders/publish_nugets.rb +5 -3
  20. data/lib/physique/task_builders/test.rb +4 -4
  21. data/lib/physique/tasks/fluent_migrator.rb +158 -158
  22. data/lib/physique/tasks/nugets_pack.rb +12 -12
  23. data/lib/physique/tasks/octopus_pack.rb +1 -1
  24. data/lib/physique/tasks/sqlcmd.rb +109 -109
  25. data/lib/physique/tasks/versionizer.rb +112 -112
  26. data/lib/physique/tasks_builder.rb +59 -59
  27. data/lib/physique/tool_locator.rb +50 -50
  28. data/lib/physique/version.rb +3 -3
  29. data/physique.gemspec +29 -28
  30. data/spec/fluent_migrator_config_spec.rb +39 -39
  31. data/spec/project_spec.rb +42 -42
  32. data/spec/publish_nugets_spec.rb +40 -40
  33. data/spec/solution_spec.rb +11 -11
  34. data/spec/sqlcmd_spec.rb +146 -146
  35. data/spec/support/shared_contexts/rake.rb +20 -21
  36. data/spec/task_builders/build_spec.rb +25 -25
  37. data/spec/task_builders/default_spec.rb +17 -17
  38. data/spec/task_builders/fluent_migrator_spec.rb +70 -68
  39. data/spec/task_builders/nspec_spec.rb +13 -13
  40. data/spec/task_builders/nuget_spec.rb +16 -16
  41. data/spec/test_data/solutions/.nuget/NuGet.Config +5 -5
  42. data/spec/test_data/solutions/.nuget/NuGet.exe +0 -0
  43. data/spec/test_data/solutions/.nuget/NuGet.targets +144 -144
  44. data/spec/test_data/solutions/.nuget/packages.config +3 -3
  45. data/spec/test_data/solutions/basic/.semver +6 -6
  46. data/spec/test_data/solutions/basic/Basic.Tests/Basic.Tests.csproj +58 -58
  47. data/spec/test_data/solutions/basic/Basic.Tests/Class1.cs +14 -14
  48. data/spec/test_data/solutions/basic/Basic.Tests/Properties/AssemblyInfo.cs +36 -36
  49. data/spec/test_data/solutions/basic/Basic.Tests/packages.config +3 -3
  50. data/spec/test_data/solutions/basic/Basic.sln +28 -28
  51. data/spec/test_data/solutions/basic/Basic/Basic.csproj +52 -52
  52. data/spec/test_data/solutions/basic/Basic/Class1.cs +12 -12
  53. data/spec/test_data/solutions/basic/Basic/Properties/AssemblyInfo.cs +36 -36
  54. data/spec/test_data/solutions/basic/Rakefile.rb +10 -10
  55. data/spec/test_data/solutions/basic/packages.config +3 -3
  56. data/spec/test_data/solutions/fluent-migrator/.semver +6 -6
  57. data/spec/test_data/solutions/fluent-migrator/Basic.Migrations/Migrations/.gitkeep +0 -0
  58. data/spec/test_data/solutions/fluent-migrator/Basic.Migrations/Properties/AssemblyInfo.cs +36 -36
  59. data/spec/test_data/solutions/fluent-migrator/Basic.Migrations/TestMigration.cs +19 -19
  60. data/spec/test_data/solutions/fluent-migrator/Basic.Migrations/_Scripts/create.sql +1 -1
  61. data/spec/test_data/solutions/fluent-migrator/Basic.Migrations/_Scripts/drop.sql +4 -4
  62. data/spec/test_data/solutions/fluent-migrator/Basic.Migrations/_Scripts/seed.sql +1 -1
  63. data/spec/test_data/solutions/fluent-migrator/Basic.Migrations/packages.config +3 -3
  64. data/spec/test_data/solutions/fluent-migrator/Basic.Specs/Basic.Specs.csproj +59 -59
  65. data/spec/test_data/solutions/fluent-migrator/Basic.Specs/Class1.cs +12 -12
  66. data/spec/test_data/solutions/fluent-migrator/Basic.Specs/DebuggerShim.cs +42 -42
  67. data/spec/test_data/solutions/fluent-migrator/Basic.Specs/Properties/AssemblyInfo.cs +36 -36
  68. data/spec/test_data/solutions/fluent-migrator/Basic.Specs/packages.config +3 -3
  69. data/spec/test_data/solutions/fluent-migrator/Basic.sln +39 -39
  70. data/spec/test_data/solutions/fluent-migrator/Basic/Basic.csproj +55 -55
  71. data/spec/test_data/solutions/fluent-migrator/Basic/Class1.cs +12 -12
  72. data/spec/test_data/solutions/fluent-migrator/Basic/Properties/AssemblyInfo.cs +36 -36
  73. data/spec/test_data/solutions/fluent-migrator/Basic/packages.config +2 -2
  74. data/spec/test_data/solutions/fluent-migrator/Rakefile.rb +20 -20
  75. data/spec/test_data/solutions/multiple-fluent-migrator/.semver +6 -6
  76. data/spec/test_data/solutions/multiple-fluent-migrator/Basic.Migrations1/Basic.Migrations1.csproj +52 -52
  77. data/spec/test_data/solutions/multiple-fluent-migrator/Basic.Migrations1/Class1.cs +12 -12
  78. data/spec/test_data/solutions/multiple-fluent-migrator/Basic.Migrations1/Properties/AssemblyInfo.cs +36 -36
  79. data/spec/test_data/solutions/multiple-fluent-migrator/Basic.Migrations2/Basic.Migrations2.csproj +52 -52
  80. data/spec/test_data/solutions/multiple-fluent-migrator/Basic.Migrations2/Class1.cs +12 -12
  81. data/spec/test_data/solutions/multiple-fluent-migrator/Basic.Migrations2/Properties/AssemblyInfo.cs +36 -36
  82. data/spec/test_data/solutions/multiple-fluent-migrator/Basic.Specs/Basic.Specs.csproj +59 -59
  83. data/spec/test_data/solutions/multiple-fluent-migrator/Basic.Specs/Class1.cs +12 -12
  84. data/spec/test_data/solutions/multiple-fluent-migrator/Basic.Specs/DebuggerShim.cs +42 -42
  85. data/spec/test_data/solutions/multiple-fluent-migrator/Basic.Specs/Properties/AssemblyInfo.cs +36 -36
  86. data/spec/test_data/solutions/multiple-fluent-migrator/Basic.Specs/packages.config +3 -3
  87. data/spec/test_data/solutions/multiple-fluent-migrator/Basic.sln +45 -45
  88. data/spec/test_data/solutions/multiple-fluent-migrator/Basic/Basic.csproj +55 -55
  89. data/spec/test_data/solutions/multiple-fluent-migrator/Basic/Class1.cs +12 -12
  90. data/spec/test_data/solutions/multiple-fluent-migrator/Basic/Properties/AssemblyInfo.cs +36 -36
  91. data/spec/test_data/solutions/multiple-fluent-migrator/Basic/packages.config +2 -2
  92. data/spec/test_data/solutions/multiple-fluent-migrator/Rakefile.rb +28 -28
  93. data/spec/test_data/solutions/nspec/.semver +6 -6
  94. data/spec/test_data/solutions/nspec/Basic.Specs/Basic.Specs.csproj +59 -59
  95. data/spec/test_data/solutions/nspec/Basic.Specs/Class1.cs +12 -12
  96. data/spec/test_data/solutions/nspec/Basic.Specs/DebuggerShim.cs +42 -42
  97. data/spec/test_data/solutions/nspec/Basic.Specs/Properties/AssemblyInfo.cs +36 -36
  98. data/spec/test_data/solutions/nspec/Basic.Specs/packages.config +3 -3
  99. data/spec/test_data/solutions/nspec/Basic.sln +28 -28
  100. data/spec/test_data/solutions/nspec/Basic/Basic.csproj +55 -55
  101. data/spec/test_data/solutions/nspec/Basic/Class1.cs +12 -12
  102. data/spec/test_data/solutions/nspec/Basic/Properties/AssemblyInfo.cs +36 -36
  103. data/spec/test_data/solutions/nspec/Basic/packages.config +2 -2
  104. data/spec/test_data/solutions/nspec/Rakefile.rb +14 -14
  105. data/spec/test_data/tool_locator/Program Files/Microsoft SQL Server/110/Tools/Binn/SQLCMD.exe.txt b/data/spec/test_data/tool_locator/Program Files/Microsoft SQL → Server/110/Tools/Binn/SQLCMD.exe.txt +0 -0
  106. data/spec/test_data/tool_locator/Windows/Microsoft.NET/Framework/v3.5/MSBuild.exe.txt +0 -0
  107. data/spec/test_data/tool_locator/Windows/Microsoft.NET/Framework/v4.0.30319/MSBuild.exe.txt +0 -0
  108. data/spec/tool_locator_spec.rb +27 -29
  109. metadata +33 -16
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in physique.gemspec
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in physique.gemspec
4
4
  gemspec
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- physique (0.3.10)
4
+ physique (0.4.0)
5
5
  activesupport (~> 4.1)
6
- albacore (~> 2.3)
6
+ albacore (~> 2.5)
7
7
  map (~> 6.5)
8
8
  rake (~> 10)
9
9
  semver2 (~> 3.4)
@@ -11,26 +11,59 @@ PATH
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- activesupport (4.2.1)
14
+ activesupport (4.2.5)
15
15
  i18n (~> 0.7)
16
16
  json (~> 1.7, >= 1.7.7)
17
17
  minitest (~> 5.1)
18
18
  thread_safe (~> 0.3, >= 0.3.4)
19
19
  tzinfo (~> 1.1)
20
- albacore (2.3.22)
20
+ albacore (2.5.6)
21
21
  map (~> 6.5)
22
22
  nokogiri (~> 1.5)
23
23
  rake (~> 10)
24
24
  semver2 (~> 3.4)
25
+ coderay (1.1.0)
25
26
  diff-lcs (1.2.5)
27
+ ffi (1.9.10)
28
+ ffi (1.9.10-x64-mingw32)
29
+ ffi (1.9.10-x86-mingw32)
30
+ formatador (0.2.5)
31
+ guard (2.13.0)
32
+ formatador (>= 0.2.4)
33
+ listen (>= 2.7, <= 4.0)
34
+ lumberjack (~> 1.0)
35
+ nenv (~> 0.1)
36
+ notiffany (~> 0.0)
37
+ pry (>= 0.9.12)
38
+ shellany (~> 0.0)
39
+ thor (>= 0.18.1)
40
+ guard-rspec (4.3.1)
41
+ guard (~> 2.1)
42
+ rspec (>= 2.14, < 4.0)
26
43
  i18n (0.7.0)
27
- json (1.8.2)
28
- map (6.5.5)
29
- mini_portile (0.6.2)
30
- minitest (5.5.1)
31
- nokogiri (1.6.6.2-x64-mingw32)
32
- mini_portile (~> 0.6.0)
33
- rake (10.4.2)
44
+ json (1.8.3)
45
+ listen (3.0.5)
46
+ rb-fsevent (>= 0.9.3)
47
+ rb-inotify (>= 0.9)
48
+ lumberjack (1.0.9)
49
+ map (6.6.0)
50
+ method_source (0.8.2)
51
+ mini_portile2 (2.0.0)
52
+ minitest (5.8.3)
53
+ nenv (0.2.0)
54
+ nokogiri (1.6.7.2)
55
+ mini_portile2 (~> 2.0.0.rc2)
56
+ notiffany (0.0.8)
57
+ nenv (~> 0.1)
58
+ shellany (~> 0.0)
59
+ pry (0.10.3)
60
+ coderay (~> 1.1.0)
61
+ method_source (~> 0.8.1)
62
+ slop (~> 3.4)
63
+ rake (10.5.0)
64
+ rb-fsevent (0.9.6)
65
+ rb-inotify (0.9.5)
66
+ ffi (>= 0.5.0)
34
67
  rspec (2.14.1)
35
68
  rspec-core (~> 2.14.0)
36
69
  rspec-expectations (~> 2.14.0)
@@ -40,6 +73,9 @@ GEM
40
73
  diff-lcs (>= 1.1.3, < 2.0)
41
74
  rspec-mocks (2.14.6)
42
75
  semver2 (3.4.2)
76
+ shellany (0.0.1)
77
+ slop (3.6.0)
78
+ thor (0.19.1)
43
79
  thread_safe (0.3.5)
44
80
  tzinfo (1.2.2)
45
81
  thread_safe (~> 0.1)
@@ -51,5 +87,9 @@ PLATFORMS
51
87
 
52
88
  DEPENDENCIES
53
89
  bundler
90
+ guard-rspec (~> 4.3.1)
54
91
  physique!
55
92
  rspec (= 2.14.1)
93
+
94
+ BUNDLED WITH
95
+ 1.11.2
@@ -0,0 +1,34 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ # Note: The cmd option is now required due to the increasing number of ways
19
+ # rspec may be run, below are examples of the most common uses.
20
+ # * bundler: 'bundle exec rspec'
21
+ # * bundler binstubs: 'bin/rspec'
22
+ # * spring: 'bin/rsspec' (This will use spring if running and you have
23
+ # installed the spring binstubs per the docs)
24
+ # * zeus: 'zeus rspec' (requires the server to be started separetly)
25
+ # * 'just' rspec: 'rspec'
26
+ guard :rspec, cmd: 'bundle exec rspec' do
27
+ watch(%r{^spec/.+_spec\.rb$})
28
+ watch(%r{spec/support/shared_contexts/(.+)\.rb}) { 'spec/task_builders' }
29
+ watch('spec/spec_helper.rb') { 'spec' }
30
+
31
+ watch(%r{^lib/physique/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
32
+ watch(%r{^lib/physique/(.+)/(.+)\.rb$}) { |m| "spec/#{m[1]}/#{m[2]}_spec.rb" }
33
+ end
34
+
data/README.md CHANGED
@@ -1,368 +1,368 @@
1
- # Physique - Beautiful builds for .NET
2
-
3
- Physique is an opinionated build framework that allows you to create a professional build process for your solution with minimal configuration. You tell Physique a little about your solution, and it creates a complete set of rake tasks to build, test and package your apps for deployment.
4
-
5
- ## Features
6
-
7
- * Integrates with any unit testing framework. Provides built in support for [NUnit](http://www.nunit.org/) and [NSpec](http://nspec.org/).
8
- * Support for packaging and publishing your assemblies as NuGet packages.
9
- * Provides powerful developer workflow tools when paired with [FluentMigrator](https://github.com/schambers/fluentmigrator).
10
- * Built-in support for packaging and publishing applications to [Octopus Deploy](https://octopusdeploy.com/)
11
- * Built on top of [Albacore](http://github.com/Albacore/albacore) which provides a rich suite of build tools to support any project.
12
- * Actively maintained with several companies using it in production.
13
-
14
- ## Getting Started with Physique
15
-
16
- ### Installing Ruby
17
-
18
- You will need to [install Ruby](RUBY_SETUP.md) on your workstation and build servers.
19
-
20
- ### Project Structure
21
-
22
- Physique was designed to minimize the amount of ceremony in defining a build process. It uses a set of practical conventions that when followed, eliminate most of the configuration required to set up your builds.
23
-
24
- Out of the box, Physique expects your repo to look something like this:
25
-
26
- ├─ build # Compiled files
27
- │ └─ packages # Compiled packages will be built here.
28
- ├─ docs # Documentation files
29
- ├─ lib # Included libraries
30
- ├─ src # Source folder
31
- │ ├─ packages # Nuget restore location
32
- │ ├─ .nuget # Nuget files
33
- │ │ └─ nuget.exe # Nuget executable
34
- │ ├─ YourProject # Project folder
35
- │ │ └─ YourProject.csproj # Project file
36
- │ ├─ YourProject.Tests # Test Project folder
37
- │ │ └─ YourProject.Tests.csproj # Test Project file
38
- │ └─ YourProject.sln # Solution file
39
- ├─ tools # Tools and utilities
40
- └─ README.md
41
-
42
- If your project doesn't look anything like this, don't worry, you can customize any of the conventions to match the structure of your solution.
43
-
44
- ### Preparing Your Project
45
-
46
- * Open a command prompt and `cd` to the root of your repo.
47
-
48
- * Create a `Gemfile` in the root and add the following:
49
-
50
- ```ruby
51
- source 'https://rubygems.org/'
52
-
53
- gem 'physique', '~> 0.3'
54
- ```
55
-
56
- * Install the Bundler gem and install the required Ruby gems
57
-
58
- ```
59
- $ gem install bundler
60
- $ bundle install
61
- ```
62
-
63
- * Physique uses the [semver2](https://github.com/haf/semver) gem to manage the version of your solution. Use the included command line tool to create a `.semver` file for the solution.
64
-
65
- ```
66
- $ bundle exec semver init
67
- ```
68
-
69
- * Create a `Rakefile` in the root and add the following:
70
-
71
- ```ruby
72
- require 'physique'
73
-
74
- Physique::Solution.new do |s|
75
- s.file = 'src/YourSolution.sln'
76
- end
77
- ```
78
-
79
- * If everything is set up correctly you should be able to run the following and see a list of tasks that Physique has created for you.
80
-
81
- ```
82
- $ bundle exec rake --tasks
83
-
84
- rake compile # Builds the solution
85
- rake compile:build # Builds the solution using the Build target
86
- rake compile:clean # Builds the solution using the Clean target
87
- rake compile:rebuild # Builds the solution using the Rebuild target
88
- rake restore # Restores all nugets as per the packages.config files
89
- rake test # Run unit tests
90
- ```
91
-
92
- * Now you can run your rake tasks. For example, to compile your solution, run the following:
93
-
94
- ```
95
- $ bundle exec rake compile
96
- ```
97
-
98
- ## The Default Build Process
99
-
100
- Physique's default build process consists of the following phases:
101
-
102
- 1. `version` - Determines the version of the build.
103
- 2. `restore` - Scans your repo for `packages.config` files and downloads the discovered packages to the Nuget restore location.
104
- 3. `compile` - Runs MSBuild on your solution file.
105
- 4. `test` - Scans your repo for test assemblies and runs all tests.
106
- 5. `package` - Packages your apps and/or assemblies for deployment.
107
- 6. `publish` - Publishes your packages to a Nuget repository.
108
-
109
- Each phase depends on the ones before it. This means when you run the tests, Physique will run the `restore` and `compile` tasks to ensure you your assemblies are up to date. In addition, you can register custom tasks to run at the different phases of the build process.
110
-
111
- ## Customizing Your Build
112
-
113
- Physique provides several customizations to tailor your build to your needs. You configure these options in your `Rakefile` which is just a Ruby code file. Having the full power of the Ruby programming language at your disposal to define your builds is one of the best features of rake, and by extension Physique, over XML-based tools like NAnt or MSBuild. If you don't know Ruby, never fear, Physique's configuration syntax is straightforward enough for any .NET developer to pick up quickly.
114
-
115
- The following describes the available configuration options. Unless otherwise specified, these examples show the default values.
116
-
117
- ### NuGet Configuration
118
-
119
- You can customize how NuGet packages are handled in your solution.
120
-
121
- ```ruby
122
- Physique::Solution.new do |s|
123
- s.file = 'src/YourSolution.sln'
124
-
125
- s.use_nuget do |n|
126
- n.exe = 'src/.nuget/NuGet.exe' # Path to the NuGet executable
127
- n.restore_location = 'src/packages' # NuGet package restore location
128
- n.build_location = 'build/packages' # Output folder for built NuGet packages
129
- end
130
- end
131
- ```
132
-
133
- ### Compilation Configuration
134
-
135
- You can customize MSBuild configuration and targets.
136
-
137
- ```ruby
138
- Physique::Solution.new do |s|
139
- s.file = 'src/YourSolution.sln'
140
-
141
- s.compilation do |c|
142
- c.default_targets = ['Clean', 'Rebuild'] # The default targets executed by the 'compile' task
143
- c.configuration = 'Release' # The build configuration
144
- c.logging = 'normal' # MSBuild logging level
145
- end
146
- end
147
- ```
148
-
149
- If you have custom MSBuild targets you can tell Physique about them.
150
-
151
- ```ruby
152
- s.compilation do |c|
153
- c.add_target 'Custom'
154
- end
155
- ```
156
-
157
- Physique will then add a rake task for each target which you can call from the command line.
158
-
159
- ```
160
- $ bundle exec rake compile:custom
161
- ```
162
-
163
- By default, Physique will create additional tasks for the Clean, Build and Rebuild targets.
164
-
165
- ### Unit Testing Configuration
166
-
167
- To execute your tests, Physique will look for the test runner executable in the NuGet restore location at runtime. If multiple versions are available, the latest version will be used. Make sure that you include the NuGet package for the test runner in a `packages.config` file somewhere in your solution.
168
-
169
- Physique supports NUnit by default, but also has built in support for NSpec. Each of these test runners have their own defaults. If you are using something different, it's easy to provide a custom configuration.
170
-
171
- #### NUnit Configuration
172
-
173
- Since NUnit is the default, no additional configuration is required to use it. Physique will automatically find and run any assembly ending in ".Tests".
174
-
175
- To tweak this behavior, you have the following configuration options:
176
-
177
- ```ruby
178
- Physique::Solution.new do |s|
179
- s.file = 'src/YourSolution.sln'
180
-
181
- s.run_tests do |t|
182
- # Find all assemblies ending in '.Tests'
183
- t.files = FileList["**/*.Tests/bin/Release/*.Tests.dll"]
184
-
185
- # Default command line args
186
- t.parameters = ['/labels', '/trace=Verbose']
187
- end
188
- end
189
- ```
190
-
191
- #### NSpec Configuration
192
-
193
- With the NSpec runner configured, Physique will automatically find and run any assembly ending in ".Specs".
194
-
195
- Like wth NUnit, you have the following configuration options. Note the runner must be set to `:nspec`.
196
-
197
- ```ruby
198
- Physique::Solution.new do |s|
199
- s.file = 'src/YourSolution.sln'
200
-
201
- s.run_tests do |t|
202
- t.runner = :nspec
203
-
204
- # The default method for finding NSpec assemblies
205
- t.files = FileList["**/*.Specs/bin/Release/*.Specs.dll"]
206
-
207
- # You can add additional command line args
208
- t.parameters = ['--failfast']
209
- end
210
- end
211
- ```
212
-
213
- #### Custom Configuration
214
-
215
- You can use any unit testing framework. You just need to provide a bit more configuration. This effectively just wraps the Albacore method for declaring a test runner.
216
-
217
- ```ruby
218
- s.run_tests do |t|
219
- t.runner = :custom
220
-
221
- # Specify the test runner
222
- t.exe = 'root-relative-path/to/the/test-runner.exe'
223
-
224
- # Specify the test assemblies
225
- t.files = FileList["**/*.Tests/bin/Release/*.Tests.dll"]
226
-
227
- # Specify additional command line args
228
- t.parameters = ['/option1', '/option2']
229
- end
230
- ```
231
-
232
- ### NuGet Publishing Configuration
233
-
234
- Physique provides an easy way to publish your NuGet packages to public or private Nuget repos. Each assembly in your solution will be published as a separate NuGet package with the correct dependencies.
235
-
236
- ```ruby
237
- Physique::Solution.new do |s|
238
- s.file = 'src/YourSolution.sln'
239
-
240
- s.publish_nugets do |p|
241
- # The NuGet repo you want to publish to
242
- p.feed_url = 'https://www.nuget.org'
243
-
244
- # The NuGet repo for your symbol package (Optional)
245
- p.symbols_feed_url = 'http://nuget.gw.symbolsource.org/Public/NuGet'
246
-
247
- # The API key to authenticate to the repo.
248
- # If your source code is public, make sure to pass this in as an environment variable.
249
- p.api_key = ENV['NUGET_API_KEY']
250
-
251
- # Metadata to be included in your Nuspec
252
- p.with_metadata do |m|
253
- m.description = 'My Awesome Library'
254
- m.authors = 'My Company, Inc.'
255
- end
256
- end
257
- end
258
- ```
259
-
260
- When you configure NuGet publishing, the `package` and `publish` tasks become available.
261
-
262
- ```
263
- $ bundle exec rake --tasks
264
- ...
265
- rake nuget:package # Package all NuGets
266
- rake nuget:publish # Publish nuget packages to feed
267
- rake nuget:publish:local # Copy nuget packages to local path
268
- ...
269
- ```
270
-
271
- ## Third Party Tools
272
-
273
- ### FluentMigrator Configuration
274
-
275
- If you are using FluentMigrator to manage your databases, Physique can create several useful tasks to improve your development workflow. Simply tell Physique where your migrations project is located and it will take care of the rest.
276
-
277
- ```ruby
278
- Physique::Solution.new do |s|
279
- s.file = 'src/YourSolution.sln'
280
-
281
- s.fluently_migrate do |db|
282
- db.instance = '(local)'
283
- db.name = 'MyDatabase'
284
- db.project = 'src\MyProject.Database\MyProject.Database.csproj'
285
- end
286
- end
287
- ```
288
-
289
- Currently Physique only works with SQL Server, but support for additional databases is planned.
290
-
291
- For more information, see [Using Physique with Fluent Migrator](FLUENT_MIGRATOR.md)
292
-
293
- ### Octopus Deploy Configuration
294
-
295
- If you are deploying your applications with Octopus Deploy, Physique allows you to package and publish your applications without needing to modify your project file.
296
-
297
- ```ruby
298
- Physique::Solution.new do |s|
299
- s.file = 'src/YourSolution.sln'
300
-
301
- s.octopus_deploy do |octo|
302
- # Octopus Deploy server's NuGet feed URL
303
- octo.server = 'http://octopus-deploy-server/nuget/packages'
304
-
305
- # Octopus Deploy API key
306
- # For security it's a good idea to pass this in as an environment variable.
307
- octo.api_key = ENV['OCTOPUS_API_KEY']
308
-
309
- # You can specify multiple apps to deploy
310
-
311
- # A hypothetical web application
312
- octo.deploy_app do |app|
313
- # App name for rake tasks
314
- app.name = 'web'
315
-
316
- # App type
317
- # Valid options include :service, :website, :console
318
- app.type = :website
319
-
320
- # App project file
321
- app.project = 'src/MyProject.Website/MyProject.Website.csproj'
322
-
323
- # Nuspec metadata for your application
324
- app.with_metadata do |m|
325
- m.description = 'My Web Application'
326
- m.authors = 'My Company, Inc.'
327
- end
328
- end
329
- end
330
- end
331
- ```
332
-
333
- When you configure Octopus deployments, the `octo:package` and `octo:publish` tasks become available.
334
-
335
- The following tasks would be available with the configuration above:
336
-
337
- ```
338
- $ bundle exec rake --tasks
339
- ...
340
- rake octo:package # Package all applications
341
- rake octo:package:web # Package MyProject.Website for Oct...
342
- rake octo:publish # Publish all apps to Octopus ...
343
- rake octo:publish:web # Publish MyProject.Website app to ...
344
- ...
345
- ```
346
-
347
- ## Roadmap
348
-
349
- * Add conventions for more unit test frameworks.
350
- * Add support for additional databases.
351
- * Optionally use [Packet](https://github.com/fsprojects/Paket) instead of NuGet during `restore` phase
352
- * Mono support is possible but completely untested.
353
-
354
- ## Acknowledgements
355
-
356
- Special thanks to [Henrik Feldt](https://github.com/haf) and [Amir Rajan](https://github.com/amirrajan) for the inspiration to make this project.
357
-
358
- ## Support
359
-
360
- Feel free to contact me [@scardetto](https://twitter.com/scardetto) if you have any questions.
361
-
362
- ## Contributing
363
-
364
- 1. Fork it ( https://github.com/scardetto/physique/fork )
365
- 2. Create your feature branch (`git checkout -b my-new-feature`)
366
- 3. Commit your changes (`git commit -am 'Add some feature'`)
367
- 4. Push to the branch (`git push origin my-new-feature`)
368
- 5. Create a new Pull Request
1
+ # Physique - Beautiful builds for .NET
2
+
3
+ Physique is an opinionated build framework that allows you to create a professional build process for your solution with minimal configuration. You tell Physique a little about your solution, and it creates a complete set of rake tasks to build, test and package your apps for deployment.
4
+
5
+ ## Features
6
+
7
+ * Integrates with any unit testing framework. Provides built in support for [NUnit](http://www.nunit.org/) and [NSpec](http://nspec.org/).
8
+ * Support for packaging and publishing your assemblies as NuGet packages.
9
+ * Provides powerful developer workflow tools when paired with [FluentMigrator](https://github.com/schambers/fluentmigrator).
10
+ * Built-in support for packaging and publishing applications to [Octopus Deploy](https://octopusdeploy.com/)
11
+ * Built on top of [Albacore](http://github.com/Albacore/albacore) which provides a rich suite of build tools to support any project.
12
+ * Actively maintained with several companies using it in production.
13
+
14
+ ## Getting Started with Physique
15
+
16
+ ### Installing Ruby
17
+
18
+ You will need to [install Ruby](RUBY_SETUP.md) on your workstation and build servers.
19
+
20
+ ### Project Structure
21
+
22
+ Physique was designed to minimize the amount of ceremony in defining a build process. It uses a set of practical conventions that when followed, eliminate most of the configuration required to set up your builds.
23
+
24
+ Out of the box, Physique expects your repo to look something like this:
25
+
26
+ ├─ build # Compiled files
27
+ │ └─ packages # Compiled packages will be built here.
28
+ ├─ docs # Documentation files
29
+ ├─ lib # Included libraries
30
+ ├─ src # Source folder
31
+ │ ├─ packages # Nuget restore location
32
+ │ ├─ .nuget # Nuget files
33
+ │ │ └─ nuget.exe # Nuget executable
34
+ │ ├─ YourProject # Project folder
35
+ │ │ └─ YourProject.csproj # Project file
36
+ │ ├─ YourProject.Tests # Test Project folder
37
+ │ │ └─ YourProject.Tests.csproj # Test Project file
38
+ │ └─ YourProject.sln # Solution file
39
+ ├─ tools # Tools and utilities
40
+ └─ README.md
41
+
42
+ If your project doesn't look anything like this, don't worry, you can customize any of the conventions to match the structure of your solution.
43
+
44
+ ### Preparing Your Project
45
+
46
+ * Open a command prompt and `cd` to the root of your repo.
47
+
48
+ * Create a `Gemfile` in the root and add the following:
49
+
50
+ ```ruby
51
+ source 'https://rubygems.org/'
52
+
53
+ gem 'physique', '~> 0.3'
54
+ ```
55
+
56
+ * Install the Bundler gem and install the required Ruby gems
57
+
58
+ ```
59
+ $ gem install bundler
60
+ $ bundle install
61
+ ```
62
+
63
+ * Physique uses the [semver2](https://github.com/haf/semver) gem to manage the version of your solution. Use the included command line tool to create a `.semver` file for the solution.
64
+
65
+ ```
66
+ $ bundle exec semver init
67
+ ```
68
+
69
+ * Create a `Rakefile` in the root and add the following:
70
+
71
+ ```ruby
72
+ require 'physique'
73
+
74
+ Physique::Solution.new do |s|
75
+ s.file = 'src/YourSolution.sln'
76
+ end
77
+ ```
78
+
79
+ * If everything is set up correctly you should be able to run the following and see a list of tasks that Physique has created for you.
80
+
81
+ ```
82
+ $ bundle exec rake --tasks
83
+
84
+ rake compile # Builds the solution
85
+ rake compile:build # Builds the solution using the Build target
86
+ rake compile:clean # Builds the solution using the Clean target
87
+ rake compile:rebuild # Builds the solution using the Rebuild target
88
+ rake restore # Restores all nugets as per the packages.config files
89
+ rake test # Run unit tests
90
+ ```
91
+
92
+ * Now you can run your rake tasks. For example, to compile your solution, run the following:
93
+
94
+ ```
95
+ $ bundle exec rake compile
96
+ ```
97
+
98
+ ## The Default Build Process
99
+
100
+ Physique's default build process consists of the following phases:
101
+
102
+ 1. `version` - Determines the version of the build.
103
+ 2. `restore` - Scans your repo for `packages.config` files and downloads the discovered packages to the Nuget restore location.
104
+ 3. `compile` - Runs MSBuild on your solution file.
105
+ 4. `test` - Scans your repo for test assemblies and runs all tests.
106
+ 5. `package` - Packages your apps and/or assemblies for deployment.
107
+ 6. `publish` - Publishes your packages to a Nuget repository.
108
+
109
+ Each phase depends on the ones before it. This means when you run the tests, Physique will run the `restore` and `compile` tasks to ensure you your assemblies are up to date. In addition, you can register custom tasks to run at the different phases of the build process.
110
+
111
+ ## Customizing Your Build
112
+
113
+ Physique provides several customizations to tailor your build to your needs. You configure these options in your `Rakefile` which is just a Ruby code file. Having the full power of the Ruby programming language at your disposal to define your builds is one of the best features of rake, and by extension Physique, over XML-based tools like NAnt or MSBuild. If you don't know Ruby, never fear, Physique's configuration syntax is straightforward enough for any .NET developer to pick up quickly.
114
+
115
+ The following describes the available configuration options. Unless otherwise specified, these examples show the default values.
116
+
117
+ ### NuGet Configuration
118
+
119
+ You can customize how NuGet packages are handled in your solution.
120
+
121
+ ```ruby
122
+ Physique::Solution.new do |s|
123
+ s.file = 'src/YourSolution.sln'
124
+
125
+ s.use_nuget do |n|
126
+ n.exe = 'src/.nuget/NuGet.exe' # Path to the NuGet executable
127
+ n.restore_location = 'src/packages' # NuGet package restore location
128
+ n.build_location = 'build/packages' # Output folder for built NuGet packages
129
+ end
130
+ end
131
+ ```
132
+
133
+ ### Compilation Configuration
134
+
135
+ You can customize MSBuild configuration and targets.
136
+
137
+ ```ruby
138
+ Physique::Solution.new do |s|
139
+ s.file = 'src/YourSolution.sln'
140
+
141
+ s.compilation do |c|
142
+ c.default_targets = ['Clean', 'Rebuild'] # The default targets executed by the 'compile' task
143
+ c.configuration = 'Release' # The build configuration
144
+ c.logging = 'normal' # MSBuild logging level
145
+ end
146
+ end
147
+ ```
148
+
149
+ If you have custom MSBuild targets you can tell Physique about them.
150
+
151
+ ```ruby
152
+ s.compilation do |c|
153
+ c.add_target 'Custom'
154
+ end
155
+ ```
156
+
157
+ Physique will then add a rake task for each target which you can call from the command line.
158
+
159
+ ```
160
+ $ bundle exec rake compile:custom
161
+ ```
162
+
163
+ By default, Physique will create additional tasks for the Clean, Build and Rebuild targets.
164
+
165
+ ### Unit Testing Configuration
166
+
167
+ To execute your tests, Physique will look for the test runner executable in the NuGet restore location at runtime. If multiple versions are available, the latest version will be used. Make sure that you include the NuGet package for the test runner in a `packages.config` file somewhere in your solution.
168
+
169
+ Physique supports NUnit by default, but also has built in support for NSpec. Each of these test runners have their own defaults. If you are using something different, it's easy to provide a custom configuration.
170
+
171
+ #### NUnit Configuration
172
+
173
+ Since NUnit is the default, no additional configuration is required to use it. Physique will automatically find and run any assembly ending in ".Tests".
174
+
175
+ To tweak this behavior, you have the following configuration options:
176
+
177
+ ```ruby
178
+ Physique::Solution.new do |s|
179
+ s.file = 'src/YourSolution.sln'
180
+
181
+ s.run_tests do |t|
182
+ # Find all assemblies ending in '.Tests'
183
+ t.files = FileList["**/*.Tests/bin/Release/*.Tests.dll"]
184
+
185
+ # Default command line args
186
+ t.parameters = ['/labels', '/trace=Verbose']
187
+ end
188
+ end
189
+ ```
190
+
191
+ #### NSpec Configuration
192
+
193
+ With the NSpec runner configured, Physique will automatically find and run any assembly ending in ".Specs".
194
+
195
+ Like wth NUnit, you have the following configuration options. Note the runner must be set to `:nspec`.
196
+
197
+ ```ruby
198
+ Physique::Solution.new do |s|
199
+ s.file = 'src/YourSolution.sln'
200
+
201
+ s.run_tests do |t|
202
+ t.runner = :nspec
203
+
204
+ # The default method for finding NSpec assemblies
205
+ t.files = FileList["**/*.Specs/bin/Release/*.Specs.dll"]
206
+
207
+ # You can add additional command line args
208
+ t.parameters = ['--failfast']
209
+ end
210
+ end
211
+ ```
212
+
213
+ #### Custom Configuration
214
+
215
+ You can use any unit testing framework. You just need to provide a bit more configuration. This effectively just wraps the Albacore method for declaring a test runner.
216
+
217
+ ```ruby
218
+ s.run_tests do |t|
219
+ t.runner = :custom
220
+
221
+ # Specify the test runner
222
+ t.exe = 'root-relative-path/to/the/test-runner.exe'
223
+
224
+ # Specify the test assemblies
225
+ t.files = FileList["**/*.Tests/bin/Release/*.Tests.dll"]
226
+
227
+ # Specify additional command line args
228
+ t.parameters = ['/option1', '/option2']
229
+ end
230
+ ```
231
+
232
+ ### NuGet Publishing Configuration
233
+
234
+ Physique provides an easy way to publish your NuGet packages to public or private Nuget repos. Each assembly in your solution will be published as a separate NuGet package with the correct dependencies.
235
+
236
+ ```ruby
237
+ Physique::Solution.new do |s|
238
+ s.file = 'src/YourSolution.sln'
239
+
240
+ s.publish_nugets do |p|
241
+ # The NuGet repo you want to publish to
242
+ p.feed_url = 'https://www.nuget.org'
243
+
244
+ # The NuGet repo for your symbol package (Optional)
245
+ p.symbols_feed_url = 'http://nuget.gw.symbolsource.org/Public/NuGet'
246
+
247
+ # The API key to authenticate to the repo.
248
+ # If your source code is public, make sure to pass this in as an environment variable.
249
+ p.api_key = ENV['NUGET_API_KEY']
250
+
251
+ # Metadata to be included in your Nuspec
252
+ p.with_metadata do |m|
253
+ m.description = 'My Awesome Library'
254
+ m.authors = 'My Company, Inc.'
255
+ end
256
+ end
257
+ end
258
+ ```
259
+
260
+ When you configure NuGet publishing, the `package` and `publish` tasks become available.
261
+
262
+ ```
263
+ $ bundle exec rake --tasks
264
+ ...
265
+ rake nuget:package # Package all NuGets
266
+ rake nuget:publish # Publish nuget packages to feed
267
+ rake nuget:publish:local # Copy nuget packages to local path
268
+ ...
269
+ ```
270
+
271
+ ## Third Party Tools
272
+
273
+ ### FluentMigrator Configuration
274
+
275
+ If you are using FluentMigrator to manage your databases, Physique can create several useful tasks to improve your development workflow. Simply tell Physique where your migrations project is located and it will take care of the rest.
276
+
277
+ ```ruby
278
+ Physique::Solution.new do |s|
279
+ s.file = 'src/YourSolution.sln'
280
+
281
+ s.fluently_migrate do |db|
282
+ db.instance = '(local)'
283
+ db.name = 'MyDatabase'
284
+ db.project = 'src\MyProject.Database\MyProject.Database.csproj'
285
+ end
286
+ end
287
+ ```
288
+
289
+ Currently Physique only works with SQL Server, but support for additional databases is planned.
290
+
291
+ For more information, see [Using Physique with Fluent Migrator](FLUENT_MIGRATOR.md)
292
+
293
+ ### Octopus Deploy Configuration
294
+
295
+ If you are deploying your applications with Octopus Deploy, Physique allows you to package and publish your applications without needing to modify your project file.
296
+
297
+ ```ruby
298
+ Physique::Solution.new do |s|
299
+ s.file = 'src/YourSolution.sln'
300
+
301
+ s.octopus_deploy do |octo|
302
+ # Octopus Deploy server's NuGet feed URL
303
+ octo.server = 'http://octopus-deploy-server/nuget/packages'
304
+
305
+ # Octopus Deploy API key
306
+ # For security it's a good idea to pass this in as an environment variable.
307
+ octo.api_key = ENV['OCTOPUS_API_KEY']
308
+
309
+ # You can specify multiple apps to deploy
310
+
311
+ # A hypothetical web application
312
+ octo.deploy_app do |app|
313
+ # App name for rake tasks
314
+ app.name = 'web'
315
+
316
+ # App type
317
+ # Valid options include :service, :website, :console
318
+ app.type = :website
319
+
320
+ # App project file
321
+ app.project = 'src/MyProject.Website/MyProject.Website.csproj'
322
+
323
+ # Nuspec metadata for your application
324
+ app.with_metadata do |m|
325
+ m.description = 'My Web Application'
326
+ m.authors = 'My Company, Inc.'
327
+ end
328
+ end
329
+ end
330
+ end
331
+ ```
332
+
333
+ When you configure Octopus deployments, the `octo:package` and `octo:publish` tasks become available.
334
+
335
+ The following tasks would be available with the configuration above:
336
+
337
+ ```
338
+ $ bundle exec rake --tasks
339
+ ...
340
+ rake octo:package # Package all applications
341
+ rake octo:package:web # Package MyProject.Website for Oct...
342
+ rake octo:publish # Publish all apps to Octopus ...
343
+ rake octo:publish:web # Publish MyProject.Website app to ...
344
+ ...
345
+ ```
346
+
347
+ ## Roadmap
348
+
349
+ * Add conventions for more unit test frameworks.
350
+ * Add support for additional databases.
351
+ * Optionally use [Packet](https://github.com/fsprojects/Paket) instead of NuGet during `restore` phase
352
+ * Mono support is possible but completely untested.
353
+
354
+ ## Acknowledgements
355
+
356
+ Special thanks to [Henrik Feldt](https://github.com/haf) and [Amir Rajan](https://github.com/amirrajan) for the inspiration to make this project.
357
+
358
+ ## Support
359
+
360
+ Feel free to contact me [@scardetto](https://twitter.com/scardetto) if you have any questions.
361
+
362
+ ## Contributing
363
+
364
+ 1. Fork it ( https://github.com/scardetto/physique/fork )
365
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
366
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
367
+ 4. Push to the branch (`git push origin my-new-feature`)
368
+ 5. Create a new Pull Request