Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements for nuget.exe install #1634

Merged
merged 1 commit into from
Aug 12, 2017
Merged

Improvements for nuget.exe install #1634

merged 1 commit into from
Aug 12, 2017

Conversation

emgarten
Copy link
Member

@emgarten emgarten commented Aug 10, 2017

Improvements for nuget.exe install

  • Allow updating packages when -ExcludeVersion is used
  • Improved detection of already installed packages when -ExcludeVersion is used
  • Adding -Framework switch to allow setting the target framework used when resolving dependencies.
  • Remove NU1000 code from packages.config restore errors.
  • Avoid unneeded downloads when a version is not given and the package is cached.
  • Disable parallel for mono
  • Display errors and return a non-zero exit when install on packages.config fails
  • Remove old files during upgrades with -ExcludeVersion
  • Adding tests for nuget.exe install -ExcludeVersion scenarios and failure cases.
  • Improving current nuget.exe install tests to avoid packages getting shared through the global packages folder.
  • Removing old skipped install command tests that no longer apply
  • Re-enabling caching test for install

Fixes NuGet/Home#5743
Fixes NuGet/Home#5737
Fixes NuGet/Home#5736
Fixes NuGet/Home#5741
Fixes NuGet/Home#5017
Fixes NuGet/Home#3957
Fixes NuGet/Home#2405
Partial fix for NuGet/Home#3244

@mishra14
Copy link
Contributor

mishra14 commented Aug 10, 2017

@emgarten not so great if it doesn't build!! :P

@nkolev92
Copy link
Member

@mishra14 I assume that's why it's a WIP :P

@emgarten emgarten force-pushed the dev-emgarten-cmdInstall branch 2 times, most recently from e434394 to 6d5bed7 Compare August 11, 2017 06:49
@emgarten emgarten changed the title [WIP] the great nuget.exe install clean up Improvements for nuget.exe install Aug 11, 2017
@emgarten
Copy link
Member Author

Tests are passing on teamcity

CultureInfo.CurrentCulture,
LocalizedResourceManager.GetString("RestoreCommandPackageRestoreOptOutMessage"),
NuGetResources.PackageRestoreConsentCheckBoxText.Replace("&", ""));
Console.WriteLine(message);
}

return PerformV2Restore(configFilePath, installPath);
return PerformV2RestoreAsync(configFilePath, installPath);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not await here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it returns the task and is awaited higher up

}
else
{
var packageId = Arguments[0];
var version = Version != null ? new NuGetVersion(Version) : null;
return InstallPackage(packageId, version, installPath);
return InstallPackageAsync(packageId, version, installPath);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also returning the task

@@ -45,6 +45,11 @@ public ICollection<string> Source
[Option(typeof(NuGetCommand), "CommandPackageSaveMode")]
public string PackageSaveMode { get; set; }

/// <summary>
/// If true the global packages folder will be added as a source.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If true the global packages folder will not be added as a source

@@ -117,7 +122,7 @@ protected IReadOnlyCollection<Configuration.PackageSource> GetPackageSources(Con
var availableSources = SourceProvider.LoadPackageSources().Where(source => source.IsEnabled);
var packageSources = new List<Configuration.PackageSource>();

if (!NoCache)
if (!NoCache && !ExcludeCacheAsSource)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "NoCache" also used in other place? why can't just use "NoCache" to exclude cache

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ExcludeCacheAsSource is a subset of NoCache

var packageReference = installedPackagesList.Where(p => p.PackageIdentity.Equals(packageIdentity)).FirstOrDefault();
if (packageReference == null)
{
// Package does not exit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exist

Copy link
Contributor

@mishra14 mishra14 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how will people realize how ExcludeCacheAsSource work?

@@ -198,6 +207,17 @@ internal string ResolveInstallPath()
{
GetDownloadResultUtility.CleanUpDirectDownloads(downloadContext);
}

if (!result.Restored || failedEvents.Count > 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

// Avoid searching for the highest version in the global packages folder,
// it needs to come from the feeds instead. Once found it may come from
// the global packages folder unless NoCache is true.
ExcludeCacheAsSource = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems a bit arbitrary. how will people realize what is the resolution logic?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed offline. This is fine as we set ExcludeCacheAsSource only if we see floating versions in the dependency list.

@@ -333,7 +333,7 @@ private void ReadSettings(PackageRestoreInputs packageRestoreInputs)
Settings.Priority.Select(x => Path.Combine(x.Root, x.FileName)),
packageSources.Select(x => x.Source),
installCount,
collectorLogger.Errors.Concat(failedEvents.Select(e => new RestoreLogMessage(LogLevel.Error, e.Exception.Message))));
collectorLogger.Errors.Concat(failedEvents.Select(e => new RestoreLogMessage(LogLevel.Error, NuGetLogCode.Undefined, e.Exception.Message))));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

/// <exception cref="ArgumentNullException">Thrown if <paramref name="targetFramework" /> is <c>null</c>.</exception>
public FolderNuGetProject(string root, PackagePathResolver packagePathResolver, NuGetFramework targetFramework)
{
if (targetFramework == null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: simplify these just as root and packagePathResolver

Copy link
Contributor

@mishra14 mishra14 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed offline. Looks good

* Allow updating packages when -ExcludeVersion is used
* Improved detection of already installed packages when -ExcludeVersion is used
* Adding -Framework switch to allow setting the target framework used when resolving dependencies.
* Remove NU1000 code from packages.config restore errors.
* Avoid unneeded downloads when a version is not given and the package is cached.
* Disable parallel for mono
* Display errors and return a non-zero exit when install on packages.config fails
* Remove old files during upgrades with -ExcludeVersion

Fixes NuGet/Home#5743
Fixes NuGet/Home#5737
Fixes NuGet/Home#5736
Fixes NuGet/Home#5741
Fixes NuGet/Home#5017
Fixes NuGet/Home#3957
Fixes NuGet/Home#2405
@emgarten emgarten merged commit 5b6edbb into dev Aug 12, 2017
@emgarten emgarten deleted the dev-emgarten-cmdInstall branch August 12, 2017 02:50
hickford added a commit to hickford/docs.microsoft.com-nuget that referenced this pull request Nov 3, 2017
NuGet/NuGet.Client#1634 introduced a Framework option for the install command.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants