我正在尝试使用WPGraphQL插件WordPress和PeachPie。我使用VisualStudio2019解决方案构建了它,其中有两个基于ASP.NET核心空模板的项目,目标框架设置为.NET 5.0。
我已经成功地建立了一个初始项目,利用默认的Nuget包,PeachPied.WordPress.AspNetCore。它正确运行,并按预期呈现WordPress页面。第一个项目文件如下所示:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="PeachPied.WordPress.AspNetCore" Version="5.7.1-preview7" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Plugins\Plugins.msbuildproj" />
</ItemGroup>
</Project>此外,我还在同一解决方案下设置了第二个项目,在这个解决方案中,我加载了插件,以便与第一个项目一起使用。第二个项目是第一个项目的依赖项。第二个项目文件如下所示:
<Project Sdk="PeachPied.WordPress.Build.Plugin/5.7.1-preview7">
<PropertyGroup>
<WpContentTarget>
</WpContentTarget>
<PhpRelativePath>wp-content/</PhpRelativePath>
</PropertyGroup>
</Project>关于我的解决方案中的外观,我已经包含了一个我的解决方案资源管理器的截图。
当设置与这个HelloDolly项目相同的方式时,我能够成功地用HelloDolly插件测试插件项目:https://github.com/iolevel/peachpie-wordpress。
但是,在尝试使用WPGraphQL插件时,我会遇到以下错误。它在生成/调试项目时显示此错误。
Unable to cast object of type 'Pchp.CodeAnalysis.Semantics.BoundArrayEx' to type 'Pchp.CodeAnalysis.Semantics.BoundReferenceExpression'.
at Pchp.CodeAnalysis.Semantics.BoundListEx.<>c.<.ctor>b__22_0(KeyValuePair`2 pair)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)
at System.Collections.Immutable.ImmutableArray.ToImmutableArray[TSource](IEnumerable`1 items)
at Pchp.CodeAnalysis.Semantics.BoundListEx..ctor(IEnumerable`1 items)
at Pchp.CodeAnalysis.Semantics.SemanticsBinder.BindArrayEx(ArrayEx x, BoundAccess access)
at Pchp.CodeAnalysis.Semantics.SemanticsBinder.BindExpressionCore(Expression expr, BoundAccess access)
at Pchp.CodeAnalysis.Semantics.SemanticsBinder.BindExpression(Expression expr, BoundAccess access)
at Pchp.CodeAnalysis.Semantics.SemanticsBinder.BindAssignEx(AssignEx expr, BoundAccess access)
at Pchp.CodeAnalysis.Semantics.SemanticsBinder.BindExpressionCore(Expression expr, BoundAccess access)
at Pchp.CodeAnalysis.Semantics.SemanticsBinder.BindExpression(Expression expr, BoundAccess access)
at Pchp.CodeAnalysis.Semantics.SemanticsBinder.BindStatementCore(Statement stmt)
at Pchp.CodeAnalysis.Semantics.SemanticsBinder.BindStatement(Statement stmt)
at Pchp.CodeAnalysis.Semantics.SemanticsBinder.BindWholeStatement(Statement stmt)
at Pchp.CodeAnalysis.Semantics.Graph.BuilderVisitor.VisitExpressionStmt(ExpressionStmt x)
at Devsense.PHP.Syntax.Ast.ExpressionStmt.VisitMe(TreeVisitor visitor)
at Devsense.PHP.Syntax.TreeVisitor.VisitElement(LangElement element)
at Devsense.PHP.Syntax.TreeVisitor.VisitList[T](IList`1 items)
at Pchp.CodeAnalysis.Semantics.Graph.BuilderVisitor.VisitBlockStmt(BlockStmt x)
at Devsense.PHP.Syntax.Ast.BlockStmt.VisitMe(TreeVisitor visitor)
at Devsense.PHP.Syntax.TreeVisitor.VisitElement(LangElement element)
at Pchp.CodeAnalysis.Semantics.Graph.BuilderVisitor.VisitForeachStmt(ForeachStmt x)
at Devsense.PHP.Syntax.Ast.ForeachStmt.VisitMe(TreeVisitor visitor)
at Devsense.PHP.Syntax.TreeVisitor.VisitElement(LangElement element)
at Pchp.CodeAnalysis.EnumeratorExtension.ForEach[T](IEnumerable`1 enumerable, Action`1 func)
at Pchp.CodeAnalysis.Semantics.Graph.BuilderVisitor..ctor(IList`1 statements, SemanticsBinder binder)
at Pchp.CodeAnalysis.Symbols.SourceRoutineSymbol.get_ControlFlowGraph()
at Pchp.CodeAnalysis.SourceCompiler.EnqueueRoutine(SourceRoutineSymbol routine)
at System.Threading.Tasks.Parallel.<>c__DisplayClass42_0`2.<PartitionerForEachWorker>b__1()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
at System.Threading.Tasks.Task.<>c__DisplayClass176_0.<ExecuteSelfReplicating>b__0(Object <p0>) Plugins C:\Users\curritl\.nuget\packages\peachpie.net.sdk\1.0.5\build\Peachpie.NET.Core.Sdk.targets 245 发布于 2021-06-11 18:27:53
它本身就是一个很大的peachpie编译器。
https://github.com/peachpiecompiler/peachpie/issues/957
您可以从php脚本中删除失败的代码,或者等待下一个peachpie版本。
https://stackoverflow.com/questions/67928617
复制相似问题