diff --git a/src/TaskRunner/Commands/BuildCommands.php b/src/TaskRunner/Commands/BuildCommands.php
index 90f9c8b64..a5775d7f4 100644
--- a/src/TaskRunner/Commands/BuildCommands.php
+++ b/src/TaskRunner/Commands/BuildCommands.php
@@ -116,8 +116,6 @@ public function buildDist(array $options = [
         $tasks[] = $this->taskWriteToFile($options['dist-root'] . '/' . $options['root'] . '/VERSION.txt')->text($tag);
 
         // Copy drush.yml file.
-        $tasks[] = $this->taskFilesystemStack()
-            ->mkdir($options['dist-root'] . '/web/sites/all/drush');
         if ($tk_drush = file_exists('resources/Drush/drush.yml.dist')) {
             $tasks[] = $this->taskFilesystemStack()
                 ->copy($tk_drush, $options['dist-root'] . '/web/sites/all/drush/drush.yml');
@@ -128,7 +126,12 @@ public function buildDist(array $options = [
                 'uri' => reset($vHostArray)
             ];
             $yaml = new Yaml();
-            file_put_contents($options['dist-root'] . '/web/sites/all/drush/drush.yml', $yaml->dump($drush_options));
+            $yaml_content = $yaml->dump($drush_options);
+            $yaml_destination = $options['dist-root'] . '/web/sites/all/drush/drush.yml';
+            $tasks[] = $this->taskFilesystemStack()
+                ->mkdir($options['dist-root'] . '/web/sites/all/drush')
+                ->touch($yaml_destination);
+            $tasks[] = $this->taskWriteToFile($yaml_destination)->text($yaml_content);
         }
 
         // Collect and execute list of commands set on local runner.yml.
@@ -192,8 +195,6 @@ public function buildDev(array $options = [
         }
 
         // Copy drush.yml file.
-        $tasks[] = $this->taskFilesystemStack()
-            ->mkdir($root . '/sites/all/drush');
         if ($tk_drush = file_exists('resources/Drush/drush.yml.dist')) {
             $tasks[] = $this->taskFilesystemStack()
                 ->copy($tk_drush, $root . '/sites/all/drush/drush.yml');
@@ -204,7 +205,12 @@ public function buildDev(array $options = [
                 'uri' => reset($vHostArray)
             ];
             $yaml = new Yaml();
-            file_put_contents($root . '/sites/all/drush/drush.yml', $yaml->dump($drush_options));
+            $yaml_content = $yaml->dump($drush_options);
+            $yaml_destination = $root . '/sites/all/drush/drush.yml';
+            $tasks[] = $this->taskFilesystemStack()
+                ->mkdir($root . '/sites/all/drush')
+                ->touch($yaml_destination);
+            $tasks[] = $this->taskWriteToFile($yaml_destination)->text($yaml_content);
         }
 
         // Collect and execute list of commands set on local runner.yml.