示例#1
0
        public CustomAssemblyResolver(DirectoryInfo assemblyDirectory, ILogger logger)
        {
            _logger = logger;

            foreach (var searchDirectory in GetSearchDirectories())
            {
                RemoveSearchDirectory(searchDirectory);
            }

            AddSearchDirectory(assemblyDirectory.FullName);

            _dependencyContext = DepsJsonUtils.LoadDependencyContext(assemblyDirectory);

            var runtimeConfigPath = assemblyDirectory.GetFiles("*.runtimeconfig.dev.json", SearchOption.TopDirectoryOnly)
                                    .Concat(assemblyDirectory.GetFiles("*.runtimeconfig.json", SearchOption.TopDirectoryOnly))
                                    .FirstOrDefault();

            if (runtimeConfigPath != null)
            {
                var runtimeConfigContent = File.ReadAllText(runtimeConfigPath.FullName);
                foreach (var path in DepsJsonUtils.GetAdditionalPaths(runtimeConfigContent))
                {
                    AddSearchDirectory(path);
                }
            }
        }
示例#2
0
        public void GetAdditionalPaths_RuntimeConfigContext_PathsReturned()
        {
            var runtimeConfigContent = @"{
  ""runtimeOptions"": {
    ""additionalProbingPaths"": [
      ""/root/.dotnet/store/|arch|/|tfm|"",
      ""/api/.nuget/packages"",
      ""/usr/share/dotnet/sdk/NuGetFallbackFolder""
    ]
    }
}";

            var result = DepsJsonUtils.GetAdditionalPaths(runtimeConfigContent);

            result.Should().NotBeEmpty();
            result.Count.Should().Be(2);
            result.Should().Contain("/api/.nuget/packages");
            result.Should().Contain("/usr/share/dotnet/sdk/NuGetFallbackFolder");
        }
        public CustomAssemblyResolver(string assemblyDirectory)
        {
            RemoveSearchDirectory(".");
            RemoveSearchDirectory("bin");

            AddSearchDirectory(assemblyDirectory);

            _dependencyContext = DepsJsonUtils.LoadDependencyContext(assemblyDirectory);

            var runtimeConfigPath = Directory.GetFiles(assemblyDirectory, "*.runtimeconfig.dev.json", SearchOption.TopDirectoryOnly)
                                    .FirstOrDefault();

            if (runtimeConfigPath != null)
            {
                var runtimeConfigContent = File.ReadAllText(runtimeConfigPath);
                foreach (var path in DepsJsonUtils.GetAdditionalPaths(runtimeConfigContent))
                {
                    AddSearchDirectory(path);
                }
            }
        }
示例#4
0
        public void GetAdditionalPaths_EmptyObject_NoError()
        {
            var result = DepsJsonUtils.GetAdditionalPaths(@"{}");

            result.Should().BeEmpty();
        }
示例#5
0
        public void GetAdditionalPaths_EmptyRuntimeConfigContext_NoError()
        {
            var result = DepsJsonUtils.GetAdditionalPaths(string.Empty);

            result.Should().BeEmpty();
        }