private static void CompileModules() { if (Compiled) { return; } ToConsole("Compiling Modules..."); TryCatch( () => { var files = ModulesDirectory.GetFiles("*.dll", SearchOption.AllDirectories); var asm = new List <Assembly>(files.Length); foreach (var file in files) { TryCatch(() => asm.AddOrReplace(Assembly.LoadFrom(file.FullName)), ToConsole); } ModuleAssemblies = asm.ToArray(); asm.AddRange(ScriptCompiler.Assemblies); asm.Prune(); ScriptCompiler.Assemblies = asm.FreeToArray(true); }, ToConsole); }
public ModulesViewModel() { _safeModules = new ModuleInfo[0]; _hashBlacklist = new List <string>(); _installModuleDialog = new OpenFileDialog(); _installModuleDialog.Title = "Tanji - Install Module"; _installModuleDialog.Filter = ".NET Assembly (*.dll, *.exe)|*.dll; *.exe|Dynamic Link Library (*.dll)|*.dll|Executable (*.exe)|*.exe"; InstallCommand = new Command(Install); UninstallCommand = new Command(Uninstall, CanUninstall); Modules = new ObservableCollection <ModuleInfo>(); Modules.CollectionChanged += Modules_CollectionChanged; if (App.Master != null) { ModulesDirectory = Directory.CreateDirectory("Installed Modules"); DependenciesDirectory = ModulesDirectory.CreateSubdirectory("Dependencies"); LoadModules(); try { var listener = new TcpListener(IPAddress.Any, TService.REMOTE_MODULE_PORT); listener.Start(); Task captureModulesTask = CaptureModulesAsync(listener); } catch (Exception ex) { App.Display(ex, $"Failed to start module listener on port '{TService.REMOTE_MODULE_PORT}'."); } } }
public Contractor(string installDirectory) { _installedAsHashes = new List <string>(); _invalidAssemblies = new List <Assembly>(); _moduleTypes = new Dictionary <string, Type>(); _modulePaths = new Dictionary <Type, string>(); _initializedModules = new Dictionary <Type, IModule>(); _moduleAttributes = new Dictionary <Type, ModuleAttribute>(); _authorAttributes = new Dictionary <Type, IEnumerable <AuthorAttribute> >(); ModulesDirectory = Directory.CreateDirectory(installDirectory); DependenciesDirectory = ModulesDirectory.CreateSubdirectory("Dependencies"); }
private void LoadModules() { foreach (FileSystemInfo fileSysInfo in ModulesDirectory.EnumerateFiles("*.*")) { string extension = fileSysInfo.Extension.ToLower(); if (extension == ".exe" || extension == ".dll") { try { Install(fileSysInfo.FullName); } catch (Exception ex) { App.Display(ex, "Failed to install the assembly as a module.\r\nFile: " + fileSysInfo.Name); } } } }
/// <summary> /// Build a module loader map that determines in which order which packages must be loaded /// </summary> /// <param name="packagesLock">The packages lock</param> /// <returns>Return a stack of dependency lists that can be loaded in parallel</returns> public Stack <List <PackageLoadingContext> > BuildMap(PackagesLock packagesLock) { var levelMap = new Dictionary <PackageIdentity, int>(PackageIdentity.Comparer); foreach (var packageIdentity in packagesLock.Keys) { SearchDependencies(packageIdentity, packagesLock, levelMap, 0); } var result = new Stack <List <PackageLoadingContext> >(); //the first item of this foreach loop must be loaded last (because it has the lowest level) foreach (var levelGroup in levelMap.GroupBy(x => x.Value).OrderBy(x => x.Key)) { var levelList = new List <PackageLoadingContext>(); foreach (var packageIdentity in levelGroup.Select(x => x.Key)) { if (!ModulesDirectory.ModuleExists(packageIdentity)) { throw new FileNotFoundException($"The package {packageIdentity} was not found."); } var packageDirectory = ModulesDirectory.VersionFolderPathResolver.GetInstallPath(packageIdentity.Id, packageIdentity.Version); var resolvedDirectory = LoadResolver.ResolveNuGetFolder(packageDirectory, MazeFramework, Runtime, Architecture); if (resolvedDirectory == null) //maybe build only package? { continue; } levelList.Add(new PackageLoadingContext(packageIdentity, packageDirectory, resolvedDirectory.Directory.FullName, resolvedDirectory.Framework, resolvedDirectory.Framework.Framework == MazeFramework.Framework)); } result.Push(levelList); } return(result); }
public MazeProject(IModuleProjectConfig config, IModulesConfig modulesConfig, IModulesLock modulesLock) { var providers = Repository.Provider.GetCoreV3(); PrimarySources = config.PrimarySources .Select(x => new SourceRepository(new PackageSource(x.AbsoluteUri), providers)).ToImmutableList(); DependencySources = config.DependencySources .Select(x => new SourceRepository(new PackageSource(x.AbsoluteUri), providers)).ToImmutableList(); ModulesDirectory = new ModulesDirectory(new VersionFolderPathResolver(config.Directory)); LocalSourceRepository = new SourceRepository(ModulesDirectory.PackageSource, providers); _modulesConfig = modulesConfig; ModulesLock = modulesLock; FrameworkLibraries = config.Frameworks.ToDictionary(x => NuGetFramework.Parse(x.Key), x => PackageIdentityConvert.ToPackageIdentity(x.Value)); Architecture = Environment.Is64BitProcess ? Architecture.x64 : Architecture.x86; Runtime = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? Runtime.Windows : Runtime.Linux; PrimaryPackages = modulesConfig.Modules; //very important because the file may change while the packages must consist }
private static void CompileModules() { if (Compiled) { return; } ToConsole("Compiling Modules..."); TryCatch( () => { var files = ModulesDirectory.GetFiles("*.vnc.mod.dll", SearchOption.AllDirectories); var asm = new List <Assembly>(files.Length); foreach (FileInfo file in files) { TryCatch( () => { Assembly a = Assembly.LoadFrom(file.FullName); if (a != null && !asm.Contains(a)) { asm.Add(a); } }, ToConsole); } ModuleAssemblies = asm.ToArray(); asm.AddRange(ScriptCompiler.Assemblies); ScriptCompiler.Assemblies = asm.ToArray(); }, ToConsole); }