Slesa
Slesa

Reputation: 245

Redirect MSBuild output path when using Cake

coming from Fake I am used to keep the standard output of csproj files to bin/debug to be able to debug locally. But when running my build script, I want the files to be compiled to /bin/build in order to create setup scripts or nuget packages.

I tried it with cake, but w/o success:

Task("Build")
.DoesForEach( GetFiles ("**/*.sln" ), (sln) =>
   var settings = new MSBuildSettings()
    .WithProperty("OutputPath", buildDir);
   MSBuild(sln, settings);
});

It produces the right call for MSBuild

"C:/.../MSBuild.exe" /v:normal /p:OutputPath=bin/build /target:Build ...

but unfortunately, the destination dir is empty? Am I missing something?

Thanks in advance

Upvotes: 1

Views: 944

Answers (1)

devlead
devlead

Reputation: 5010

OutputPath needs to be an absolute path, try something like:

Task("Build")
.DoesForEach( GetFiles ("**/*.sln" ), (sln) =>
    DirectoryPath buildDir = MakeAbsolute(Directory("./bin/build"));
    // Use MSBuild
    var settings = new MSBuildSettings()
                        .WithProperty("OutputPath", buildDir.FullPath);
    MSBuild(sln, settings);
});

Upvotes: 3

Related Questions