23. December 2012
Hendrik
General
For the DeltaEngine we're using NuGet to manage our third-party dependencies.
The problem is that only Visual Studio 2010 Pro or Visual Studio 2012 (all editions) supporting automatic restore,
other IDE's like SharpDevelop or MonoDevelop are not supported.
By default you can install all references of a Visual Studio project inside a solution like this:
nuget.exe install project-folder\packages.config
However, normally you have more than one project inside a solution and all this "packages.config" references are aggregated inside a "packages\repositories.config" file like this:
<repositories>
<repository path="..\Core\Tests\packages.config" />
</repositories>
Sadly, installing directly from a "repositories.config" like with a "packages.config is not possible
To overcome this problem I created this little PowerShell script that iterate each reference inside the XML file and execute the install command for every "packages.config" file.
Note that you have to download and copy the nuget.exe commandline version from CodePlex and copy it inside the ".nuget" directory of your solution to make it work.
Now simply copy this script inside the root of you solution and execute it (look here if local script execution is disabled on you system):
Function InstallPackages($packagesConfigPath)
{
$nugetInstallCmd = "..\.nuget\nuget.exe install ""{0}""" -f $packagesConfigPath
Invoke-Expression $nugetInstallCmd
}
Function IterateRepositoriesAndInstall
{
[xml]$repositoriesConfig = Get-Content .\repositories.config
foreach( $repository in $repositoriesConfig.repositories.repository)
{
InstallPackages($repository.path)
}
}
Function ShowInstallInstructions
{
Write-Warning "nuget.exe not found! Pleas download the commandline version from ""http://nuget.codeplex.com/releases"" and copy it inside the "".nuget"" directory."
Read-Host
}
Set-Location .\packages
if (Test-Path ..\.nuget\nuget.exe)
{
IterateRepositoriesAndInstall
}
else
{
ShowInstallInstructions
}