/// <summary>
 /// This function was added as a defensive measure where we saw a couple of times
 /// a file was created for what should have been a directory. This caused the
 /// build scripts to fail in a very non obvious way.
 ///
 /// </summary>
 /// <param name="path"></param>
 private static void DeleteIntermediateDirectory(string path)
 {
     if (File.Exists(path))
     {
         GeneralFileOperations.DeleteFile(path);
     }
     if (Directory.Exists(path))
     {
         GeneralFileOperations.DeleteDirectory(path);
     }
 }
예제 #2
0
 /// <summary>
 /// Modifies the install for W2K8.
 /// </summary>
 /// <param name="configuration">The configuration.</param>
 /// <param name="results">The results.</param>
 public static void ModifyInstallForW2k8(
     BuildControlParameters configuration,
     DailyBuildFullResults results)
 {
     Console.WriteLine("Modifying Installation for W2k8 ....");
     try
     {
         string fileName = Path.Combine(configuration.WpdtLkgTargetPath, BuildControlParameters.FileToModifyForW2k8);
         File.SetAttributes(fileName, FileAttributes.Normal);
         string[] fileContents             = File.ReadAllLines(fileName);
         bool     foundSection             = false;
         bool     foundInstallOnLHS        = false;
         bool     foundInstallonWin7Server = false;
         for (Int32 i = 0; i < fileContents.Length; i++)
         {
             if (!foundSection)
             {
                 if (fileContents[i].Contains(InstallSection))
                 {
                     foundSection = true;
                     continue;
                 }
             }
             else
             {
                 if (fileContents[i].ToLower().Contains(InstallLhs.ToLower()))
                 {
                     fileContents[i]   = InstallLhs + "=0";
                     foundInstallOnLHS = true;
                     continue;
                 }
                 if (fileContents[i].ToLower().Contains(InstallServer.ToLower()))
                 {
                     fileContents[i]          = InstallServer + "=0";
                     foundInstallonWin7Server = true;
                     break;
                 }
             }
         }
         if (foundSection && foundInstallOnLHS && foundInstallonWin7Server)
         {
             File.WriteAllLines(fileName + ".tmp", fileContents);
             GeneralFileOperations.DeleteFile(fileName);
             GeneralFileOperations.RenameFile(fileName + ".tmp", fileName);
             Console.WriteLine("Successfully completed modifying the installation for W2k8!");
         }
         else
         {
             ProgramExecutionLog.AddEntry(
                 "Failed to find expected settings to enable W2k8 install. This may or not be a problem");
             results.ModifyWdpt.SetResults(false,
                                           "Failed to find expected settings to enable W2k8 install. This may or not be a problem");
         }
     }
     catch (Exception e)
     {
         ProgramExecutionLog.AddEntry(
             "Failed to modify for W2k8 install. This may or not be a problem");
         results.ModifyWdpt.SetResults(false, e.Message);
     }
 }