Created
September 27, 2012 21:32
-
-
Save AnthonyMastrean/3796590 to your computer and use it in GitHub Desktop.
Automatic discovery of NuGet dependencies.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def auto_add_dependencies(projects) | |
projects.each do |project| | |
each_project_dependency do |dependency| | |
@dependencies.push dependency | |
end | |
end | |
end | |
def get_packages_config(project) | |
return File.join File.dirname project, 'packages.config' | |
end | |
def each_project_dependency(project) | |
packages_config = get_packages_config project | |
return [] unless File.exists? packages_config | |
each_package packages_config do |id, version| | |
yield Dependency.new id, version | |
end | |
end | |
def each_package(packages_config) | |
xml = File.read packages_config | |
doc = REXML::Document.new xml | |
doc.elements.each 'packages/package' do |package| | |
yield package.attributes['id'], package.attributes['version'] if block_given? | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<packages> | |
<package id="StructureMap" version="2.5.2" /> | |
<package id="Machine.Specifications" version="0.5" /> | |
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nuspec :create_nuspec do |nuspec| | |
nuspec.auto_add_dependencies FileList['./source/**/*.csproj'] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For this Albacore issue.