3

I'm using Visual Studio 2013. Now, I have a few C# and C++ projects in a solution. Under project properties I can add some debugging properties. That works fine. But when I run the visual studio solution on another computer the command arguments are deleted.

How can I define default command arguments that are also available when I run the project on another computer?

user2644964
  • 763
  • 2
  • 10
  • 28
  • Have you checked that the properties are being saved? Project properties should stay with the project once they are saved. If you close and re-open the solution on the same computer are the properties still there? Are you running the same project within the solution (and in debug mode) on the other computer? – James Gardner Apr 29 '15 at 10:15
  • Thanks for your reply. Yes, if I reopen the same project everything is there but if I pull the project from git in a new folder the config is not available anymore, in which file does the parameters get stored? – user2644964 Apr 29 '15 at 14:39
  • 2
    Some project properties are stored in PROJECTNAME.csproj.user files. I thought they were all in the .csproj file but it seems some are in .csproj.user (I just checked with the "Debug-Command line arguments property"). This file is probably being ignored by git. I'm not sure how to get all the properties to be saved to the .csproj file. – James Gardner Apr 30 '15 at 02:21

2 Answers2

2

Those command line arguments from Visual Studio are for debugging purposes only, so you have two options:

1) instruct your users to run your application with arguments from cmd (or provide a script to run your application)

or

2) code your application to accept some missing arguments, so that when no arguments are passed to execute as if the default arguments are passed.

Zlatomir
  • 6,964
  • 3
  • 26
  • 32
2

If you are using other computer for debugging, then instead of setting the arguments in properties, set them via config file.

let's say following is your config file (by-default it is App.config),

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<appSettings>
<add key ="key1" value ="Sample" />
</appSettings>
</configuration>

To get value of key1 use ConfigurationManager.AppSettings["key1"];. You can add multiple keys in <appSettings> tag.

Abhishek
  • 6,912
  • 14
  • 59
  • 85