dub root folder as environment-variable in VisualD

ShadoLight ettienne.gilbert at gmail.com
Sun Jan 3 22:21:54 UTC 2021


I switch frequently between creating + building projects in dub, 
and then switching to VisualD if debugging is required. dub 
excels at dependency management and VS+VisualD excels at 
debugging... so this works as a nice work-flow for me.

I generate the VisualD solution with dub and dub does an 
admirable job of including all the dependencies as required 
(although there are some minor shortcomings... but nothing 
serious, so lets ignore those).

But, if you have a number of dependencies, you can end up with a 
substantial number of "Additional Import Paths" for your 
dependencies in VisualD, all looking like this:

"C:\Users\someBloke\AppData\Local\dub\packages\some\path\to\dep1\..."
"C:\Users\someBloke\AppData\Local\dub\packages\some\path\to\dep2\..."
..etc..

This is as a consequence of dub (on Windows) installing all 
packages to "C:\Users\someBloke\AppData\Local\dub\...etc..".

I don't particularly like this (I would prefer to be able to 
specify the root folder for dub packages), but it would already 
be an improvement if you could use an environment variable to 
refer to the root of dub packages in your VisualD project 
properties, so that instead you could have the following on the 
VisualD side:

"$(DUB_PACKAGES_ROOT)some\path\to\dep1\..."
"$(DUB_PACKAGES_ROOT)some\path\to\dep2\..."
..etc..

I tried a couple of "work-arounds" using the global "Import 
Paths" under "VisualD Settings", but cannot avoid having to 
specify the full paths.

dub defines a number of environment-variables [1], but it looks 
like the dub ones are expanded when dub generates the 
*.visualdproj project (the VisualD+VS ones are not).


Is there some way this can be done at the moment? (modulo some 
trickery using external *.bat files or system 
environment-variables)


[1] https://dub.pm/package-format-json.html#environment-variables


More information about the Digitalmars-d-ide mailing list