Build events not honoring multiple command-line arguments

前端 未结 3 1785
梦谈多话
梦谈多话 2021-01-07 09:52

I have the following as my post-build event in a C# .NET 4.0 project in Visual Studio 2010:

call \"$(SolutionDir)Publish\\Publish.exe\" \"$(TargetDir)\" \"\\         


        
相关标签:
3条回答
  • 2021-01-07 10:27

    I'm not getting this behaviour at all.

    I created a post-build event of

    call "$(SolutionDir)test.cmd" "$(SolutionDir)a.txt" "$(SolutionDir)b.txt"
    

    Where test.cmd contains:

    if '%1' == '' GOTO END
    notepad.exe %1
    if '%2' == '' GOTO END
    notepad.exe %2
    :END
    

    a.txt & b.txt just have "This is File A" & "This is File B"

    When I do the build, Notepad fires up with a.txt, and when I close it then Notepad fires up with b.txt.

    So the parameters are definitely being sent separately for me.

    Can you try this same test to see what behaviour you get?

    0 讨论(0)
  • 2021-01-07 10:28

    While working on another project, I actually managed to replicate your problem. I was passing multiple args to a powershell script and found that they were being treated as a single argument. Googling found this link

    http://davidfrette.wordpress.com/2011/01/20/creating-powershell-pre-build-and-post-build-events-for-visual-studio-projects/

    Which has the solution of putting a space at the end of the first parameter i.e. in your example it would be

    call "$(SolutionDir)Publish\Publish.exe" "$(TargetDir) " "\\lithium\c\Photon"
    

    This worked for me so hopefully it will fix your problem.

    If you have more than 2 args then you would need to add a space at the end of each except for the last one.

    HTH

    0 讨论(0)
  • 2021-01-07 10:32

    I hit the same problem - if the argument expands out to something which ends in a backslash, I think the second quote is being escaped and treated as a quote character within the first argument.

    Using "$(OutDir)\" worked for me.

    0 讨论(0)
提交回复
热议问题