K. Alan Bates
K. Alan Bates

Reputation: 3154

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

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

Upvotes: 4

Views: 3698

Answers (1)

Marcus Mangelsdorf
Marcus Mangelsdorf

Reputation: 3070

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>

Upvotes: 3

Related Questions