翻译原文:https://www.cnblogs.com/Qbit/p/9746457.html 转载请注明出处html
Orchard Core Templates使用dotnet新模板配置从命令shell建立新网站,主题和模块。git
有关dotnet new的更多信息,请访问:github
https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-newweb
安装.NET Core SDK后,键入如下命令以安装用于建立Orchard Core Cms Web应用程序的模板。shell
dotnet new -i OrchardCore.Cms.Templates::1.0.0-beta2-*
这将使用最稳定的Orchard Core版本。 为了使用Orchard Core的最新dev分支,能够使用如下命令:json
dotnet new -i OrchardCore.Cms.Templates::1.0.0-beta2-* --nuget-source https://www.myget.org/F/orchardcore-preview/api/v3/index.json
dotnet new occms
使用此命令能够忽略日志记录:api
dotnet new occms --nlog false
启动Visual Studio,经过建立新的ASP.NET Core Web应用程序建立新的解决方案文件(.sln)::app
如今咱们建立了一个新的Web应用程序,咱们须要添加适当的依赖项,以便将这个新的Web应用程序做为Orchard Core应用程序进行定位。visual-studio
原文:Now that we created a new Web Application we need to add proper dependencies so that this new Web Application be targetted as an Orchard Core application.
请参阅 Adding Orchard Core Nuget Feed网站
最后,咱们须要在Startup.cs文件中注册Orchard CMS服务,以下所示:
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; namespace MyNewWebsite { public class Startup { // This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { services.AddOrchardCms(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseOrchardCore(); } } }
dotnet new ocmodule -n ModuleName.OrchardCore
dotnet new ocmodule -n ModuleName.OrchardCore --PartName TestPart
dotnet new ocmodule -n ModuleName.OrchardCore --PartName TestPart --AddPart true
启动Visual Studio,打开Orchard Core解决方案文件(.sln),选择OrchardCore.Modules文件夹,右键单击并选择“添加 - >新项目”并建立一个新的.NET Standard Class Library:
为了将这个新类库标记为Orchard模块,咱们如今须要引用OrchardCore.Module.Targets Nuget包。
See adding Orchard Core Nuget Feed
这些“* .Targets”Nuget包中的每个都用于将类库标记为特定的Orchard Core功能。 OrchardCore.Module.Targets是咱们如今感兴趣的。 咱们将新的类库标记为模块,方法是将OrchardCore.Module.Targets添加为依赖项。 为此,您须要右键单击MyModule.OrchardCore项目并选择“Manage Nuget Packages”选项。 要在Nuget Package Manager中查找软件包,您须要选中“include prerelease”并确保您已选择咱们以前添加的Orchard Core Feed。 找到它后,单击Version:Latest prerelease x.x.x.x旁边右侧面板上的Install按钮
:
要让Orchard Core识别此模块,它如今须要一个Manifest.cs文件。 这是该文件的一个示例:
using OrchardCore.Modules.Manifest; [assembly: Module( Name = "TemplateModule.OrchardCore", Author = "The Orchard Team", Website = "http://orchardproject.net", Version = "0.0.1", Description = "Template module." )]
要启动此模块,咱们如今须要将Startup.cs文件添加到新模块中。 以此文件为例:
OrchardCore.Templates.Module/Startup.cs
最后一步是将咱们的新模块添加到OrchardCore.Cms.Web项目中做为参考,将其做为咱们网站模块的一部分包含在内。 以后,您应该已准备好开始构建自定义模块。 你能够参考咱们的 template module 例如,基本上一般须要什么。
原文: For this module to start we now will need to add a Startup.cs file to our new module. See this file as an example: OrchardCore.Templates.Module/Startup.cs Last step is to add our new module to the OrchardCore.Cms.Web project as a reference for including it as part as our website modules. After that, you should be all set for starting building your custom module. You can refer to our template module for examples of what's basically needed normally.
dotnet new octheme -n "ThemeName.OrchardCore"
应该是与模块相同的过程,但咱们须要引用OrchardCore.Theme.Targets和Manifest.cs文件略有不一样:
using OrchardCore.DisplayManagement.Manifest; [assembly: Theme( Name = "TemplateTheme.OrchardCore", Author = "The Orchard Team", Website = "https://orchardproject.net", Version = "0.0.1", Description = "The TemplateTheme." )]
为了可以使用Visual Studio中的开发源,请打开Nuget Package Manager - > Package Manager Settings下的Tools菜单。 引用网址是 https://www.myget.org/F/orchardcore-preview/api/v3/index.json