Skip to content

Commit

Permalink
Address PR review by Nkolche.
Browse files Browse the repository at this point in the history
  • Loading branch information
erdembayar committed Jan 7, 2021
1 parent f4598c1 commit 4943245
Show file tree
Hide file tree
Showing 4 changed files with 522 additions and 416 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,19 @@ public async Task<int> ExecuteCommand(PackageReferenceArgs packageReferenceArgs,
var originalPackageSpec = matchingPackageSpecs.FirstOrDefault();

// Convert relative path to absolute path if there is any
List<string> sourcePaths = new List<string>();
List<string> sources = null;

if (packageReferenceArgs.Sources?.Any() == true)
{
sources = new List<string>();

foreach (string source in packageReferenceArgs.Sources)
{
sourcePaths.Add(UriUtility.GetAbsolutePath(Environment.CurrentDirectory, source));
sources.Add(UriUtility.GetAbsolutePath(Environment.CurrentDirectory, source));
}

originalPackageSpec.RestoreMetadata.Sources =
sourcePaths.Where(ns => !string.IsNullOrEmpty(ns))
sources.Where(ns => !string.IsNullOrEmpty(ns))
.Select(ns => new PackageSource(ns))
.ToList();
}
Expand Down Expand Up @@ -165,7 +167,7 @@ public async Task<int> ExecuteCommand(PackageReferenceArgs packageReferenceArgs,
packageReferenceArgs.Logger.LogDebug("Running Restore preview");

var restorePreviewResult = await PreviewAddPackageReferenceAsync(packageReferenceArgs,
updatedDgSpec, sourcePaths);
updatedDgSpec, sources);

packageReferenceArgs.Logger.LogDebug("Restore Review completed");

Expand Down Expand Up @@ -349,8 +351,8 @@ private static async Task<RestoreResultPair> PreviewAddPackageReferenceAsync(Pac
Log = packageReferenceArgs.Logger,
MachineWideSettings = new XPlatMachineWideSetting(),
GlobalPackagesFolder = packageReferenceArgs.PackageDirectory,
PreLoadedRequestProviders = providers,
Sources = sourcePaths
PreLoadedRequestProviders = providers
// Sources : No need to pass it, because SourceRepositories contains the already built SourceRepository objects
};

// Generate Restore Requests. There will always be 1 request here since we are restoring for 1 project.
Expand Down
Loading

0 comments on commit 4943245

Please sign in to comment.