Skip to content

Instantly share code, notes, and snippets.

@stefan-pdx
Last active February 6, 2019 11:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stefan-pdx/9572d5c5aec284e3cadb1f1909f70470 to your computer and use it in GitHub Desktop.
Save stefan-pdx/9572d5c5aec284e3cadb1f1909f70470 to your computer and use it in GitHub Desktop.
require 'nokogiri'
namespace 'conan' do
desc 'Export Conan binary directories to the CONAN_BINARY_DIRECTORIES environment variable'
task :export_env do
doc = File.open('conanbuildinfo.props') { |f| Nokogiri::XML(f) }
paths = doc.search("ConanBinaryDirectories").first.text
`setx.exe CONAN_BINARY_DIRECTORIES "#{paths}"`
end
end
@stefan-pdx
Copy link
Author

stefan-pdx commented Jun 12, 2018

This Rakefile can be used to parse through the Visual Studio property sheet generated by Conan (conanbuildinfo.props) and extract out the directory paths containing any binaries (i.e., .dlls) and set the CONAN_BINARY_DIRECTORIES environmental variable. This allows a Visual Studio project to link with runtime dependencies which is useful for running tests.

To use it, simply place this file in your project folder, install Nokogiri (gem install nokogiri), and run rake conan:export_env. Cheers!

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