/// <summary> /// Initializes a new instance of <see cref="Assemblies"/> /// </summary> /// <param name="configuration">Current <see cref="Configuration"/></param> /// <param name="assemblyPaths">Paths for assemblies</param> public Assemblies(Configuration configuration, AssemblyPaths assemblyPaths) { _configuration = configuration; _assemblyPaths = assemblyPaths; PopulateRootAssemblies(); ImportAllAssemblies(); }
static void Main(string[] args) { var configuration = new Configuration(args); var paths = new AssemblyPaths(configuration); var managedFilesFileCopier = new FileCopier(configuration.ManagedOutputPath); var staticFilesFileCopier = new FileCopier(configuration.OutputPath); var assemblies = new Assemblies(configuration, paths); var artifactsEmbedder = new ArtifactsEmbedder(configuration, assemblies); artifactsEmbedder.Perform(); managedFilesFileCopier.Copy(assemblies.AllImportedAssemblyPaths); managedFilesFileCopier.Copy(assemblies.AllImportedAssemblyDebugSymbolPaths); staticFilesFileCopier.Copy(new[] { Path.Combine(paths.Sdk, "debug", "mono.js"), Path.Combine(paths.Sdk, "debug", "mono.wasm"), Path.Combine(paths.Sdk, "debug", "mono.wasm.map"), Path.Combine(paths.Sdk, "debug", "mono.wast") }); var managedFiles = new List <string>(); managedFiles.AddRange(assemblies.AllImportedAssemblyPaths); managedFiles.AddRange(assemblies.AllImportedAssemblyDebugSymbolPaths); var assembliesFilePath = Path.Combine(configuration.OutputPath, "assemblies.json"); var fileList = string.Join(",\n\t\t", managedFiles.Select(_ => $"\"{Path.GetFileName(_)}\"").ToArray()); File.WriteAllText(assembliesFilePath, $"[\n\t\t{fileList}\n]"); var monoConfigPath = Path.Combine(configuration.OutputPath, "mono-config.js"); File.WriteAllText(monoConfigPath, $"config = {{\n\tvfs_prefix: 'managed',\n\tdeploy_prefix: 'managed',\n\tenable_debugging: 0, \n\tfile_list: [\n\t\t{fileList}\n\t ],\n\tadd_bindings: function() {{ \n\t\tModule.mono_bindings_init ('[WebAssembly.Bindings]WebAssembly.Runtime');\n\t}}\n}}" ); var monoJsSource = Path.Combine(paths.Sdk, "debug", "mono.js"); var monoJsDestination = Path.Combine(configuration.OutputPath, "mono.js"); var monoJs = File.ReadAllText(monoJsSource); monoJs = monoJs.Replace("this.mono_wasm_runtime_is_ready=true;debugger", "this.mono_wasm_runtime_is_ready=true;"); monoJs = monoJs.Replace( " this.mono_wasm_runtime_is_ready = true;\n"+ " debugger;\n", " this.mono_wasm_runtime_is_ready = true;\n"); File.WriteAllText(monoJsDestination, monoJs); }
IEnumerable <string> GetFilesFor(AssemblyPaths paths, string path) { var files = new List <string>(); path = paths.FindBestMatchFor(path); if (File.Exists(path)) { files.Add(path); var pdbFile = Path.ChangeExtension(path, ".pdb"); if (File.Exists(pdbFile)) { files.Add(pdbFile); } } return(files); }