【发布时间】:2020-06-24 08:02:22
【问题描述】:
我正在向我的解决方案添加一个Nuke 构建项目。
我需要创建一个将编译文件复制到自定义文件夹的目标。您可以将其视为一种部署。
如何获取特定项目的输出文件夹?
比如项目名为“MyProject”,在C:\git\test\MyProject文件夹下,我需要根据当前配置和平台获取输出路径,如C:\git\test\MyProject\bin\x64\Release。
我试过这个,但它给了我OutputPath 属性的第一个值,而不是当前配置和平台的值:
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");
});
我也尝试过这种方式,它尊重配置而不是平台:
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");
【问题讨论】:
标签: c# build nuke-build