如何忽略postbuild事件的警告和错误?(How to ignore warnings and errors of a postbuild event?)

编程入门 行业动态 更新时间:2024-10-26 02:27:58
如何忽略postbuild事件的警告和错误?(How to ignore warnings and errors of a postbuild event?)

我在csproj中有一个postbuild事件。 我想忽略这个命令的输出,但是每当我执行命令> nul 2>&1时,这个csproj就会被破坏,可能是因为“>”。 我注意到当我从后生成窗口写入“>”,而不是直接编辑csproj如果得到编码..是否有解决方法(除了从bat文件运行它)

I have a postbuild event in my csproj. I want to ignore the output from this command, but whenever I do command >nul 2>&1 this csproj goes corrupt, probably because of the ">". I noticed when I write ">" from the postbuild window instead of editing the csproj directly if gets encoded.. Is there a workaround (other than running it from a bat file)

最满意答案

这可以使用MSBuild的<Exec>任务从自定义目标完成,而不是依赖默认的前/后构建脚本属性。

您可以将其添加到csproj文件中,而不是使用默认的pre / post构建脚本:

<Target Name="PostBuild" AfterTargets="PostBuildEvent"> <Exec Command="some command" IgnoreExitCode="true" /> </Target>

请注意,对于“基于sdk的”项目(ASP.NET Core,.NET Core,.NET Standard),上述格式是在Visual Studio UI中指定后构建事件时已添加的内容,但IgnoreExitCode属性除外。

This can be done using MSBuild's <Exec> task from a custom target instead of relying on the default pre/post build script properties.

You can add this to your csproj file instead of using the default pre/post build scripts:

<Target Name="PostBuild" AfterTargets="PostBuildEvent"> <Exec Command="some command" IgnoreExitCode="true" /> </Target>

Note that for "sdk-based" projects (ASP.NET Core, .NET Core, .NET Standard) the above format is what is added when specifying a post build event in the Visual Studio UI already with the exception of the IgnoreExitCode attribute.

更多推荐

csproj,postbuild,电脑培训,计算机培训,IT培训"/> <meta name="description&

本文发布于:2023-07-21 09:31:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1208980.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   事件   postbuild   ignore   event

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!