I'm adding a Nuke build project to my solution.
I need to create a target which copies the compiled files to a custom folder. You can think of it as a sort of deploy.
How do I get the output folder of a specific project?
For example, if the project is called "MyProject" and it's in the C:\git\test\MyProject
folder, I need to get the output path based on the current configuration and platform, such as C:\git\test\MyProject\bin\x64\Release
.
I tried this one, but it gives me the first value of the OutputPath
property, not the one for the current configuration and platform:
readonly Configuration Configuration = Configuration.Release;
readonly MSBuildTargetPlatform Platform = MSBuildTargetPlatform.x64;
// ...
Target LocalDeploy => _ => _
.DependsOn(Compile)
.Executes(() =>
{
var myProject = Solution.GetProject("MyProject");
var outputPath = myProject.GetProperty("OutputPath"); // this returns bin\Debug
var fullOutputPath = myProject.Directory / outputPath;
CopyDirectoryRecursively(fullOutputPath, @"C:\DeployPath");
});
I also tried this way, which honor the Configuration but not the Platform:
var myProject = Solution.GetProject("MyProject");
var myMSBuildProject = visionTools3Project.GetMSBuildProject(Configuration);
var outputPath = myProject.GetProperty("OutputPath"); // this returns bin\Release
var fullOutputPath = myProject.Directory / outputPath;
CopyDirectoryRecursively(fullOutputPath, @"C:\DeployPath");