Exemplo n.º 1
0
        private void LookForProjectFile(DirectoryInfo dir, Config currentConfig)
        {
            var projectFiles = dir.GetFiles().Where(f => f.Extension.In(".csproj", ".vbproj", ".fsproj", ".sqlproj"));

            LookForConfigFileAndMaybeChangeConfiguration(dir, currentConfig);

            foreach (var projectFile in projectFiles)
            {
                string projectPath = projectFile.DirectoryName;

                XDocument doc = XDocument.Load(projectFile.FullName);
                XNamespace vsNamespace = Constants.VisualStudioProjectFileXmlNamespace;

                var filesIncludedInCurrentProject = doc.Element(vsNamespace + "Project")
                    .Descendants(vsNamespace + "ItemGroup")
                    .SelectMany(x => x.Elements().Where(y => y.Name.LocalName.In(Constants.VisualStudioBuildActions)).Select(y => y.Attribute("Include").Value)).ToArray();

                GenerateMessage("----Project found : " + projectFile.Name);
                LookForProjectMissingFiles(filesIncludedInCurrentProject, projectPath, dir, currentConfig);
            }

            if (projectFiles == null || projectFiles.Count() == 0)
            {
                foreach (DirectoryInfo subDir in dir.GetDirectories())
                {
                    LookForProjectFile(subDir, currentConfig);
                }
            }
        }
Exemplo n.º 2
0
 private void LookForConfigFileAndMaybeChangeConfiguration(DirectoryInfo currentDir, Config currentConfig)
 {
     //look for any file with this extension
     FileInfo configFile = currentDir.GetFiles().Where(f => f.Name.ToLower().EndsWith(".vspniff")).FirstOrDefault();
     if (configFile != null)
     {
         Config newConfig = Config.Load(configFile.FullName);
         currentConfig.Merge(newConfig);
     }
 }
Exemplo n.º 3
0
 public void Merge(Config config)
 {
     if (config.Mode == ConfigFileMode.Override)
     {
         ExcludedExtensions = config.ExcludedExtensions;
         ExcludedDirs = config.ExcludedDirs;
     }
     else if (config.Mode == ConfigFileMode.Append)
     {
         ExcludedDirs = ExcludedDirs.Union(config.ExcludedDirs).ToArray();
         ExcludedExtensions = ExcludedExtensions.Union(config.ExcludedExtensions).ToArray();
     }
 }
Exemplo n.º 4
0
        public void SetUp()
        {
            _config = new Config
            {
                Mode = ConfigFileMode.Append,
                ExcludedDirs = "bin,obj".Split(','),
                ExcludedExtensions = "bat,exe,com".Split(',')
            };

            _config2 = new Config
            {
                Mode = ConfigFileMode.Append,
                ExcludedDirs = new string[] { "bin", "trash", "home" },
                ExcludedExtensions = new string[] { "exe", "bin", "zip" }
            };
        }
Exemplo n.º 5
0
        private void LookForProjectMissingFiles(string[] projectFiles, string projectPath, DirectoryInfo dir, Config currentConfig)
        {
            string relativeDirPath = dir.FullName.Replace(projectPath + "\\", "");
            LookForConfigFileAndMaybeChangeConfiguration(dir, currentConfig);
            if (!currentConfig.ExcludedDirs.Any(x => relativeDirPath.StartsWith(x)))
            {
                foreach (FileInfo file in dir.GetFiles())
                {
                    string relativeFilePath = file.FullName.Replace(projectPath + "\\", "");

                    if (!currentConfig.ExcludedExtensions.Any(x => x == file.Extension.TrimStart(new char[] { '.' })))
                    {
                        if (!projectFiles.Contains(relativeFilePath))
                        {
                            GenerateMessage("Potentially missing file " + relativeFilePath);
                        }
                    }
                }
                foreach (DirectoryInfo subDir in dir.GetDirectories())
                {
                    LookForProjectMissingFiles(projectFiles, projectPath, subDir, currentConfig);
                }
            }
        }