我正在向我的解决方案中添加一个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");