Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Project path or other macro in command-line parameters for console project in VS2010

The debug tab of the project properties for a console application in VS2010 allows me to set command-line parameters to pass to the project whilst debugging.

I would like to set a parameter which is a path and the path is specific to each developer/machine, as it is a path which resides in the solution folder and each environment is different.

For pre- and post-build events, I can use macros such as $(ProjectDir), but I can't find a way to do this for command-line parameters - is there a way? A hack is fine, as long as it's not too awful!

Thanks

like image 519
enashnash Avatar asked Aug 01 '12 23:08

enashnash


People also ask

How to pass command line arguments using Visual Studio?

How to Pass Command Line Arguments using Visual Studio ? 1 Right Click on Project from Solution Explorer and Select Properties. 2 In the Project Properties Windows, Navigate to “Debug Tab” 3 You will find the text box “Command Line”

How to debug a Visual Studio project using command line?

Visual Studio enables nice features where you can do this on the Debug tab. Here are the steps to achieve this. 1. Right Click on Project from Solution Explorer and Select Properties. 2. In the Project Properties Windows, Navigate to “Debug Tab”. 3. You will find the text box “Command Line”.

How do I open a VS Code project from command line?

Launching from command line # You can launch VS Code from the command line to quickly open a file, folder, or project. Typically, you open VS Code within the context of a folder. To do this, from an open terminal or command prompt, navigate to your project folder and type code.:

How do I run Visual Studio Code from the command line?

Visual Studio Code has a powerful command line interface built-in that lets you control how you launch the editor. ... On macOS, you need to manually run the Shell Command: Install 'code' command in PATH command (available through the Command Palette ⇧⌘P (Windows, Linux Ctrl+Shift+P)).


1 Answers

I haven't found a way to use $(ProjectDir) in the command line arguments, but you can access files contained within the project by:

  • Tell Visual Studio to copy specific files to the output directory by changing their "Copy to Output Directory" property.
  • Change your command line arguments from $(ProjectDir)/FileNeededDuringRuntime to FileNeededDuringRuntime.

This is more of a hack since it probably doesn't cover all the cases of using the variable, but it may get you by if you're just referencing a few files.

like image 200
Kyle Krull Avatar answered Nov 14 '22 03:11

Kyle Krull