directories.Add(sharedDirectory);
}
+ var paths = new List<string>();
+
foreach (var assembly in library.Assemblies)
{
bool resolved = false;
string fullName;
if (ResolverUtils.TryResolveAssemblyFile(_fileSystem, directory, assemblyFile, out fullName))
{
- assemblies.Add(fullName);
+ paths.Add(fullName);
resolved = true;
break;
}
if (!resolved)
{
- // throw in case when we are published app and nothing found
- // because we cannot rely on nuget package cache in this case
- if (isPublished)
- {
- throw new InvalidOperationException(
- $"Cannot find assembly file {assemblyFile} at '{string.Join(",", directories)}'");
- }
return false;
- }
+ }
}
+ // only modify the assemblies parameter if we've resolved all files
+ assemblies?.AddRange(paths);
return true;
}
}
var resolver = CreateResolver(fileSystem);
var assemblies = new List<string>();
- var exception = Assert.Throws<InvalidOperationException>(() => resolver.TryResolveAssemblyPaths(library, assemblies));
- exception.Message.Should()
- .Contain(BasePath)
- .And.Contain(BasePathRefs)
- .And.Contain(TestLibraryFactory.SecondAssembly);
+ resolver.TryResolveAssemblyPaths(library, assemblies).Should().Be(false);
+ assemblies.Should().BeEmpty();
}
[Fact]
}
[Fact]
- public void ShouldThrowForNonResolvedInPublishedApps()
+ public void ShouldReturnFalseForNonResolvedInPublishedApps()
{
var fileSystem = FileSystemMockBuilder
.Create()
var resolver = CreateResolver(fileSystem);
var assemblies = new List<string>();
- Assert.Throws<InvalidOperationException>(() => resolver.TryResolveAssemblyPaths(library, assemblies));
+ resolver.TryResolveAssemblyPaths(library, assemblies).Should().Be(false);
+ assemblies.Should().BeEmpty();
}
[Fact]