How to run a script before running the debugger in Visual Studio 2019?

Viewed 174

I have a project in C++ in Visual Studio 2019 and I would like to run it in a conan virtualrunenv environment prepared using the Conan package manager. For this purpose, I would like to execute the script before running the debugger. I tried to do it by setting "Command" option in Properties>Configuration Properties>Debugging>Command to value (cmd version):

D:\MyProject\bld\activate_run.bat && $(TargetPath)

or (powershell version)

D:\MyProject\bld\activate_run.ps1; $(TargetPath)

but both executions ends with error "Unable to start program . The filename, directory name, or volume label syntax is incorrect".

In short: I would like to execute a script (.bat or .ps1) before executing the debugger.

Does anyone know how this can be done?

1 Answers

Add this to the beginning of your code:

    #if DEBUG
        System.Diagnostics.Process.Start(@"C:\MyBatchFile.bat").WaitForExit();
    #endif

(This is a somewhat irrelevant answer since it's a C# solution. Maybe you or someone else can adapt it to your context.)

Related