Open adamralph opened 9 years ago
Here is an example of one of my create directory tasks for some ideas on usage.
.Task("create-artifact-folders").Do(() => {
var dirsToCreate = new[] {
artifactDir,
nugetOutputDir,
logsDir
}.Where(di => !di.Exists);
foreach(var di in dirsToCreate) {
di.Create();
}
System.Threading.Thread.Sleep(100);
})
would be much better as
.Directory("create-artifact-folders").Do(d => d.Create(artifactDir, nugetOutputDir, logsDir));
I envisage the .Directory()
task as just taking a single path which would also serve as the task name, but there could also be a .Directories("foo").Do(() => directories.Paths(artifactDir, nugetOutputDir, logsDir))
Only partially related to the issue:
I have started defining DirectoryInfo and FileInfo instances at the top of my baufile instead of using strings. It's not for everybody but as time goes on I find myself using it more. For example instead of needing to use the snippet I pasted above I am now doing this: OutDir = artifactDir.CreateSubdirectory("publishTemp").FullName
as CreateSubdirectory does nothing if the directory already exists.
Can use the outcome of #187
(Of course, individual plugins can also build in the ability to create folders on the fly if it makes sense in those contexts.)