From c566a54eeca7b1a4d8602bd3837ab411e18c26d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Sun, 29 Apr 2018 13:11:48 +0300 Subject: [PATCH] add Dealing Embedded Files On The Development section to Virtual-File-System.md --- docs/Virtual-File-System.md | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/docs/Virtual-File-System.md b/docs/Virtual-File-System.md index 4c3ac5bbd8..2b962e0a12 100644 --- a/docs/Virtual-File-System.md +++ b/docs/Virtual-File-System.md @@ -102,6 +102,39 @@ public class MyService } ```` +#### Dealing Embedded Files On The Development +Embedding a file into a module assembly and using it from another project by just referencing the assembly (or adding a nuget package) is very valuable for creating a re-usable module. However, it makes a bit hard to develop the module itself. + +Assume that you are developing a module that contains an embedded javascript file. Whenever you change the file you must re-compile the project, re-start the application and refresh the browser page to take the change. Obviously, it is very time consuming and tedious. + +What if the application could directly use the physical file in the development time? Thus, you could just refresh the browser page to see any change in the javascript file. `ReplaceEmbeddedByPyhsical` method makes that possible. + +The example below shows an application depends on a module (`MyModule`) that contains embedded files and the application can reach the source code of the module on the development time. + +````C# +[DependsOn(typeof(MyModule))] +public class MyWebAppModule : AbpModule +{ + public override void ConfigureServices(IServiceCollection services) + { + var hostingEnvironment = services.GetHostingEnvironment(); + + if (hostingEnvironment.IsDevelopment()) //only for development time + { + services.Configure(options => + { + //ReplaceEmbeddedByPyhsical gets the root folder of the MyModule project + options.FileSets.ReplaceEmbeddedByPyhsical( + Path.Combine(hostingEnvironment.ContentRootPath, "..\\MyModuleProject") + ); + }); + } + + //... + } +} +```` + +The code above assumes that `MyWebAppModule` and `MyModule` are two different projects in a Visual Studio solution and `MyWebAppModule` depends on the `MyModule`. -s \ No newline at end of file