我在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&
发布评论