I am using Visual Studio 2017 RC1
to load a CMake Project (C++) using the new "Open Folder" feature and try to set environment variables for the binary upon launching.
Since there is no solution file anymore when using Open Folder, the pre-VS-2017 way of using the debugging dialogue doesn't seem to be an option here.
What I've tried so far:
env: {}
there, which should give the Hello World program an empty environmentScreenshot of Solution Explorer and launch.vs.json
However, if I try to run the binary a pop-up window shows up which says "Object must implement IConvertible" and the binary won't run. It works fine when omitting env: {}
, though. I've also tried to add something to env, but the effect stays the same. Changing the working directory using currentDir works fine, so I assume that launch.vs.json
is at least read and used.
Since the documentation on this seems quite sparse, I am not sure if this is even the intended way for setting Environment Variables when using the VS 2017 CMake integration.
In order to set multiple environment variables for VS 2017 with CMake, use \u0000
as separator. For example, the put these in your launch.vs.json
will set 2 environment variables VAR1=USA
and VAR2=JAPAN
{
"version": "0.2.1",
"defaults": {},
"configurations": [
{
"type": "default",
"name": "main.cpp",
"project": "src\\main.cpp",
"env": "VAR1=USA\u0000VAR2=JAPAN"
}
]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With