private List <BlazorModuleManifestAssemblyEntry> GetAppAssemblies() { var assemblies = new Dictionary <string, Assembly>(); var blazorConfig = BlazorConfig.Read(_appAssembly.Location); AddAssemblyAndDependencies(_appAssembly, assemblies); var result = new List <BlazorModuleManifestAssemblyEntry>(capacity: assemblies.Count); var sourceOutputDir = Path.GetDirectoryName(blazorConfig.SourceOutputAssemblyPath); foreach (var assembly in assemblies.Values) { var dllFile = Path.Combine(sourceOutputDir, Path.GetFileName(assembly.Location)); if (File.Exists(dllFile)) { var dllFileRef = AssemblyName.GetAssemblyName(dllFile); result.Add(new BlazorModuleManifestAssemblyEntry { AssemblyName = assembly.GetName().Name, AssemblyVersion = dllFileRef.Version, IsAppPart = assembly == _appAssembly }); } } return(result); }
// TODO: Test if publishing works correctly. public static void UseBlazorModule(this IApplicationBuilder applicationBuilder, BlazorOptions options) { if (applicationBuilder == null) { throw new ArgumentNullException(nameof(applicationBuilder)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } // TODO: Make the .blazor.config file contents sane // Currently the items in it are bizarre and don't relate to their purpose, // hence all the path manipulation here. We shouldn't be hardcoding 'dist' here either. var env = applicationBuilder.ApplicationServices.GetRequiredService <IHostingEnvironment>(); var config = BlazorConfig.Read(options.ClientAssemblyPath); //if (env.IsDevelopment() && config.EnableAutoRebuilding) //{ // applicationBuilder.UseHostedAutoRebuild(config, env.ContentRootPath); //} // First, match the request against files in the client app dist directory if (Directory.Exists(config.DistPath)) { applicationBuilder.UseStaticFiles(new StaticFileOptions { FileProvider = new PhysicalFileProvider(config.DistPath), ContentTypeProvider = CreateContentTypeProvider(config.EnableDebugging), OnPrepareResponse = SetCacheHeaders }); } // * Before publishing, we serve the wwwroot files directly from source // (and don't require them to be copied into dist). // In this case, WebRootPath will be nonempty if that directory exists. // * After publishing, the wwwroot files are already copied to 'dist' and // will be served by the above middleware, so we do nothing here. // In this case, WebRootPath will be empty (the publish process sets this). if (!string.IsNullOrEmpty(config.WebRootPath)) { applicationBuilder.UseStaticFiles(new StaticFileOptions { FileProvider = new PhysicalFileProvider(config.WebRootPath), OnPrepareResponse = SetCacheHeaders }); } // Accept debugger connections //if (config.EnableDebugging) //{ // applicationBuilder.UseMonoDebugProxy(); //} applicationBuilder.UseStaticFiles(new StaticFileOptions { FileProvider = new PhysicalFileProvider(Path.GetDirectoryName(config.SourceOutputAssemblyPath)), ContentTypeProvider = CreateContentTypeProvider(config.EnableDebugging), OnPrepareResponse = SetCacheHeaders }); }