通过从开始菜单或PowerShell ISE中启动PowerShell来运行此代码时,效果很好,但是当我在自定义构建步骤中从Visual Studio内部运行PowerShell时,会出现错误。
$Signature = '
[DllImport("user32.dll")] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
[DllImport("user32.dll")] public static extern int SetForegroundWindow(IntPtr hwnd);
'
if ($Maximize) { $nCmdShow = 3 } else { $nCmdShow = 1 }
$pInvoke = Add-Type -MemberDefinition $Signature -Name WindowAPI -PassThru
错误:
Add-Type : (0) : Warning as Error: Invalid search path 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.27.29110\atlmfc\lib\x64' specified in 'LIB environment variable' -- 'The system cannot find the path specified. ' (1) : using System; At <Filepath>.ps1:22 char:13 + ... $pInvoke = Add-Type -MemberDefinition $csClass -Name WindowAPI -Pass ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (Microsoft.Power...peCompilerError:AddTypeCompilerError) [Add-Type], Except ion + FullyQualifiedErrorId : SOURCE_CODE_ERROR,Microsoft.PowerShell.Commands.AddTypeCommand
请帮助!