How to invoke MSBuild from PowerShell using & operator?

后端 未结 4 641
陌清茗
陌清茗 2020-12-15 16:42

I\'ve just tested this on PowerShell v1.0. Setup is as follows:

 Id CommandLine
 -- -----------
  1 $msbuild = \"C:\\Windows\\Microsoft.NET\\Framework\\v3.5\         


        
4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-15 16:58

    Ugh.

    $collectionOfArgs = @("C:\some\project\or\other\src\Solution.sln", 
        "/target:Clean", "/target:Build")
    & $msbuild $collectionOfArgs
    

    This works. & takes a collection of arguments, so you must split up strings containing multiple arguments into a collection of string arguments.

提交回复
热议问题