我有一个Nuget包,它拥有自己的MVC控制面板,包含控制器、视图和路由。
这个Nuget包被导入到其他.NET Core Web应用程序中。
在使用.NET Core的Visual Studio 2015中,我使用以下代码将视图编译为资源,使它们可以被Razor引擎找到并正确渲染:
在项目的project.json(Nuget)文件中:
"buildOptions": {
"embed": "**/Views/**/*.cshtml"
}
在Startup.cs (Web应用程序)中:
public void ConfigureServices(IServiceCollection services)
{
services.Configure<RazorViewEngineOptions>(options =>
{
options.FileProviders.Add(new CompositeFileProvider(
new EmbeddedFileProvider(
typeof(HomeController).GetTypeInfo().Assembly,
"Some.Namespace"))
);
});
return new IuguPortalBuilder(services);
}
在Visual Studio 2017中,project.json文件已经不存在了,我找不到一种新的方式来将我的视图嵌入到NuGet包中。请问如何嵌入我的视图?
Include="**\Translations\Resource.*.resx"
的格式对我有效。 - Myobis