gpt4 book ai didi

powershell - 通过 powershell 执行时,Msbuild 日志不起作用

转载 作者:行者123 更新时间:2023-12-02 23:31:23 25 4
gpt4 key购买 nike

当我使用批处理文件调用 msbuild.exe 时,日志记录功能工作正常。

但是当它用 powershell 编写时,它不会记录任何内容。

以下是我正在使用的 powershell 脚本。知道如何解决这个问题吗?

# Script to invoke build
. ./vsvars32.ps1

Remove-Item "ViewBuild1.log"

$MsbuildBinPath="C:\Windows\Microsoft.NET\Framework\v4.0.30319"


$errorLogFileName="ViewBuild1Errors.log"
$buildLogFileName="ViewBuild1.log"

$MSBuildLogger="/flp1:Append;LogFile=ViewBuild1.log;Verbosity=Normal; /flp2:LogFile=ViewBuild1Errors.log;Verbosity=Normal;errorsonly"

$MSBuildFile="Build.Targets"

Write-Host --------------------------------------------
Write-Host Prepare for the build
Write-Host --------------------------------------------
&"$MsbuildBinPath\Msbuild.exe" $MSBuildFile "/t:Prepare" "$MSBuildLogger"
if ($LastExitCode -ne 0) {
Write-Host "It failed, send a mail"
}
#$LastExitCode

&"$MsbuildBinPath\Msbuild.exe" $MSBuildFile "/t:BuildAll" "$MSBuildLogger"

尽管我在文件记录器中使用了附加选项,但执行后 Viewbuild1.log 根本没有内容。

最佳答案

全部$MSBuildLogger作为单个参数传递给 MSBuild 例如:

PS> $MSBuildLogger="/flp1:Append;LogFile=ViewBuild1.log;Verbosity=Normal; /flp2:LogFile=ViewBuild1Errors.log;Verbosity=
Normal;errorsonly"
PS> echoargs $MSBuildLogger
Arg 0 is </flp1:Append;LogFile=ViewBuild1.log;Verbosity=Normal; /flp2:LogFile=ViewBuild1Errors.log;Verbosity=Normal;erro
rsonly>

尝试改用两个变量:
PS> $MSBuildLogger1="/flp1:Append;LogFile=ViewBuild1.log;Verbosity=Normal;"
PS> $MSBuildLogger2="/flp2:LogFile=ViewBuild1Errors.log;Verbosity=Normal;errorsonly"
PS> echoargs $MSBuildLogger1 $MSBuildLogger2
Arg 0 is </flp1:Append;LogFile=ViewBuild1.log;Verbosity=Normal;>
Arg 1 is </flp2:LogFile=ViewBuild1Errors.log;Verbosity=Normal;errorsonly>

仅供引用,echoargs.exe 是来自 PowerShell Community Extensions 的实用程序.

关于powershell - 通过 powershell 执行时,Msbuild 日志不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8524088/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com