简体   繁体   中英

How to execute an executable path returned by a powershell function?

In PowerShell, you can return a path in a function, and then execute the resulting variable like this:

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

$MSBuildExe= GetMSBuildExe
&$MSBuildExe MySolution.sln

Is there a way I can simply run the MSBuildExe without copying into a variable first? Doing this simply prints ou the GetMSBuildExe result:

&GetMsBuildExe MySolution.sln

Thanks!

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

&(GetMsBuildExe) MySolution.sln

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM