Skip to content

Instantly share code, notes, and snippets.

@AnthonyMastrean
Created September 27, 2012 21:32
Show Gist options
  • Save AnthonyMastrean/3796590 to your computer and use it in GitHub Desktop.
Save AnthonyMastrean/3796590 to your computer and use it in GitHub Desktop.
Automatic discovery of NuGet dependencies.
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
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="StructureMap" version="2.5.2" />
<package id="Machine.Specifications" version="0.5" />
</packages>
nuspec :create_nuspec do |nuspec|
nuspec.auto_add_dependencies FileList['./source/**/*.csproj']
end
@AnthonyMastrean
Copy link
Author

For this Albacore issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment