类别:技术积累 / 日期:2024-12-15 / 浏览:1747 / 评论:0

        除了手动方式创建Orchard Core项目,还可以通过模板创建。先通过以下dotnet new命令在命令提示符或VS Terminal中安装VS模板:

dotnet new install OrchardCore.ProjectTemplates::2.1.3

        其中2.1.3是版本号,如果要使用最新main分值,则运行如下命令安装:

dotnet new install OrchardCore.ProjectTemplates::2.1.3-* --nuget-source https://nuget.cloudsmith.io/orchardcore/preview/v3/index.json

        然后就可以通过命令行自动创建CMS项目(各命令的详细参数列表可通过附加-h或--help参数查看):

dotnet new occms //自动创建CMS应用(Full CMS)
dotnet new ocmvc //自动创不含CMS功能的WEB应用(Orchard Core Framework),仅引用OrchardCore.Application.Cms.Core.Targets
dotnet new ocmodulecms //自动创建CMS模块(Full CMS)
dotnet new octheme //自动创建主题
dotnet new ocmodulemvc //自动创建不含CMS功能的模块(Orchard Core Framework)

        也可以在VS新建项目对话框中选择对应模板手动创建项目。

        所有命令的共同选项:

  -n, --name <name>       The name for the output being created. If no name is specified, the name of the output directory is used.
  -o, --output <output>   Location to place the generated output.
  --dry-run               Displays a summary of what would happen if the given command line were run if it would result in a template creation.
  --force                 Forces content to be generated even if it would change existing files.
  --no-update-check       Disables checking for the template package updates when instantiating a template.
  --project <project>     The project that should be used for context evaluation.
  -lang, --language <C#>  Specifies the template language to instantiate.
  --type <project>        Specifies the template type to instantiate.
  • -n, --name <name>:指定要创建的输出的名称。如果没有指定名称,则使用输出目录的名称。这通常用于设置项目名称。

  • -o, --output <output>:指定生成输出的位置。这决定了生成的模板或项目文件应该被放置在哪个文件夹中。

  • --dry-run:执行“干运行”模式,即不会实际执行任何操作,而是显示如果运行给定的命令行将会发生什么,特别是如果它会导致模板创建的话。这可以用于预览将要发生的更改。

  • --force:强制生成内容,即使这会更改现有文件。通常用于覆盖或更新已存在的文件。

  • --no-update-check:在实例化模板时禁用模板包的更新检查。这可以加快操作速度,特别是在不希望或不需要检查更新时。

  • --project <project>:指定用于上下文评估的项目。这个选项可能用于在多项目环境中指定应该使用哪个项目的上下文或设置。

  • -lang, --language <C#>:指定要实例化的模板语言。在这个例子中,C#被用作示例语言,但也可以指定其他编程语言。

  • --type <project>:指定要实例化的模板类型。这可以用于区分不同类型的模板,例如Web应用程序、控制台应用程序等。

        occms的特殊选项:

  -fm, --framework <net8.0>                 The target framework for the project. //指定目标框架,默认net8.0
                                            Type: choice
                                              net8.0  Target net8.0
                                            Default: net8.0
  -lo, --logger <NLog|None|Serilog>         Configures the logger component. //指定日志组件:NLog、Serilog或None,默认NLog
                                            Type: choice
                                              NLog     Configures NLog as the logger component.
                                              Serilog  Configures Serilog as the logger component.
                                              None     Do not configure logger.
                                            Default: NLog
  -ov, --orchard-version <orchard-version>  Specifies which version of Orchard Core packages to use. //指定Orchard Core版本号,默认2.1.3
                                            Type: string
                                            Default: 2.1.3

        ocmvc的特殊选项:

  -fm, --framework <net8.0>                 The target framework for the project. //指定目标框架,默认net8.0
                                            Type: choice
                                              net8.0  Target net8.0
                                            Default: net8.0
  -ov, --orchard-version <orchard-version>  Specifies which version of Orchard Core packages to use. //指定Orchard Core版本号,默认2.1.3
                                            Type: string
                                            Default: 2.1.3

        ocmodulecms的特殊选项:

  -fm, --framework <net8.0>                 The target framework for the project. //指定目标框架,默认net8.0
                                            Type: choice
                                              net8.0  Target net8.0
                                            Default: net8.0
  -A, --AddPart                             Add dependency injection for part in Startup.cs. If PartName is not provided, default name will be used //是否添加Part依赖注入
                                            Type: bool
                                            Default: false
  -P, --PartName <PartName>                 Add all files required for a part //指定Part名称
                                            Type: string
                                            Default: MyTest
  -ov, --orchard-version <orchard-version>  Specifies which version of Orchard Core packages to use. //指定Orchard Core版本号,默认2.1.3
                                            Type: string
                                            Default: 2.1.3

        octheme的特殊选项:

  -F, --Framework <net8.0>               The target framework for the project. //指定目标框架,默认net8.0
                                         Type: choice
                                           net8.0  Target net8.0
                                         Default: net8.0
  -A, --AddLiquid                        Add .liquid files in Views //是否添加.liquid视图文件,默认是
                                         Type: bool
                                         Default: true
  -O, --OrchardVersion <OrchardVersion>  Specifies which version of Orchard Core packages to use. //指定Orchard Core版本号,默认2.1.3
                                         Type: string
                                         Default: 2.1.3

        ocmodulemvc的特殊选项:

  -fm, --framework <net8.0>                 The target framework for the project. //指定目标框架,默认net8.0
                                            Type: choice
                                              net8.0  Target net8.0
                                            Default: net8.0
  -ov, --orchard-version <orchard-version>  Specifies which version of Orchard Core packages to use. //指定Orchard Core版本号,默认2.1.3
                                            Type: string
                                            Default: 2.1.3


 可能感兴趣的文章

评论区

发表评论 / 取消回复

必填

选填

选填

◎欢迎讨论,请在这里发表您的看法及观点。