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

Fix dotnet add package doesn't work with relative path source or when version is not specified #3783

Merged
merged 31 commits into from
Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f1a52d0
Fix 'dotnet add package' with user supplied source feed works if no v…
erdembayar Dec 1, 2020
b1994d9
Prevent from user enter duplicate source from cli.
erdembayar Dec 1, 2020
5ebec22
Add unit tests for 'dotnet pack Package' command with user supplied s…
erdembayar Dec 3, 2020
f2e4d5d
Fix test breaking on Linux.
erdembayar Dec 3, 2020
29632d9
2nd attempt to fix unit test failing on Linux.
erdembayar Dec 3, 2020
d810d92
Fix failing Linux unit test3.
erdembayar Dec 3, 2020
35c2426
Remove unneeded utility method.
erdembayar Dec 3, 2020
528f0cd
Address PR review by Nikolche.
erdembayar Dec 5, 2020
c2c9692
Implemented V2 unget source feed instead of V3 source feed for unit t…
erdembayar Dec 5, 2020
b5ab7ca
Correct conflicting FindLocalPackagesResourceV2Provider, FindLocalPac…
erdembayar Dec 8, 2020
cbd7a36
Fix relative path is not discovered when resolving package from local.
erdembayar Dec 9, 2020
1a9398e
Add more unit test covering all possible scenarios.
erdembayar Dec 9, 2020
586e3ab
Fix Linux unit tests.
erdembayar Dec 10, 2020
a87d7f2
Remove unneeded changes.
erdembayar Dec 18, 2020
7a8f91c
Add passed sources into dgSpec sources.
erdembayar Dec 21, 2020
6deb739
Refactor code: Instead of add source we replace source in dgSpec file.
erdembayar Dec 21, 2020
3a1b6f1
Revert other feed provider problem fix which need to go in seperate PR.
erdembayar Dec 21, 2020
86a56b8
Address code review comments by Nikolche.
erdembayar Dec 22, 2020
f4224c2
Address latest code review comment
erdembayar Dec 22, 2020
eabc100
Instead of relative to project directory, now resolve sources relativ…
erdembayar Jan 1, 2021
aabcaf5
Start moving dotnet relative source tests to dotnet integration tests.
erdembayar Jan 5, 2021
a901f57
Move another dotnet relative source test into dotnet.integration.test
erdembayar Jan 6, 2021
73a3141
Fix empty source passed situation for dotnet add package.
erdembayar Jan 6, 2021
f46d327
Test additional frameworks
erdembayar Jan 6, 2021
3646937
Finish moving dotnet relative source unit tests to dotnet.integration…
erdembayar Jan 6, 2021
f4598c1
Fix new unit test names.
erdembayar Jan 6, 2021
4943245
Address PR review by Nkolche.
erdembayar Jan 7, 2021
ec6c73f
Remove unused `sources` parameter passed down.
erdembayar Jan 7, 2021
8f797e1
Remove V2 sourcefeed unit tests
erdembayar Jan 8, 2021
c9e4a0f
Revert unused file change.
erdembayar Jan 8, 2021
514e29b
Merge branch 'dev' into dev-eryondon-package-incompatible-allframworks
erdembayar Jan 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,22 @@ 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>();
Copy link
Member

Choose a reason for hiding this comment

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

naming: sources, not sourcepaths. These can be http sources, not necessarily paths.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. Renamed to sources.


if (packageReferenceArgs.Sources?.Any() == true)
{
foreach (string source in packageReferenceArgs.Sources)
{
sourcePaths.Add(UriUtility.GetAbsolutePath(Environment.CurrentDirectory, source));
erdembayar marked this conversation as resolved.
Show resolved Hide resolved
}

originalPackageSpec.RestoreMetadata.Sources =
sourcePaths.Where(ns => !string.IsNullOrEmpty(ns))
.Select(ns => new PackageSource(ns))
.ToList();
}

PackageDependency packageDependency = default;
if (packageReferenceArgs.NoVersion)
{
Expand Down Expand Up @@ -149,7 +165,7 @@ public async Task<int> ExecuteCommand(PackageReferenceArgs packageReferenceArgs,
packageReferenceArgs.Logger.LogDebug("Running Restore preview");

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

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

Expand Down Expand Up @@ -308,7 +324,7 @@ private static LibraryDependency GenerateLibraryDependency(
}

private static async Task<RestoreResultPair> PreviewAddPackageReferenceAsync(PackageReferenceArgs packageReferenceArgs,
DependencyGraphSpec dgSpec)
DependencyGraphSpec dgSpec, List<string> sourcePaths)
{
// Set user agent and connection settings.
XPlatUtility.ConfigureProtocol();
Expand All @@ -334,7 +350,7 @@ private static async Task<RestoreResultPair> PreviewAddPackageReferenceAsync(Pac
MachineWideSettings = new XPlatMachineWideSetting(),
GlobalPackagesFolder = packageReferenceArgs.PackageDirectory,
PreLoadedRequestProviders = providers,
Sources = packageReferenceArgs.Sources?.ToList()
Sources = sourcePaths
Copy link
Member

Choose a reason for hiding this comment

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

tbh, you can cut this. It's not used anyways. We should probably mark it as not used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added comment here for why we're not passing value down here.

};

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