question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to turn relative Directory into an absolute path?

See original GitHub issue

I’m trying to set the OutDir property on the MSBuild task for my solution so that every project is built to a single directory (currently migrating from UpperCut that does this).

However I can’t work out how to turn the relative path when creating a Directory object into an absolute path. Am I missing something obvious? There seems to be a MakeAbsolute method on DirectoryPath but that requires an ICakeEnvironment that I can’t work out how to get either.

var buildResultDir = Directory("./build-output") + Directory("v" + semVersion) + Directory("bin";

MSBuild("./src/app.sln", settings =>
        settings.SetConfiguration(configuration)
            .WithProperty("OutDir", buildResultDir.Path)
            .UseToolVersion(MSBuildToolVersion.Default)
            .SetNodeReuse(false));

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

11reactions
devleadcommented, May 27, 2015

Hi @coxp ,

Version 0.4.2 is now released, in the DSL you can now write:

var file = MakeAbsolute(File("./path")) 
var dir = MakeAbsolute(Directory("./path")) 

Thanks for your feedback and interest in Cake 👍

1reaction
patriksvenssoncommented, May 26, 2015

Hello,

You can get the current ICakeEnvironment instance via the script context.

Like this:

path = path.MakeAbsolute(Context.Environment)

There is a PR waiting that adds an alias method (MakeAbsolute) for this, but it won’t be available until the next release.

Best regards Patrik

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to retrieve absolute path given relative
Try realpath . ~ $ sudo apt-get install realpath # may already be installed ~ $ realpath .bashrc /home/username/.bashrc.
Read more >
How do I convert a relative to an absolute path, portably ...
This module provides functions for determining the pathname of the current working directory. Perl is generally already installed on Linux and ...
Read more >
How to convert relative path to absolute path?
suppose i ahve a shell script Nsdnet.sh inside a directory /dialp/Release/bin another file nsdnet_file.csv is under the same directory. Now in ...
Read more >
Expand a Relative Path in Bash | Baeldung on Linux
Learn about absolute and relative paths and how we can expand them in bash ... In Linux, paths are used to refer to...
Read more >
Replacing Relative Paths with Absolute Paths in DataFrames
In this tutorial, we'll walk through the process of converting relative paths to absolute paths in a pandas DataFrame.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found