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));
There may be a more concise way, but this seems to work:
var buildResultDirRelative = Directory("./build-output") + Directory("v" + semVersion) + Directory("bin");
var buildResultDir = System.IO.Path.GetFullPath(buildResultDirRelative.ToString());
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
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 :+1:
Works great. Thanks :+1:
Excellent:+1:
Most helpful comment
Hi @coxp ,
Version 0.4.2 is now released, in the DSL you can now write:
Thanks for your feedback and interest in Cake :+1: