In my C# .NET core solution, I have two projects, a BASE, and a TEST project. The TEST project references BASE and BASE has a method that needs to use a file from BASE's output folder. Even when TEST is calling the method from BASE, it needs to point to BASE's output directory.
However, when executing the test from the TEST project (which uses the methods from BASE), all the methods I can find point to TEST's output directory, not BASE's. Any tips/ideas?
Here is a list of methods I have tried. These are being executed within BASE, but being called from TEST.
var t1 = AppDomain.CurrentDomain.BaseDirectory;
var t2 = Assembly.GetExecutingAssembly().Location;
var t3 = Environment.CurrentDirectory;
var t4 = Assembly.GetCallingAssembly().Location;
var t5 = Assembly.GetEntryAssembly().Location;
var t6 = Assembly.GetExecutingAssembly().GetName().CodeBase;
var t7 = Assembly.GetCallingAssembly().GetName().CodeBase;
var t8 = Assembly.GetEntryAssembly().GetName().CodeBase;
var t9 = System.IO.Directory.GetCurrentDirectory();
var t10 = Directory.GetParent(Environment.CurrentDirectory).Parent.Parent.FullName;
As you can see below, each of these points to the TEST's directory, not the BASE project's directory where the file needed resides.
Thank you in advance!