Code Generation Templates

翻译原文:https://www.cnblogs.com/Qbit/p/9746457.html转载请注明出处

Orchard Core Templates使用dotnet新模板配置从命令shell创建新网站,主题和模块。

有关dotnet new的更多信息,请访问:

https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-new

安装Orchard Cms模板

安装.NET Core SDK后,键入以下命令以安装用于创建Orchard Core Cms Web应用程序的模板。

dotnet new -i OrchardCore.Cms.Templates::1.0.0-beta2-*

这将使用最稳定的Orchard Core版本。 为了使用Orchard Core的最新dev分支,可以使用以下命令:

dotnet new -i OrchardCore.Cms.Templates::1.0.0-beta2-* --nuget-source https://www.myget.org/F/orchardcore-preview/api/v3/index.json

创建一个新网站

From Command Shell (automated way)

Generate an Orchard Cms Web Application

dotnet new occms   

使用此命令可以忽略日志记录:

dotnet new occms --nlog false

使用Visual Studio(手动方式)

启动Visual Studio,通过创建新的ASP.NET Core Web应用程序创建新的解决方案文件(.sln)::

现在我们创建了一个新的Web应用程序,我们需要添加适当的依赖项,以便将这个新的Web应用程序作为Orchard Core应用程序进行定位。

原文: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();
}
}
}

创建一个新的module

New module from Command Shell (automated way)

Module commands

dotnet new ocmodule -n ModuleName.OrchardCore
dotnet new ocmodule -n ModuleName.OrchardCore --PartName TestPart

dotnet new ocmodule -n ModuleName.OrchardCore --PartName TestPart --AddPart true

New module from Visual Studio (manual way)

启动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.

  

Create a new theme

New theme From Command Shell (automated way)

Theme commands

dotnet new octheme -n "ThemeName.OrchardCore"

New theme from Visual Studio (manual way)

应该是与模块相同的过程,但我们需要引用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."
)]

Adding Orchard Core Nuget Feed

为了能够使用Visual Studio中的开发源,请打开Nuget Package Manager - > Package Manager Settings下的Tools菜单。 引用网址是 https://www.myget.org/F/orchardcore-preview/api/v3/index.json

 

Orchard Core 文档翻译 (二)代码生成模板 Code Generation Templates的更多相关文章

  1. Orchard Core 文档翻译 (三) Orchard Core Modules

    原文连接:https://www.cnblogs.com/Qbit/p/9746442.html 转载请注明出处 介绍 Orchard Core Modules库提供了一种机制,可以拥有一个独立的模块 ...

  2. Orchard官方文档翻译(二) 安装 Orchard

    原文地址:http://docs.orchardproject.net/Documentation/Installing-Orchard 想要查看文档目录请用力点击这里 最近想要学习了解orchard ...

  3. Orchard Core 文档翻译 (六)HTML

    Body (OrchardCore.Html) Theming Shapes 将HtmlBodyPart附加到内容类型时,将呈现以下形状(Shapes) Name Display Type Defau ...

  4. Orchard Core 文档翻译 (七)Contents

    CMS Modules »Contents Contents (OrchardCore.Contents) 此模块提供内容管理服务. Liquid 您可以使用“content ”属性从liquid 视 ...

  5. Orchard Core 文档翻译 (五)自动路由 Autoroute (OrchardCore.Autoroute)

    Autoroute (OrchardCore.Autoroute) 此模块允许您为内容项指定自定义URL(永久链接 permalink). Autoroute Part 将此部分附加到内容类型以指定内 ...

  6. Orchard Core 文档翻译 (四)CMS ModulesTitle (OrchardCore.Title)

    Title (OrchardCore.Title) 标题模块提供Title Part ,允许用户定义内容项的标题.它还定义了ContentItemMetadata方面的DisplayText属性 Th ...

  7. Orchard core 中文文档翻译系列

    本系列翻译顺序完全参照 官方顺序 原文地址:https://orchardcore.readthedocs.io/en/latest/ Orchard Core 中文文档翻译(一)关于Orchard ...

  8. Orchard Core 中文文档翻译(一)关于Orchard Core

    原文连接:https://www.cnblogs.com/Qbit/p/9746363.html 转载请注明出处 翻译说明:本系列为直译,按照官方的计划现在这个版本(2018年10月5日)已经接近最终 ...

  9. Orchard Core 简介

    Orchard Core 是基于ASP.NET Core 对Orchard CMS的 二次开发. Orchard Core由两部分组成: Orchard Core Framework: 一个基于ASP ...

随机推荐

  1. BZOJ - 1257 分块 详解

    中文题面 这道题就是LightOJ某题的升级版 前段时间我是直接用√k前暴力后分块的处理方式,然后直接套个等差求和 这次看到了dalao的证明再次让我知道我好菜啊 在这里做下笔记,学习一下对于整除运算 ...

  2. PIE SDK波段运算

    1.算法功能简介 波段运算(Band Math)工具能够方便的执行图像中的各个波段的加减乘除.三角函数.指数.对数等数学函数计算,也可以使用IDL编写的函数. 由于每个用户都有独特的需求,利用此工具用 ...

  3. java c c++大学补遗

    第一次面试时的问题是一个看起来50多数的老工程师问的, 仍然记忆犹新 java(面向对象)的基本特性? 封装 继承 多态 工作几年后,各种框架用来用去, 回想起这个问题,java也就剩下这几个特性了

  4. 移动端刷新组件XtnScroll--Angular4实现

    刷新组件 - 主要是学习一下Angular4所有花了我一天时间,写了这个刷新组件. 以项目开发当中,特别是手机移动端开发的时候,经常要用到就是上拉加载下一面,下拉刷新获取最新数据的功能. 在网也有很多 ...

  5. Android中改变Activity的不同icon:activity-alias

    Android设置title中的Icon有几种方法,介绍如下: 一种是直接在AndroidManifest.xml文件中设置android:icon属性,这种方法简单有效,应该算是我们最常用的设置Ic ...

  6. git读书笔记以及使用技巧

    [添加文件] git add  把文件修改添加到暂存区    git commit -m '' 把暂存区的所有内容提交到当前分支 [查看历史]    git log 查看提交历史 git log -- ...

  7. 你还在把Java当成Android官方开发语言吗?Kotlin了解一下!

    导语:2017年Google IO大会宣布使用Kotlin作为Android的官方开发语言,相比较与典型的面相对象的JAVA语言,Kotlin作为一种新式的函数式编程语言,也有人称之为Android平 ...

  8. C++程序设计基础(2)变量

    注:读<程序员面试笔记>笔记总结 1.知识点 (1)C++变量命名只能包含字母.数字.下划线,其中开头不能是数字:大小写敏感:习惯上变量用小写字母,常量.宏定义用大写字母. (2)变量的作 ...

  9. [转]Implementing User Authentication in ASP.NET MVC 6

    本文转自:http://www.dotnetcurry.com/aspnet-mvc/1229/user-authentication-aspnet-mvc-6-identity In this ar ...

  10. 03.枚举和string以及int类型之间的转换

    练习1:   将枚举类型强转成int类型 namespace _04.枚举类型的练习01 { //声明一个QQState类型的枚举 public enum QQState { OnLine, OffL ...