如何抑制编译目标的错误
我的 Vazor 项目中出现构建错误:
默认情况下,仅在 C# 项目中支持 Google.Protobuf.Tools 原型编译
但是,我不会在该项目中进行原型编译。 codegen 项目是一个 C# 项目,我在我的 Vazor 项目中引用了它。显然编译器不够聪明,无法弄清楚这一点。
以下是 Google.Protobuf.Tools.Targets
文件中的相关片段:
<!-- Check configuration sanity before build. -->
<Target Name="_Protobuf_SanityCheck" BeforeTargets="PrepareForBuild">
<Error
Condition=" '$(Protobuf_ProjectSupported)' != 'true' "
Text="Google.Protobuf.Tools proto compilation is only supported by default in a C# project (extension .csproj)" />
</Target>
这是在我添加 Grpc.AspNetCore
包时启动的,因此我可以在 Startup 中执行此操作.vb
:
Services.AddGrpc
我尝试注释掉
元素,这确实有效,但它是一种 hack,而且是一个非常糟糕的 hack。问题与这个很接近,但他们并没有真正解决问题。
这是一个重现项目。构建 VazorMVC1,您将看到错误。
是否有一种有尊严的方法来抑制此错误,以便我的项目可以构建(也许使用声明性 MSBuild 语法),而无需更改目标文件?
I'm getting a build error in my Vazor project:
Google.Protobuf.Tools proto compilation is only supported by default in a C# project
However, I'm not doing proto compilation in this project. The codegen project is a C# project, which I'm referencing in my Vazor project. Apparently the compiler isn't smart enough to figure that out.
Here's the relevant snippet from the Google.Protobuf.Tools.Targets
file:
<!-- Check configuration sanity before build. -->
<Target Name="_Protobuf_SanityCheck" BeforeTargets="PrepareForBuild">
<Error
Condition=" '$(Protobuf_ProjectSupported)' != 'true' "
Text="Google.Protobuf.Tools proto compilation is only supported by default in a C# project (extension .csproj)" />
</Target>
This started when I added the Grpc.AspNetCore
package, so I could do this in Startup.vb
:
Services.AddGrpc
I tried commenting out the <Error />
element, and that works, but it's a hack—and a pretty lousy one at that. Q&As like this one come close, but they don't really address the problem.
Here's a repro project. Build VazorMVC1 and you'll see the error.
Is there a dignified way to suppress this error so my project can build, perhaps in declarative MSBuild syntax, without my having to alter the targets file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论