Is there any way to create a conditional reference in a C# script (CSX)?

157 views Asked by At

I have a CSX script that needs to reference a DLL, but the location of the DLL varies; at design time it's in one folder but at runtime it's in another. I tried adding #r directives for both locations but then when I run the app which is calling the script, I get an error on the one that is for design time support. Is there any way to make a conditional reference to the DLL, such that the script will just silently skip it if the DLL does not exist? Or put some sort of condition around it so that only the correct reference for the current environment is executed?

#r "../../../bin/Debug/net5.0/FrEee.Core.dll" // this one is for design time
#r "../../FrEee.Core.dll" // this one is for runtime
0

There are 0 answers