Skip to content

Instantly share code, notes, and snippets.

@wallymathieu
Created August 26, 2015 08:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wallymathieu/b1694060b65fa3c7153e to your computer and use it in GitHub Desktop.
Save wallymathieu/b1694060b65fa3c7153e to your computer and use it in GitHub Desktop.
Howto add links from one projects files into another project
require 'visual_studio_files' # https://rubygems.org/gems/visual_studio_files
desc "regenerate links in project X"
task :regen_links do
project_y = VisualStudioFiles::CsProj.new(File.open(File.join($dir,'ProjectY','ProjectY.csproj'), "r").read)
project_y_files = v.files.select do |file|
file.type=='Compile' && !file.file.end_with?('AssemblyInfo.cs')
end
project_x = VisualStudioFiles::CsProj.new(File.open(File.join($dir,'ProjectX','ProjectX.csproj'), "r").read)
project_x.clear_links
project_y_files.each do |file|
hash = file.to_hash
hash[:file] = "..\\ProjectX\\#{file.file}"
hash[:link] = "ProjectX\\#{file.file}"
project_x.add(hash)
end
File.open(File.join($dir,'ProjectX','ProjectX.csproj'), "w") do |f|
project_x.write f
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment