Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何执行powershell函数返回的可执行路径?_Powershell - Fatal编程技术网

如何执行powershell函数返回的可执行路径?

如何执行powershell函数返回的可执行路径?,powershell,Powershell,在PowerShell中,您可以在函数中返回路径,然后执行生成的变量,如下所示: Function GetMSBuildExe { # Code that sets the value of $MSBuildExe Return $MSBuildExe } $MSBuildExe= GetMSBuildExe &$MSBuildExe MySolution.sln 有没有一种方法可以简单地运行MSBuildExe而不首先复制到变量中?执行此操作只会打印GetMSBuildExe结果:

在PowerShell中,您可以在函数中返回路径,然后执行生成的变量,如下所示:

Function GetMSBuildExe {
# Code that sets the value of $MSBuildExe
Return $MSBuildExe
}

$MSBuildExe= GetMSBuildExe
&$MSBuildExe MySolution.sln
有没有一种方法可以简单地运行MSBuildExe而不首先复制到变量中?执行此操作只会打印GetMSBuildExe结果:

&GetMsBuildExe MySolution.sln

谢谢

将函数放在括号中,以便首先对其求值:

&(GetMsBuildExe)MySolution.sln