Loading

Orchard Core 使用模板创建Module

 

根据官方示例:https://orchardcore.readthedocs.io/en/latest/Templates/README/#create-a-new-module

执行以下命令:

dotnet new --install "OrchardCore.Cms.Templates"

PS C:\Users\hyzx8\Documents\Visual Studio 2017\Projects\JZProjectManage> dotnet new --install "OrchardCore.Cms.Templates"
正在还原 C:\Users\hyzx8\.templateengine\dotnetcli\v2.1.403\scratch\restore.csproj 的包...
C:\Users\hyzx8\.templateengine\dotnetcli\v2.1.403\scratch\restore.csproj : error NU1103: 找不到版本为 的稳定包 OrchardCore.Cms.Templates
C:\Users\hyzx8\.templateengine\dotnetcli\v2.1.403\scratch\restore.csproj : error NU1103: - 在 Orchard Core Nuget 中找到 20 个版本[ 最接近版本: 1.0.0-beta3-68792 ]
C:\Users\hyzx8\.templateengine\dotnetcli\v2.1.403\scratch\restore.csproj : error NU1103: - 在 nuget.org 中找到 3 个版本[ 最接近版本: 1.0.0-beta2-67846 ]
C:\Users\hyzx8\.templateengine\dotnetcli\v2.1.403\scratch\restore.csproj : error NU1103: - 在 Microsoft Visual Studio Offline Packages 中找到 0 个版本
C:\Users\hyzx8\.templateengine\dotnetcli\v2.1.403\scratch\restore.csproj : error NU1103: - 在 C:\Program Files\dotnet\sdk\NuGetFallbackFolder 中找到 0 个版本
正在生成 MSBuild 文件 C:\Users\hyzx8\.templateengine\dotnetcli\v2.1.403\scratch\obj\restore.csproj.nuget.g.props。
正在生成 MSBuild 文件 C:\Users\hyzx8\.templateengine\dotnetcli\v2.1.403\scratch\obj\restore.csproj.nuget.g.targets。
C:\Users\hyzx8\.templateengine\dotnetcli\v2.1.403\scratch\restore.csproj 的还原在 251.62 ms 内失败。

  

安装失败,此时参考微软官方的 api :https://docs.microsoft.com/zh-cn/dotnet/core/tools/dotnet-new?tabs=netcore21#examples

-i|--install <PATH|NUGET_ID>

从提供的 PATH 或 NUGET_ID 安装源或模板包。 若要安装模板包的预发布版本,需要以 <package-name>::<package-version> 格式指定该版本。 默认情况下,dotnet new 为该版本传递 *,表示最后一个稳定的包版本。 请在示例部分查看示例。

注意以上命令中的高亮部分,由于OrchardCore 尚未发布稳定版,所以我们需要指定具体的版本号,在此之前你应确保已经添加了OrchardCore官方的 Nuget源: https://orchardcore.readthedocs.io/en/latest/Templates/README/#adding-orchard-core-nuget-feed

将命令修改为:

dotnet new --install "OrchardCore.Cms.Templates::1.0.0-beta3-68792"

注意后方的版本号来自于 上一个命令的 最接近版本 部分

接下来再按照官方文档继续执行就没问题了

 

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

 

posted @ 2018-10-12 14:51  韩严重  阅读(1304)  评论(0编辑  收藏  举报