public void Execute(BuildRequest request, ZlpDirectoryInfo workingDirectory) { // https://docs.aws.amazon.com/codedeploy/latest/userguide/writing-app-spec.html try { ZlpFileInfo appSpecFile = (from f in workingDirectory.GetFiles("appspec.yml", SearchOption.TopDirectoryOnly) select f).SingleOrDefault(); if (appSpecFile == null) { Program.Logger.Warn("Generating AppSpec file. For advanced configuration create and include an appspec.yml at the root of your project. See: https://docs.aws.amazon.com/codedeploy/latest/userguide/app-spec-ref-structure.html"); string appSpecFilePath = Path.Combine(workingDirectory.FullName, "appspec.yml"); appSpecFile = new ZlpFileInfo(appSpecFilePath); AppSpec appSpec = this.BuildAppSpec(request, workingDirectory); using (FileStream stream = appSpecFile.OpenCreate()) { using (StreamWriter sWriter = new StreamWriter(stream)) { using (StringWriter writer = new StringWriter()) { YamlDotNet.Serialization.Serializer serializer = new YamlDotNet.Serialization.Serializer(); serializer.Serialize(writer, appSpec); var yaml = writer.ToString(); sWriter.WriteLine(yaml); Program.Logger.Info("----------------------- BEGIN APPSPEC -----------------------"); Program.Logger.Info(yaml); Program.Logger.Info("----------------------- END APPSPEC -----------------------"); } } } } else { Program.Logger.Info(" An AppSpec file was found in the working directory. This plug-in will not generate an AppSec."); } } catch (Exception ex) { Program.Logger.Error(ex); throw ex; } }