Sitecore 9.3 Serialization CLI执行push命令失败求助
问题描述
我们有一个非Helix架构、非无头模式的Sitecore 9.3项目,尝试添加Serialization CLI,已安装v5.1.25版本的CLI和管理服务,dotnet tool restore及认证操作均正常。但执行dotnet sitecore ser push命令时,系统能识别所有待添加项,但在显示"Applying changes..."后抛出如下错误:
[GraphQLException] GraphQL.ExecutionError: 处理请求时发生异常。---> System.MissingFieldException: 未找到字段: 'Sitecore.DevEx.Serialization.Logging.SerializationEventIds.Created'.
at Sitecore.DevEx.GraphQL.Serialization.Mutations.SerializationCommands.CreateItemCommand.Execute(SerializationCommandData command, IItemData dataModel)
at Sitecore.DevEx.GraphQL.Serialization.Mutations.SerializationCommands.CommandExtensions.TryExecute(IEnumerable1 commands, IList1& results)
at Sitecore.DevEx.GraphQL.Serialization.Mutations.ExecuteSerializationCommandsMutation.Resolve(ResolveFieldContext context)
--- 内部异常堆栈跟踪结束 ---
[GraphQLException] GraphQL.ExecutionError: 无法为非null类型返回null。字段: name, 类型: String!.
at GraphQL.Execution.ExecutionStrategy.ValidateNodeResult(ExecutionContext context, ExecutionNode node)
at GraphQL.Execution.ExecutionStrategy.d__7.MoveNext()
[GraphQLException] GraphQL.ExecutionError: 解析logLevel时出错。---> System.MissingMethodException: 未找到方法: 'Microsoft.Extensions.Logging.LogLevel Sitecore.DevEx.Logging.OperationMessage.get_LogLevel()'.
at Sitecore.DevEx.GraphQL.Serialization.GraphTypes.OperationResultMessageGraphType.ResolveLevel(ResolveFieldContext1 context) at GraphQL.Resolvers.FuncFieldResolver2.GraphQL.Resolvers.IFieldResolver.Resolve(ResolveFieldContext context)
at GraphQL.Execution.ExecutionStrategy.d__7.MoveNext()
--- 内部异常堆栈跟踪结束 ---
[GraphQLException] GraphQL.ExecutionError: 解析eventID时出错。---> System.MissingMethodException: 未找到方法: 'Microsoft.Extensions.Logging.EventId Sitecore.DevEx.Logging.OperationMessage.get_EventId()'.
at Sitecore.DevEx.GraphQL.Serialization.GraphTypes.OperationResultMessageGraphType.ResolveEventId(ResolveFieldContext1 context) at GraphQL.Resolvers.FuncFieldResolver2.GraphQL.Resolvers.IFieldResolver.Resolve(ResolveFieldContext context)
at GraphQL.Execution.ExecutionStrategy.d__7.MoveNext()
--- 内部异常堆栈跟踪结束 ---
解决方案
这类错误的核心原因是Sitecore CLI v5.x版本与Sitecore 9.3不兼容。Sitecore CLI v5.x是为Sitecore 10.2及以上版本设计的,其依赖的DevEx组件、GraphQL接口与Sitecore 9.3的底层实现存在版本差异,导致字段、方法找不到的异常。
解决步骤:
- 卸载当前的v5.1.25版本CLI:
dotnet tool uninstall --global Sitecore.CLI - 安装与Sitecore 9.3兼容的CLI版本,推荐使用v3.0.0(该版本专门适配Sitecore 9.x系列):
dotnet tool install --global Sitecore.CLI --version 3.0.0 - 同步管理服务版本:确保Sitecore实例上安装的Management Service版本与CLI v3.0.0匹配,避免版本不一致导致的接口不兼容。
- 重新执行序列化命令:完成上述操作后,重新进行
dotnet tool restore、认证,再尝试dotnet sitecore ser push即可正常运行。
另外需要注意,Sitecore 9.3的Serialization CLI功能相对有限,若后续需要更丰富的序列化能力,建议考虑升级到Sitecore 10.x及以上版本。
内容的提问来源于stack exchange,提问作者Reza.Hoque

