Merge pull request #9137 from peterhuene/relative-sources

Fix --source-feed option for tool install and update commands.
This commit is contained in:
Peter Huene 2018-04-30 14:46:50 -07:00 committed by GitHub
commit 56d8103181
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 55 additions and 1 deletions

View file

@ -161,7 +161,17 @@ namespace Microsoft.DotNet.ToolPackage
var feeds = new List<string>(); var feeds = new List<string>();
if (additionalFeeds != null) if (additionalFeeds != null)
{ {
feeds.AddRange(additionalFeeds); foreach (var feed in additionalFeeds)
{
if (Uri.IsWellFormedUriString(feed, UriKind.Absolute))
{
feeds.Add(feed);
}
else
{
feeds.Add(Path.GetFullPath(feed));
}
}
} }
// use fallbackfolder as feed to enable offline // use fallbackfolder as feed to enable offline

View file

@ -259,6 +259,50 @@ namespace Microsoft.DotNet.ToolPackage.Tests
package.Uninstall(); package.Uninstall();
} }
[Theory]
[InlineData(false)]
[InlineData(true)]
public void GivenARelativeSourcePathInstallSucceeds(bool testMockBehaviorIsInSync)
{
var source = GetTestLocalFeedPath();
var (store, installer, reporter, fileSystem) = Setup(
useMock: testMockBehaviorIsInSync,
feeds: GetMockFeedsForSource(source));
var package = installer.InstallPackage(
packageId: TestPackageId,
versionRange: VersionRange.Parse(TestPackageVersion),
targetFramework: _testTargetframework,
additionalFeeds: new[] { Path.GetRelativePath(Directory.GetCurrentDirectory(), source) });
AssertPackageInstall(reporter, fileSystem, package, store);
package.Uninstall();
}
[Theory]
[InlineData(false)]
[InlineData(true)]
public void GivenAUriSourceInstallSucceeds(bool testMockBehaviorIsInSync)
{
var source = GetTestLocalFeedPath();
var (store, installer, reporter, fileSystem) = Setup(
useMock: testMockBehaviorIsInSync,
feeds: GetMockFeedsForSource(source));
var package = installer.InstallPackage(
packageId: TestPackageId,
versionRange: VersionRange.Parse(TestPackageVersion),
targetFramework: _testTargetframework,
additionalFeeds: new[] { new Uri(source).AbsoluteUri });
AssertPackageInstall(reporter, fileSystem, package, store);
package.Uninstall();
}
[Theory] [Theory]
[InlineData(false)] [InlineData(false)]
[InlineData(true)] [InlineData(true)]