Resolves assemblies referenced by NuGet packages used by the function.
Пример #1
0
        public async Task RestorePackagesAsync()
        {
            var packageManager = new PackageManager(_functionMetadata, _traceWriter);
            await packageManager.RestorePackagesAsync();

            // Reload the resolver
            _packageAssemblyResolver = new PackageAssemblyResolver(_functionMetadata);
        }
 public FunctionMetadataResolver(FunctionMetadata metadata, TraceWriter traceWriter)
 {
     _functionMetadata        = metadata;
     _traceWriter             = traceWriter;
     _packageAssemblyResolver = new PackageAssemblyResolver(metadata);
     _privateAssembliesPath   = GetBinDirectory(metadata);
     _scriptResolver          = ScriptMetadataResolver.Default.WithSearchPaths(_privateAssembliesPath);
 }
 public FunctionMetadataResolver(FunctionMetadata metadata, TraceWriter traceWriter)
 {
     _functionMetadata = metadata;
     _traceWriter = traceWriter;
     _packageAssemblyResolver = new PackageAssemblyResolver(metadata);
     _privateAssembliesPath = GetBinDirectory(metadata);
     _scriptResolver = ScriptMetadataResolver.Default.WithSearchPaths(_privateAssembliesPath);
 }
Пример #4
0
 public FunctionMetadataResolver(FunctionMetadata metadata, Collection <ScriptBindingProvider> bindingProviders, TraceWriter traceWriter)
 {
     _functionMetadata                = metadata;
     _traceWriter                     = traceWriter;
     _packageAssemblyResolver         = new PackageAssemblyResolver(metadata);
     _privateAssembliesPath           = GetBinDirectory(metadata);
     _scriptResolver                  = ScriptMetadataResolver.Default.WithSearchPaths(_privateAssembliesPath);
     _extensionSharedAssemblyProvider = new ExtensionSharedAssemblyProvider(bindingProviders);
 }
 public FunctionMetadataResolver(FunctionMetadata metadata, ICollection<ScriptBindingProvider> bindingProviders, TraceWriter traceWriter)
 {
     _functionMetadata = metadata;
     _traceWriter = traceWriter;
     _packageAssemblyResolver = new PackageAssemblyResolver(metadata);
     _privateAssembliesPath = GetBinDirectory(metadata);
     _scriptResolver = ScriptMetadataResolver.Default.WithSearchPaths(_privateAssembliesPath);
     _extensionSharedAssemblyProvider = new ExtensionSharedAssemblyProvider(bindingProviders);
 }
Пример #6
0
 public FunctionMetadataResolver(string scriptFilePath, ICollection <ScriptBindingProvider> bindingProviders, ILogger logger)
 {
     _scriptFileDirectory             = Path.GetDirectoryName(scriptFilePath);
     _scriptFilePath                  = scriptFilePath;
     _packageAssemblyResolver         = new PackageAssemblyResolver(_scriptFileDirectory);
     _privateAssembliesPath           = GetBinDirectory(_scriptFileDirectory);
     _scriptResolver                  = ScriptMetadataResolver.Default.WithSearchPaths(_privateAssembliesPath);
     _extensionSharedAssemblyProvider = new ExtensionSharedAssemblyProvider(bindingProviders);
     _logger = logger;
 }
Пример #7
0
        public async Task <PackageRestoreResult> RestorePackagesAsync()
        {
            var packageManager          = new PackageManager(_scriptFileDirectory, _logger);
            PackageRestoreResult result = await packageManager.RestorePackagesAsync();

            // Reload the resolver
            _packageAssemblyResolver = new PackageAssemblyResolver(_scriptFileDirectory);

            return(result);
        }
        public async Task <PackageRestoreResult> RestorePackagesAsync()
        {
            var packageManager          = new PackageManager(_functionMetadata, _traceWriter, _loggerFactory);
            PackageRestoreResult result = await packageManager.RestorePackagesAsync();

            // Reload the resolver
            _packageAssemblyResolver = new PackageAssemblyResolver(_functionMetadata);

            return(result);
        }
 public FunctionMetadataResolver(string scriptFileDirectory, ICollection <ScriptBindingProvider> bindingProviders, TraceWriter traceWriter, ILoggerFactory loggerFactory)
 {
     _scriptFileDirectory             = scriptFileDirectory;
     _traceWriter                     = traceWriter;
     _packageAssemblyResolver         = new PackageAssemblyResolver(scriptFileDirectory);
     _privateAssembliesPath           = GetBinDirectory(scriptFileDirectory);
     _scriptResolver                  = ScriptMetadataResolver.Default.WithSearchPaths(_privateAssembliesPath);
     _extensionSharedAssemblyProvider = new ExtensionSharedAssemblyProvider(bindingProviders);
     _loggerFactory                   = loggerFactory;
 }
        public void GivenPackagesWithAssemblyReferences_AssemblyReferencesAreResolved()
        {
            var functionMetadata = new FunctionMetadata()
            {
                Name = "TestFunction",
                ScriptFile = _lockFilePath, /*We just need the path from this*/
                ScriptType = ScriptType.CSharp
            };

            var assemblyResolver = new PackageAssemblyResolver(functionMetadata);

            string nugetHome = PackageManager.GetNugetPackagesPath();

            Assert.Contains<string>(_targetAssemblyFilePath, assemblyResolver.AssemblyReferences);
        }
        public void GivenLockFile_PackageReferencesAreResolved()
        {
            var functionMetadata = new FunctionMetadata()
            {
                Name = "TestFunction",
                ScriptFile = _lockFilePath, /*We just need the path from this*/
                ScriptType = ScriptType.CSharp
            };

            var assemblyResolver = new PackageAssemblyResolver(functionMetadata);

            PackageReference package = assemblyResolver.Packages.Single();

            Assert.Equal("Test.Package", package.Name);
            Assert.Equal("1.0.0", package.Version);
            Assert.Equal(1, package.Assemblies.Count);
            Assert.Equal(2, package.FrameworkAssemblies.Count);
        }
        public void GivenPackagesWithFrameworkReferences_FrameworkReferencesAreResolved()
        {
            var functionMetadata = new FunctionMetadata()
            {
                Name = "TestFunction",
                ScriptFile = _lockFilePath, /*We just need the path from this*/
                ScriptType = ScriptType.CSharp
            };

            var assemblyResolver = new PackageAssemblyResolver(functionMetadata);

            Assert.Contains<string>("System.Net.Http", assemblyResolver.AssemblyReferences);
            Assert.Contains<string>("System.Net.Http.WebRequest", assemblyResolver.AssemblyReferences);
        }
        public void TryResolveAssembly_WithReferencedFrameworkAssemblyName_ResolvesAssemblyAndReturnsTrue()
        {
            var functionMetadata = new FunctionMetadata()
            {
                Name = "TestFunction",
                ScriptFile = _lockFilePath, /*We just need the path from this*/
                ScriptType = ScriptType.CSharp
            };

            var assemblyResolver = new PackageAssemblyResolver(functionMetadata);

            string assemblyPath;
            bool result = assemblyResolver.TryResolveAssembly("System.Net.Http", out assemblyPath);

            Assert.True(result);
            Assert.Equal("System.Net.Http", assemblyPath);
        }
        public void TryResolveAssembly_WithReferencedAssemblyName_ResolvesAssemblyPathAndReturnsTrue()
        {
            var functionMetadata = new FunctionMetadata()
            {
                Name = "TestFunction",
                ScriptFile = _lockFilePath, /*We just need the path from this*/
                ScriptType = ScriptType.CSharp
            };

            var assemblyResolver = new PackageAssemblyResolver(functionMetadata);

            string assemblyPath;
            bool result = assemblyResolver.TryResolveAssembly(this.GetType().Assembly.FullName, out assemblyPath);

            Assert.True(result);
            Assert.Equal(_targetAssemblyFilePath, assemblyPath);
        }
        public async Task RestorePackagesAsync()
        {
            var packageManager = new PackageManager(_functionMetadata, _traceWriter);
            await packageManager.RestorePackagesAsync();

            // Reload the resolver
            _packageAssemblyResolver = new PackageAssemblyResolver(_functionMetadata);
        }