How do you specify command line arguments in a .csproj's StartProgram setting?

喜欢而已 提交于 2021-01-27 16:00:29

问题


I'm trying to specify command line arguments to an executable in a <StartProgram> value of a <PropertyGroup> Currently looks like this

<PropertyGroup>
  <StartAction>Program</StartAction>
  <StartProgram>$(SolutionDir)\Edge.Express\node.exe</StartProgram>
</PropertyGroup>

I'm trying to automate the steps involved in attaching my library to a running process so my team can directly debug a library without additional ceremony (They're not familiar with Visual Studio yet)

I copied the node executable to the Edge.Express folder and my Express server configuration is in server.js at that location. What I want to do is this:

<PropertyGroup>
  <StartAction>Program</StartAction>
  <StartProgram>$(SolutionDir)\Edge.Express\node.exe server</StartProgram>
</PropertyGroup>

but that throws the following exception Exception

Removing the "server" arg fires up an instance of node.

How would I give the "server" argument to node.exe inside my <StartProgram> setting?

Alternatively Is there a way to set the StartAction to run a batch script and just push the server startup into the script?

A quick search did not return any documentation on what the available StartActions are


回答1:


As Hans pointed out: If you want to specify arguments for the <StartAction> Program, you have to use the <StartArguments> element:

<StartAction>Program</StartAction>
<StartProgram>$(SolutionDir)\Edge.Express\node.exe</StartProgram>
<StartArguments>server</StartArguments>


来源:https://stackoverflow.com/questions/26492099/how-do-you-specify-command-line-arguments-in-a-csprojs-startprogram-setting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!