使用Cake(C#make)在树中构建所有解决方案?
作者:互联网
我在同一目录树中有多个VS解决方案,并希望使用Cake构建所有这些解决方案.有没有办法构建所有这些,而不是逐个将它们放入构建脚本?
谢谢你的任何想法
解决方法:
是的,使用内置的globber功能肯定是可能的,例如:
var solutions = GetFiles("./**/*.sln");
Task("Build")
.IsDependentOn("Clean")
.IsDependentOn("Restore")
.Does(() =>
{
// Build all solutions.
foreach(var solution in solutions)
{
Information("Building {0}", solution);
MSBuild(solution, settings =>
settings.SetPlatformTarget(PlatformTarget.MSIL)
.WithProperty("TreatWarningsAsErrors","true")
.WithTarget("Build")
.SetConfiguration(configuration));
}
});
类似地,您可以在使用nuget restore构建之前执行相同的操作,例如
Task("Restore")
.Does(() =>
{
// Restore all NuGet packages.
foreach(var solution in solutions)
{
Information("Restoring {0}...", solution);
NuGetRestore(solution);
}
});
一个干净的任务可以像这样适应
var solutionPaths = solutions.Select(solution => solution.GetDirectory());
Task("Clean")
.Does(() =>
{
// Clean solution directories.
foreach(var path in solutionPaths)
{
Information("Cleaning {0}", path);
CleanDirectories(path + "/**/bin/" + configuration);
CleanDirectories(path + "/**/obj/" + configuration);
}
});
标签:c,msbuild,cakebuild 来源: https://codeday.me/bug/20190611/1217686.html