PowerShell v1.0에서이 기능을 테스트했습니다. 설정은 다음과 같습니다 :& 연산자를 사용하여 PowerShell에서 MSBuild를 호출하는 방법?
Id CommandLine
-- -----------
1 $msbuild = "C:\Windows\Microsoft.NET\Framework\v3.5\msbuild.exe"
4 $a = "C:\some\project\or\other\src\Solution.sln /target:Clean /target:Build"
.
이 줄은 직관적 오류 메시지와 함께 실패합니다
Id CommandLine
-- -----------
5 & $msbuild $a
.
&은 첫 번째 인수가 명령 자체이기 때문에이 줄이 실패합니다.
Id CommandLine
-- -----------
10 & "$msbuild $a"
.
이 줄 작동합니다
Id CommandLine
-- -----------
16 cmd /c "$msbuild $a"
.
설명해주십시오. 나는 & 구문이 작동하지 않는 이유에 대해 MSBuild 관련 해결 방법보다 더 관심이 있습니다.
MSBuild를 직접 호출하는 대신 [Invoke-MSBuild] (http://sedodream.com/2014/07/19/IntroducingPSBuildAnImprovedInterfaceForMsbuildexeInPowerShell.aspx)와 같은 도우미 cmdlet을 사용하는 것이 좋습니다. – orad