solution-generator 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.md +5 -0
- data/Rakefile +2 -0
- data/bin/solution-generator +16 -0
- data/lib/solution-generator.rb +69 -0
- data/lib/solution-generator/version.rb +5 -0
- data/solution-generator.gemspec +23 -0
- metadata +84 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require_relative '../lib/solution-generator'
|
4
|
+
|
5
|
+
if ARGV.size < 2
|
6
|
+
puts "Usage:"
|
7
|
+
puts <<-USAGE
|
8
|
+
solution-generator <solution_name> <project_name> <project_name> <project_name>
|
9
|
+
USAGE
|
10
|
+
exit
|
11
|
+
end
|
12
|
+
|
13
|
+
solution_name = ARGV[0]
|
14
|
+
projects = ARGV - [solution_name]
|
15
|
+
projects = projects.map {|p| Dir.glob("**/#{p}.csproj").first}
|
16
|
+
SolutionGenerator::generate(solution_name + ".sln", projects)
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
module SolutionGenerator
|
5
|
+
|
6
|
+
def self.generate(solution_name, projects)
|
7
|
+
all_projects = projects.map do |project|
|
8
|
+
get_referenced_projects(project)
|
9
|
+
end
|
10
|
+
all_projects.flatten!
|
11
|
+
all_projects.uniq! { |p| p.name }
|
12
|
+
write_solution_file(solution_name, all_projects)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.get_referenced_projects(project, projects=nil)
|
16
|
+
projects = [] if projects == nil
|
17
|
+
|
18
|
+
project = project.gsub('\\', '/')
|
19
|
+
contents = File.read(project).gsub(' xmlns="http://schemas.microsoft.com/developer/msbuild/2003"', "")
|
20
|
+
xml = Nokogiri::XML(contents)
|
21
|
+
projects << create_project(project, File.basename(project), xml.xpath('//Project/PropertyGroup/ProjectGuid').first.text)
|
22
|
+
project = projects.last
|
23
|
+
xml.xpath('//Project/ItemGroup/ProjectReference').each do |project_reference|
|
24
|
+
referenced_project = File.expand_path(project_reference['Include'], File.dirname(project.path))
|
25
|
+
projects = get_referenced_projects(referenced_project, projects)
|
26
|
+
end
|
27
|
+
projects
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.create_project(path, name, guid)
|
31
|
+
project = OpenStruct.new
|
32
|
+
project.name = name
|
33
|
+
project.path = path
|
34
|
+
project.guid = guid
|
35
|
+
project
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.write_solution_file(path, projects)
|
39
|
+
solution_guid = '{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}'
|
40
|
+
configurations = ['Debug|Any CPU', 'Release|Any CPU']
|
41
|
+
File.open(path, 'w') do |file|
|
42
|
+
file.puts 'Microsoft Visual Studio Solution File, Format Version 10.00'
|
43
|
+
file.puts '# Visual Studio 2008'
|
44
|
+
projects.each do |project|
|
45
|
+
file.puts "Project(\"#{solution_guid}\") = \"#{project.name}\", \"#{project.path}\", \"#{project.guid}\""
|
46
|
+
file.puts "EndProject"
|
47
|
+
end
|
48
|
+
file.puts 'Global'
|
49
|
+
file.puts ' GlobalSection(SolutionConfigurationPlatforms) = preSolution'
|
50
|
+
configurations.each do |configuration|
|
51
|
+
file.puts " #{configuration} = #{configuration}"
|
52
|
+
end
|
53
|
+
file.puts ' EndGlobalSection'
|
54
|
+
file.puts ' GlobalSection(ProjectConfigurationPlatforms) = postSolution'
|
55
|
+
projects.each do |project|
|
56
|
+
configurations.each do |configuration|
|
57
|
+
file.puts " #{project.guid}.#{configuration}.ActiveCfg = #{configuration}"
|
58
|
+
file.puts " #{project.guid}.#{configuration}.Build.0 = #{configuration}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
file.puts ' EndGlobalSection'
|
62
|
+
file.puts ' GlobalSection(SolutionProperties) = preSolution'
|
63
|
+
file.puts ' HideSolutionNode = FALSE'
|
64
|
+
file.puts ' EndGlobalSection'
|
65
|
+
file.puts 'EndGlobal'
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "solution-generator/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "solution-generator"
|
7
|
+
s.version = Solution::Generator::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Andrew Vos"]
|
10
|
+
s.email = ["andrew.vos@gmail.com"]
|
11
|
+
s.homepage = ""
|
12
|
+
s.summary = %q{Generates smaller solution files for large enterprisey .NET solutions}
|
13
|
+
s.description = %q{Generates smaller solution files for large enterprisey .NET solutions}
|
14
|
+
|
15
|
+
s.rubyforge_project = "solution-generator"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
s.bindir = 'bin'
|
22
|
+
s.add_dependency 'nokogiri'
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: solution-generator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Andrew Vos
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-07-04 00:00:00 +01:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: nokogiri
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
31
|
+
type: :runtime
|
32
|
+
version_requirements: *id001
|
33
|
+
description: Generates smaller solution files for large enterprisey .NET solutions
|
34
|
+
email:
|
35
|
+
- andrew.vos@gmail.com
|
36
|
+
executables:
|
37
|
+
- solution-generator
|
38
|
+
extensions: []
|
39
|
+
|
40
|
+
extra_rdoc_files: []
|
41
|
+
|
42
|
+
files:
|
43
|
+
- .gitignore
|
44
|
+
- Gemfile
|
45
|
+
- README.md
|
46
|
+
- Rakefile
|
47
|
+
- bin/solution-generator
|
48
|
+
- lib/solution-generator.rb
|
49
|
+
- lib/solution-generator/version.rb
|
50
|
+
- solution-generator.gemspec
|
51
|
+
has_rdoc: true
|
52
|
+
homepage: ""
|
53
|
+
licenses: []
|
54
|
+
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
segments:
|
66
|
+
- 0
|
67
|
+
version: "0"
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
segments:
|
74
|
+
- 0
|
75
|
+
version: "0"
|
76
|
+
requirements: []
|
77
|
+
|
78
|
+
rubyforge_project: solution-generator
|
79
|
+
rubygems_version: 1.3.7
|
80
|
+
signing_key:
|
81
|
+
specification_version: 3
|
82
|
+
summary: Generates smaller solution files for large enterprisey .NET solutions
|
83
|
+
test_files: []
|
84
|
+
|