zoukankan      html  css  js  c++  java
  • Best practice for Invoke other scripts or exe in PowerShell

    Recently, I find I used many different type method to invoke other scripts or exe in PowerShell. Maybe by start new process, or just use the call operator &. That's fine. But I want to mention there's one preper way to invoke other scripts or exe in PowerShell I'd like to use.

    Problem background:

     I want to run msbuild to build something, but I want to sepcify multi folders. e.g. I want to output to both 'C:output' and 'D:output'. So, what should I do ?

     I may use the call operator & directly like:

    What's wrong ? Can you find it ?

    Actually, The real OutputFolder property value would be: "C:output, D:output". 

    And the whole script will be tranlated to:

    & .msbuild.exe YOUR_PROJECT.csproj /t:$Targets /p:C:output, D:output

    msbuild.exe will report something like, property is invalid or cannot distinguish and so on. Because the wired comma exists.

    Sulotion:

     

    Create a argument array, and use double quote to quote the property value to make true the quote will in the property value.

    Done.

  • 相关阅读:
    一些名词解释
    less那些事儿
    正则表达式检测汉字
    正则匹配括号中内容
    atom中vue高亮支持emmet语法
    正则匹配标签内内容
    联想一体机u盘启动设置
    vuejs时间格式化
    graphicsmagick常用命令
    js中对象的深度复制
  • 原文地址:https://www.cnblogs.com/wushuaiyi/p/5695650.html
Copyright © 2011-2022 走看看