Skip to content

Commit

Permalink
Quick fix to ensure that the output packages.config has been updated …
Browse files Browse the repository at this point in the history
…when we are using a -latest flag
  • Loading branch information
BenPhegan committed Jan 14, 2013
1 parent 2b0d2b7 commit dde2577
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions NuGet.Extensions/Commands/Get.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ private void GetByDirectoryPath(IFileSystem baseFileSystem, string target)
else
{
var tempPackageConfig = packageAggregator.Save(packagesConfigDiretory);
if (TeamCityNugetXml)
SaveNuGetXml(tempPackageConfig,TeamCityNuGetXmlOutputDirectory);
InstallPackagesFromConfigFile(packagesConfigDiretory, GetPackageReferenceFile(baseFileSystem, tempPackageConfig.FullName), target);
if (TeamCityNugetXml)
SaveNuGetXml(tempPackageConfig, TeamCityNuGetXmlOutputDirectory);
}
}
});
Expand Down Expand Up @@ -340,6 +340,7 @@ private IPackageRepository GetRepository()
private void InstallPackagesFromConfigFile(string packagesDirectory, PackageReferenceFile file, string target)
{
var packageReferences = file.GetPackageReferences().ToList();
var installedPackages = new List<PackageReference>();

//We need to create a damn filesystem at the packages directory, so that the ROOT is correct. Ahuh...
var fileSystem = CreateFileSystem(packagesDirectory);
Expand Down Expand Up @@ -370,12 +371,14 @@ private void InstallPackagesFromConfigFile(string packagesDirectory, PackageRefe
{
SemanticVersion version = _packageResolutionManager.ResolveInstallableVersion(_repository, packageReference);
installedAny |= InstallPackage(packageManager, fileSystem, packageReference.Id, version ?? packageReference.Version);
installedPackages.Add(new PackageReference(packageReference.Id, version ?? packageReference.Version, null));
}
else
{
//We got it straight from the server, check whether we get a cache hit, else just install
var resolvedPackage = _packageResolutionManager.FindPackageInAllLocalSources(packageManager.LocalRepository, packageManager.SourceRepository, package);
packageManager.InstallPackage(resolvedPackage ?? package, !IncludeDependencies, false);
installedPackages.Add(new PackageReference(package.Id, resolvedPackage != null ? resolvedPackage.Version : package.Version, null));
}
// Note that we ignore dependencies here because packages.config already contains the full closure
}
Expand All @@ -384,6 +387,16 @@ private void InstallPackagesFromConfigFile(string packagesDirectory, PackageRefe
{
Console.WriteLine(GetResources.GetCommandNothingToInstall, Constants.PackageReferenceFile);
}

if (packageReferences != installedPackages)
{
foreach (var reference in file.GetPackageReferences())
file.DeleteEntry(reference.Id, reference.Version);
foreach (var installedPackage in installedPackages)
{
file.AddEntry(installedPackage.Id,installedPackage.Version);
}
}
}


Expand Down

0 comments on commit dde2577

Please sign in to comment.