Is there a way to know what the original working directory of the terminal that launched cake? #3076
-
I store all my cake files out of the root to keep things organised. But not only that, I sometimes use the cake files from different locations. Some of my parameters are relative paths, and they will never resolve. Is ther a way to know where cake was originally launched from so I can combine paths? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Hi @mattleibow, When you run a Cake script, the working directory is always set to the folder where the entry-point Cake script is located. So the relative path to other Cake scripts would have to be relative to that particular folder. If I understand your question, you have other scripts in other folders, that are Assuming that's the case, this is not something Cake supports out-of-the-box. Even if you were able to find out the original working directory, the One This would give you the ability to receive the original working directory in your Cake script e.g. var launchedFrom = Argument<string>("launchedFrom", null);
if (!string.IsNullOrWhiteSpace(launchedFrom))
{
Information("This Cake script was launched from {0}", launchedFrom);
} You'd have to adapt each of the bootstrappers that you use to capture the working directory and pass it as an argument. For PowerShell, you could use Now the good news is that you have a way of getting the original working directory from within your Cake script. The bad news is that it's too late for the CakeExecuteScript(script, new CakeSettings { Arguments = arguments }); This means that you might have to change some of your scripts to be "runnable" rather than "loadable" if that makes sense. Of course, you can also get creative and copy files around, make changes, and execute on-the-fly via |
Beta Was this translation helpful? Give feedback.
-
@mattleibow tracking via #3092 |
Beta Was this translation helpful? Give feedback.
@mattleibow tracking via #3092
PRs welcome!