简体   繁体   English

如何使用 msbuild 命令忽略错误并成功构建?

[英]How to ignore error and build successfully by using msbuild command?

I have tried these command to ignore the error messages by using msbuild command, but it doesn't work.我已经尝试使用这些命令通过使用 msbuild 命令忽略错误消息,但它不起作用。

msbuild /property:ContinueOnError=true E:...../xxx.sln

I got error messages like我收到错误消息,例如

GRGVTMWorkflowImp.cs(52,10): error CS0246: The type or namespace name 'GrgCreateFunctionAttribute' could not be found (are you missing a using directive or an assembly reference?) [E:\Fortify_Scan\src\AP1\VTM\20220607\20220601\GRGVTMBusinessService\GRGVTMWorkflow\GRGVTMWorkflow.csproj] GRGVTMWorkflowImp.cs(36,6): error CS0246: The type or namespace name 'GrgComponent' could not be found (are you missing a using directive or an assembly reference?) GRGVTMWorkflowImp.cs(52,10):错误 CS0246:找不到类型或命名空间名称“GrgCreateFunctionAttribute”(是否缺少 using 指令或程序集引用?) [E:\Fortify_Scan\src\AP1\VTM\20220607 \20220601\GRGVTMBusinessService\GRGVTMWorkflow\GRGVTMWorkflow.csproj] GRGVTMWorkflowImp.cs(36,6):错误 CS0246:找不到类型或命名空间名称“GrgComponent”(您是否缺少 using 指令或程序集引用?)

I know what these error messages means but I still want the project can be build successfully.我知道这些错误消息是什么意思,但我仍然希望项目能够成功构建。

Is it possible to ignore those error messages by using msbuild command or any other way to do it?是否可以通过使用 msbuild 命令或任何其他方式来忽略这些错误消息?

According to the Microsoft docs I get the impression that ContinueOnError is purely a property for MSBuild Tasks.根据Microsoft 文档,我得到的印象是ContinueOnError纯粹是 MSBuild 任务的属性。 While it is true that you're entering the build process via MSBuild, at some point the compiler csc.exe will be called.虽然您确实是通过 MSBuild 进入构建过程,但有时会调用编译器csc.exe
I didn't find any information whether the compiler also supports this property.我没有找到任何关于编译器是否也支持这个属性的信息。 But I doubt it, because what should the compiler do with a project that is obviously corrupt (missing dependencies)?但我对此表示怀疑,因为编译器应该如何处理明显损坏的项目(缺少依赖项)? My assumption and expectation - fail fast.我的假设和期望 - 快速失败。

Refer to MSBuild command line reference we can see that “-property:name=value” just can set or override the specified project-level properties but ContinueOnError is an attribute of task, so it doesn't work to change the value of ContinueOnError.参考MSBuild命令行参考我们可以看到“-property:name=value”只是可以设置或覆盖指定的项目级属性,但是ContinueOnError是task的一个属性,所以不能改变ContinueOnError的值。

If you want to change the value of ContinueOnError you can write a task to define ContinueOnError=true such as:如果要更改 ContinueOnError 的值,可以编写一个任务来定义 ContinueOnError=true,例如:

<Task 
    Parameter1="Value1" ContinueOnError=" true ">
</Task>

or use Directory.Build.targets to customize your build .或使用 Directory.Build.targets 自定义您的构建

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在命令行中使用 MSBuild 生成 VSIX 不会出错,不会生成 VSIX - 但 IDE 会出错。 如何调试? - Using MSBuild at command-line to produce VSIX does not error, does not build VSIX - but IDE does. How to debug? 如何使用 MSBuild 构建文件 - How to build the file using MSBuild 如何使用 MSBuild 构建项目? - How to build project using MSBuild? 如何在不使用命令提示符的情况下使用MSBuild引擎构建多个c#项目? - How to build multiple c# projects using MSBuild engine without using command prompt? 如何使用命令行中的C#7代码构建.csproj(msbuild) - How to build .csproj with C# 7 code from command line (msbuild) 使用Jenkins MSBuild的.NET生成错误“不允许使用默认参数说明符” - .NET build using Jenkins MSBuild error “Default parameter specifiers are not permitted” Jenkins + MsBuild + Nunit构建成功但未经测试 - Jenkins+MsBuild+Nunit build successfully but without tests 发布期间如何使MSBuild命令行忽略非ClickOnce应用程序? - How to make MSBuild Command Line ignore non ClickOnce applications during publishing? 使用MSBuild创建成功的版本 - Using MSBuild to create a successful build 如何使用具有管理员权限的MSBUILD构建VSNET 2008应用程序 - how to build a VSNET 2008 application using MSBUILD with Administrator rights
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM