翻譯原文: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