gimmi
7/12/2013 - 2:14 PM

create_nuget_cfg

import os, glob, shutil, subprocess

base_path = os.path.join(os.getcwd(), 'GesDB')
pkgs_path = os.path.join(base_path, 'packages')

os.path.relpath('c:\sviluppo\dir\packages', 'c:\sviluppo\dir')

for sln_path, directories, files in os.walk(base_path):
  if not [f for f in files if f.lower().endswith(".sln")]: continue

	pkgs_rel_path = os.path.relpath(pkgs_path, sln_path)

	print(sln_path + ' => ' + pkgs_rel_path)

	cfg_content = """\
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <config>
    <add key="repositoryPath" value="%s" />
  </config>
</configuration>
""" % pkgs_rel_path

	with open(os.path.join(sln_path, 'NuGet.config'), 'w') as f:
		f.write(cfg_content)