public static void makeDefectPortable()

in SmvLibrary/Utility.cs [701:758]


        public static void makeDefectPortable(string bugFolderPath)
        {
            if (!Directory.Exists(bugFolderPath))
            {
                Log.LogFatalError("Bug folder path not found");
            }
            try
            {
                //to update defect.tt file
                string defectTtFileContents = File.ReadAllText(bugFolderPath + "\\defect.tt");

                string pattern = @"([a-zA-Z]:[\\[a-zA-Z0-9 ._-]+]*\.?[a-zA-Z]+)";
                List<string> files = new List<string>();

                foreach (Match match in Regex.Matches(defectTtFileContents, pattern))
                {
                    if (!files.Contains(match.Value))
                    {
                        files.Add(match.Value);
                    }
                }

                //getting smvsrcfiles to an array
                string smvSrcFilesPath = Path.Combine(smvVars["smvOutputDir"], "smvsrcfiles");
                if (File.Exists(smvSrcFilesPath)){
                    string[] smvSrcFiles = File.ReadAllLines(smvSrcFilesPath);
                    foreach (string smvSrcFile in smvSrcFiles)
                    {
                        if (!files.Contains(smvSrcFile))
                        {
                            files.Add(smvSrcFile);
                        }
                    }
                }

                foreach (string file in files)
                {
                    try
                    {
                        string destinationPath = Path.Combine("src", file.Trim().Replace(":", ""));
                        CopyFile(file.Trim(), Path.Combine(bugFolderPath, destinationPath), null);
                        defectTtFileContents = defectTtFileContents.Replace(file.Trim(), destinationPath);
                    }
                    catch (Exception)
                    {
                        Log.LogError("Exception while copying " + file + "while making defects portable");
                        continue;
                    }
                }

                File.WriteAllText(bugFolderPath + "\\defect.tt", defectTtFileContents);
            }

            catch (Exception e)
            {
                Log.LogFatalError("Exception occurred in trying to make defect portable - " + e);
            }
        }