从PowerShell v. 7.2.7升级到v. 7.3后,调用带参数的可执行文件开始持续失败,并出现各种错误。
看起来参数没有被正确传递。
一个示例(为了简洁,删除了一些参数):
msbuild.exe "$Solution" /maxcpucount:1 `
/t:Build `
/p:Configuration=$Configuration `
"/l:TeamCity.MSBuild.Logger.TeamCityMSBuildLogger,$RootDir.buildpackagesTeamCity.Dotnet.Integrationbuild_commonmsbuild15TeamCity.MSBuild.Logger.dll;teamcity"
失败:
MSBUILD : error MSB1021: Cannot create an instance of the logger. Could not load file or assembly ''JetBrains.BuildServer.MSBuildLoggers.MSBuildLogger,"D:\BuildAgentA\plugins\dotnetPlugin\bin\JetBrains.BuildServer.MSBuildLoggers.4.0.dll"'' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
解决方案是使用飞溅:
$params = @(
"$Solution",
"/maxcpucount",
"/t:Build",
"/p:Configuration=$Configuration"
)
if ($env:TEAMCITY_VERSION) {
$params += "/l:TeamCity.MSBuild.Logger.TeamCityMSBuildLogger,$RootDir.buildpackagesTeamCity.Dotnet.Integrationbuild_commonmsbuild15TeamCity.MSBuild.Logger.dll;teamcity"
}
msbuild @params
注意是msbuild @params
,不是msbuild $params
。