-
Notifications
You must be signed in to change notification settings - Fork 695
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
erdembayar
merged 31 commits into
dev
from
dev-eryondon-package-incompatible-allframworks
Jan 12, 2021
Merged
Fix dotnet add package doesn't work with relative path source or when version is not specified #3783
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 b1994d9
Prevent from user enter duplicate source from cli.
erdembayar 5ebec22
Add unit tests for 'dotnet pack Package' command with user supplied s…
erdembayar f2e4d5d
Fix test breaking on Linux.
erdembayar 29632d9
2nd attempt to fix unit test failing on Linux.
erdembayar d810d92
Fix failing Linux unit test3.
erdembayar 35c2426
Remove unneeded utility method.
erdembayar 528f0cd
Address PR review by Nikolche.
erdembayar c2c9692
Implemented V2 unget source feed instead of V3 source feed for unit t…
erdembayar b5ab7ca
Correct conflicting FindLocalPackagesResourceV2Provider, FindLocalPac…
erdembayar cbd7a36
Fix relative path is not discovered when resolving package from local.
erdembayar 1a9398e
Add more unit test covering all possible scenarios.
erdembayar 586e3ab
Fix Linux unit tests.
erdembayar a87d7f2
Remove unneeded changes.
erdembayar 7a8f91c
Add passed sources into dgSpec sources.
erdembayar 6deb739
Refactor code: Instead of add source we replace source in dgSpec file.
erdembayar 3a1b6f1
Revert other feed provider problem fix which need to go in seperate PR.
erdembayar 86a56b8
Address code review comments by Nikolche.
erdembayar f4224c2
Address latest code review comment
erdembayar eabc100
Instead of relative to project directory, now resolve sources relativ…
erdembayar aabcaf5
Start moving dotnet relative source tests to dotnet integration tests.
erdembayar a901f57
Move another dotnet relative source test into dotnet.integration.test
erdembayar 73a3141
Fix empty source passed situation for dotnet add package.
erdembayar f46d327
Test additional frameworks
erdembayar 3646937
Finish moving dotnet relative source unit tests to dotnet.integration…
erdembayar f4598c1
Fix new unit test names.
erdembayar 4943245
Address PR review by Nkolche.
erdembayar ec6c73f
Remove unused `sources` parameter passed down.
erdembayar 8f797e1
Remove V2 sourcefeed unit tests
erdembayar c9e4a0f
Revert unused file change.
erdembayar 514e29b
Merge branch 'dev' into dev-eryondon-package-incompatible-allframworks
erdembayar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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>(); | ||
|
||
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) | ||
{ | ||
|
@@ -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"); | ||
|
||
|
@@ -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(); | ||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Renamed to
sources
.