|
1 | | -# docFxWebAppRefresh |
2 | | -DocFx .net core web app build middleware. Rebuilds docFx assets when files are changed in a web app. |
| 1 | +# ElCamino.DocFx.WebAppRefresh |
| 2 | +DocFx build middleware that allows you to setup a .net core web app project and adds a file watcher to your content files. When you change a content file, such as markdown, css, etc, the middleware automatically starts a docFx build in the background regenerating the target html files. |
| 3 | + |
| 4 | +**This library should be configured for local development only as shown below!** |
| 5 | +1. Create a new .net core web application 'Empty' project |
| 6 | +``` |
| 7 | +dotnet new web |
| 8 | +``` |
| 9 | +or |
| 10 | + |
| 11 | +Use Visual Studio new project, web application, Empty. |
| 12 | + |
| 13 | +2. Use the nuget package manager to install **docfx.console** |
| 14 | +``` |
| 15 | +dotnet add package docfx.console |
| 16 | +``` |
| 17 | +3. **Build** the project (this will generate all of the docfx files) |
| 18 | +4. Rename the **_site** folder to **wwwroot**. |
| 19 | +5. Edit the *.gitignore* file, remove **_site**, add **wwwroot** and **log.txt** |
| 20 | +``` |
| 21 | +wwwroot |
| 22 | +log.txt |
| 23 | +``` |
| 24 | +6. Edit the *docfx.json*, rename **_site** and replace with **wwwroot** |
| 25 | +```json |
| 26 | +{... |
| 27 | + "dest": "wwwroot", |
| 28 | +... |
| 29 | +} |
| 30 | +``` |
| 31 | +7. Use the nuget package manager to install **ElCamino.DocFx.WebAppRefresh** |
| 32 | +``` |
| 33 | +dotnet add package ElCamino.DocFx.WebAppRefresh |
| 34 | +``` |
| 35 | +8. Edit the Startup.cs |
| 36 | +```c# |
| 37 | +public class Startup |
| 38 | +{ |
| 39 | + ... |
| 40 | + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. |
| 41 | + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) |
| 42 | + { |
| 43 | + if (env.IsDevelopment()) |
| 44 | + { |
| 45 | + app.UseDeveloperExceptionPage(); |
| 46 | + // only use in development, not for production |
| 47 | + app.UseDocFxBuildRefresh(env.ContentRootPath, env.WebRootPath); |
| 48 | + } |
| 49 | + app.UseDefaultFiles(); |
| 50 | + |
| 51 | + app.UseStaticFiles(); |
| 52 | + } |
| 53 | +... |
| 54 | +``` |
| 55 | +9. Debug the web application. Change a content file (markdown, css, etc) and watch the debug output for the docFx build output and refresh the page to see your changes. |
0 commit comments