1

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
ekolis
  • 6,270
  • 12
  • 50
  • 101
  • Why don't you just move/link them, or use a nuget reference instead? – Milney Jan 23 '21 at 19:10
  • What do you mean by link them? I could use a NuGet reference if the DLL I was referencing came from a NuGet package, but it's just the output of a project in my solution... – ekolis Jan 23 '21 at 21:04
  • Wouldn't that DLL just live in the same place your executable does? (just as it does for the debug project) – Robert Harvey Jan 23 '21 at 21:37
  • Well, the thing is, both the CSX script and the DLL move when I build the project, so both the relative and absolute paths change. – ekolis Jan 23 '21 at 23:04

0 Answers0