英文:
C# .Net build failure due to strawberryshake error - Method not found: 'Void StrawberryShake.CodeGeneration.CSharp.CSharpGeneratorSettings
问题
我有一个使用StrawberryShake 12.18.0 GraphQL客户端的.NET 6项目。它可以在我的本地环境中构建。但是当它在Azure管道中运行时,由于以下错误而无法构建项目。
> 错误SS0006:未找到方法:“Void StrawberryShake.CodeGeneration.CSharp.CSharpGeneratorSettings.set_RequestStrategy(StrawberryShake.Tools.Configuration.RequestStrategy)”
> 错误CS0246:找不到类型或命名空间名称“IGraphQLClient”(是否缺少使用指令或程序集引用?)
英文:
I have a .net 6 project which uses strawberryshake 12.18.0 grahpql client. It build in my local environment. But when it runs in Azure pipeline it fails to build the project due to below error.
> Error SS0006: Method not found: 'Void StrawberryShake.CodeGeneration.CSharp.CSharpGeneratorSettings.set_RequestStrategy(StrawberryShake.Tools.Configuration.RequestStrategy)'
> Error CS0246: The type or namespace name 'IGraphQLClient' could not be found (are you missing a using directive or an assembly reference?)
答案1
得分: 3
解决方案 01 - 将 Azure 管道的 YAML 文件中的 'vmImage' 属性更改为 'windows-latest'。
解决方案 02 - 将 Strawberryshake 客户端升级到 13.2.1 版本。
- 移除 StrawberryShake.CodeGeneration.CSharp.Analyzers
- 移除 StrawberryShake.Transport.Http
- 将 strawberryshake.tools 版本设置为 13.2.1
- 添加 StrawberryShake.Server 版本 13.2.1
- 移除由 StrawberryShake 12 生成的生成文件夹
- 运行 Dotnet clean
- 构建项目
英文:
I was able to found two solutions so far for this issue.
Solution 01 - Change azure pipeline yaml 'vmImage' property to 'windows-latest'
Solution 02 - Upgrade Strawberryshake client to 13.2.1 version.
- Remove StrawberryShake.CodeGeneration.CSharp.Analyzers
- Remove StrawberryShake.Transport.Http
- Set strawberryshake.tools to version 13.2.1
- Add StrawberryShake.Server" Version 13.2.1
- Remove generated folder which generates by the StrawberryShake 12.
- Run Dotnet clean
- Build the project
答案2
得分: 2
+1 同意。一直运行得很完美,直到今天突然在流水线中失败,但在我的本地机器上仍然正常工作。当我遇到错误时,我使用的是12.16版本。尝试升级到12.18仍然出现错误。升级到最新版本(版本13)会在我的本地机器上引发许多错误,但在流水线中仍然会因为这个确切的问题而失败。
经过一些调查,似乎Azure DevOps上的Ubuntu镜像已经更新,这导致了错误的发生。一个(不是很好的)权宜之计是,暂时将流水线更改为使用Windows而不是Ubuntu。
至少对我来说解决了问题(但我的流水线速度变慢了一个数量级)。希望对你也有帮助
英文:
+1 on this. Been working perfectly until today - now suddenly it fails in the pipeline but still works on my local machine. I was on 12.16 when I got the error. Tried to update to 12.18 still get the error. Updating to newest (version 13) introduces a lot of errors on my local machine, but in the pipeline it still fails with this exact issue.
After some digging, it seems that the ubuntu image on azure devops have been updated, which causes the error. A (not very good) workaround, is to change the pipeline to use windows instead of ubuntu for the time being.
At least, that solved the issue for me (but my pipeline is an order of magnitude slower). Hope it helps you
答案3
得分: 2
在失败任务之前,对于我有效的方法是将此任务添加到 Azure 管道中。
- task: UseDotNet@2
displayName: '使用 DotNet 6.0 进行项目构建'
inputs:
version: '6.0.x'
(我的应用程序是 .Net 6 和 StrawberryShake v12.18,就像楼主一样。)
英文:
What worked for me is to add this task to the azure pipeline before the failing task.
- task: UseDotNet@2
displayName: 'Use DotNet 6.0 for Project Build'
inputs:
version: '6.0.x'
(My app is .Net 6 and StrawberryShake v12.18, just like the OP.)
答案4
得分: 2
这可能是由于使用了analyzer包导致的。在升级到版本13时,我们已经重新构建了代码生成。您需要删除所有的strawberry包并添加新的包之一:
- StrawberryShake.Server:如果您在ASP.NET Core或控制台中使用StrawberryShake。
- StrawberryShake.Blazor:如果您在Blazor WebAssembly项目中使用StrawberryShake。
- StrawberryShake.Maui:如果您在使用Maui。
请查看此处的文档,以了解如何设置客户端:
https://chillicream.com/docs/strawberryshake/v13/get-started
还有一个链接到YouTube的视频,我会在其中为您演示新的设置。
迁移后,工具更加健壮,在Blazor用例中的工作效果更好。
如果您在此过程中遇到更多问题,请加入社区聊天:
slack.chillicream.com
英文:
This probably is due to the use of the analyzer package. When upgrading to version 13 we have rebuild the code generation. You need to remove all strawberry packages and add one of the new packages:
- StrawberryShake.Server: If you are using StrawberryShake in ASP.NET core or a console.
- StrawberryShake.Blazor: If you are using StrawberryShake in a Blazor WebAssembly Project
- StrawberryShake.Maui: If you are using Maui.
Have a look at the docs here that show how to set the client up:
https://chillicream.com/docs/strawberryshake/v13/get-started
There is also a YouTube episode linked where I walk you through the new setup.
After the migration the tooling is more robust and work better in the blazor use case.
If you have further issues with this join the community chat:
slack.chillicream.com
答案5
得分: 0
在使用GitHub工作流时遇到了相同的问题。唯一的解决办法似乎是将Strawberry Shake升级到13.x版本,这非常简单。
只需按照此处提供的简要指南进行操作:https://chillicream.com/docs/strawberryshake/v13/migrating/migrate-from-12-to-13
英文:
Had the same issue using github workflows. The only solution seemed to be to bump Strawberry shake to 13.x, which was pretty simple.
Just used the small guide provided here: https://chillicream.com/docs/strawberryshake/v13/migrating/migrate-from-12-to-13
答案6
得分: 0
遇到了类似的问题:项目 NET 7,StrawberryShake 客户端 12.18,在我更新 dotnet SDK 到 7.0.305 后开始构建失败,在 7.0.1 上正常运行。在 Mac M1 上运行。
英文:
Encountered a similar issue: project NET 7, StrawberryShake client 12.18 started to fail build once I updated dotnet SDK to 7.0.305, on 7.0.1 works just fine. Running on mac m1
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论