private string[] ProcessScriptFiles(RuntimeLibrary runtimeLibrary, string[] nugetPackageFolders, bool restorePackages)
 {
     if (restorePackages)
     {
         return(_scriptFilesDependencyResolver.GetScriptFileDependencies(runtimeLibrary.Path, nugetPackageFolders));
     }
     else
     {
         // If restorePackages are false, it means we are running from a DLL
         // and the scripts from the script packages are already compiled into the DLL
         // NOTE: This whole class needs some cleanup.
         return(Array.Empty <string>());
     }
 }
        public IEnumerable <CompilationDependency> GetDependencies(string targetDirectory, bool enableScriptNugetReferences, string defaultTargetFramework = "net46")
        {
            var pathToProjectFile = _scriptProjectProvider.CreateProject(targetDirectory, defaultTargetFramework,
                                                                         enableScriptNugetReferences);

            if (pathToProjectFile == null)
            {
                return(Array.Empty <CompilationDependency>());
            }

            var dependencyInfo = _scriptDependencyInfoProvider.GetDependencyInfo(pathToProjectFile, Array.Empty <string>());

            var dependencyContext = dependencyInfo.DependencyContext;

            var compilationAssemblyResolvers = GetCompilationAssemblyResolvers(dependencyInfo.NugetPackageFolders);


            List <CompilationDependency> result = new List <CompilationDependency>();
            var compileLibraries = dependencyContext.CompileLibraries;

            foreach (var compilationLibrary in compileLibraries)
            {
                var resolvedReferencePaths = new HashSet <string>();
                _logger.Debug($"Resolving compilation reference paths for {compilationLibrary.Name}");
                var referencePaths = ResolveReferencePaths(compilationLibrary, compilationAssemblyResolvers);
                var scripts        =
                    _scriptFilesDependencyResolver.GetScriptFileDependencies(compilationLibrary.Path, dependencyInfo.NugetPackageFolders);
                foreach (var referencePath in referencePaths)
                {
                    resolvedReferencePaths.Add(referencePath);
                }
                var compilationDependency = new CompilationDependency(
                    compilationLibrary.Name,
                    compilationLibrary.Version,
                    resolvedReferencePaths.ToList(),
                    scripts);

                result.Add(compilationDependency);
            }
            return(result);
        }
Beispiel #3
0
 private string[] ProcessScriptFiles(RuntimeLibrary runtimeLibrary, string[] nugetPackageFolders)
 {
     return(_scriptFilesDependencyResolver.GetScriptFileDependencies(runtimeLibrary.Path, nugetPackageFolders));
 }