1

BrowserLink 与 Asp.net Core webapp 配合得很好,但是当涉及到 Razor 类库 (RCL) 时,我只是看不到它工作。每次我在 RCL 中的 .cshtml 视图中进行更改时,我都必须对解决方案进行重建,以查看根本没有生产力的更改。有人能够与 RCL 一起工作吗?谢谢。

4

1 回答 1

1

You need to add a PhysicalFileProvider in your Startup.cs ConfigureServices of the WebApp that you are using Razor Class Library components on. I have two Razor Class Library projects in the same solution as my website set up and named as so:

  • WebApp (.net core webapp)
  • ModelLibrary (Razor Class Library)
  • ViewComponentLibrary (Razor Class Library)

In Startup ConfigureServices of the WebApp...

services.Configure<RazorViewEngineOptions>(options => 
        {
            options.FileProviders.Add(new PhysicalFileProvider(Path.Combine(hosting.ContentRootPath, "..\\ViewComponentLibrary")));
        });

The "hosting" is an IHostingEnvironment Dependency Injection in the Startup class.

You would obviously need to change "ViewComponentLibrary" to whatever you named your own Razor Class Library. Now, when you make changes they are shown without rebuilding the solution.

于 2019-07-10T09:07:51.017 回答