public void Check(CheckContext context) { var properties = context.ProjectCommonProperties.Result; properties.CheckRequired("TargetFrameworkVersion", "v4.0"); properties.CheckOptional("TargetFrameworkProfile", String.Empty); }
public virtual void Check(CheckContext context) { var config = RequiredProjectFile(context, "App.config"); CheckBuildAction(config, BuildAction.None); CheckCopyToOutput(config, CopyToOutputDirectory.None); }
public override void Check(CheckContext context) { var config = RequiredProjectFile(context, "Web.config"); CheckBuildAction(config, BuildAction.Content); CheckCopyToOutput(config, CopyToOutputDirectory.None); }
public void Check(CheckContext context) { var items = context.LocalFiles.Result .Where(item => item != Paths.ProjectFileName + ".vspscc") .Where(item => !item.StartsWith(@"$tf\")) .Where(item => !item.EndsWith(".DotSettings")) .ToList(); var required = context.ProjectFiles.Result .Select(file => file.FullName) .Union(new[] { Paths.ProjectFileName }) .ToList(); string description; if (!CheckEntries(items, required, out description)) { throw new FailedCheckException( @"All files under source control should match the files included into project: {0} Please include necessary files into project or remove them from source control.", description); } }
public override void Check(CheckContext context) { var config = RequiredProjectFile(context, String.Format("{0}.exe.config.default", Args.ProjectName)); CheckBuildAction(config, BuildAction.Content); CheckCopyToOutput(config, CopyToOutputDirectory.Always); }
public void Check(CheckContext context) { m_lines = ParseLines(context); m_projects = ParseProjects(m_lines); CheckVisualStudioVersion(); CheckTeamFoundationServer(); CheckSolutionConfigurationPlatforms(); CheckProjectConfigurationPlatforms(); }
protected ProjectFile RequiredProjectFile(CheckContext context, string fileName) { var files = context.ProjectFiles.Result; var file = files.FirstOrDefault(i => i.FullName == fileName); file.Check( i => i != null, String.Format("Project is expected to have '{0}' file.", fileName)); return(file); }
protected ProjectFile RequiredProjectFile(CheckContext context, string fileName) { var files = context.ProjectFiles.Result; var file = files.FirstOrDefault(i => i.FullName == fileName); file.Check( i => i != null, String.Format("Project is expected to have '{0}' file.", fileName)); return file; }
public void Check(CheckContext context) { var solutionName = Path.GetFileName(Paths.TfsSolutionFile); var solution = context.TfsSolutionItems.Result .Where(item => Path.GetFileName(item) == solutionName) .FirstOrDefault(); if (solution == null) throw new FailedCheckException("Project should have a primary solution file '{0}' placed in parent folder.", solutionName); }
public void Check(CheckContext context) { var details = "That is because documentation type was set to 'None' for this project."; var debug = context.ProjectDebugProperties.Result; debug.CheckOptional("NoWarn", String.Empty, details); debug.CheckOptional("DocumentationFile", String.Empty, details); var release = context.ProjectReleaseProperties.Result; release.CheckOptional("NoWarn", String.Empty, details); release.CheckOptional("DocumentationFile", String.Empty, details); }
private Dictionary <string, int> GetTfsEncodings(CheckContext context) { Console.WriteLine("Getting file encodings from TFS..."); var files = context.Tfs.GetAllItems(Args.TfsPath) .Where(item => item.Encoding > 0) .ToDictionary( item => item.ServerPath.ReplaceIgnoreCase(Args.TfsPath + '/', String.Empty), item => item.Encoding); Console.WriteLine("Found {0} text files.", files.Count); return(files); }
public void Check(CheckContext context) { var solutionName = Path.GetFileName(Paths.TfsSolutionFile); var solution = context.TfsSolutionItems.Result .Where(item => Path.GetFileName(item) == solutionName) .FirstOrDefault(); if (solution == null) { throw new FailedCheckException("Project should have a primary solution file '{0}' placed in parent folder.", solutionName); } }
public void Check(CheckContext context) { var details = "That is because documentation type was set to 'Full' for this project."; var debug = context.ProjectDebugProperties.Result; var debugXml = String.Format("{0}{1}.xml", debug["OutputPath"], Args.AssemblyName); debug.CheckOptional("NoWarn", String.Empty, details); debug.CheckRequired("DocumentationFile", debugXml, details); var release = context.ProjectReleaseProperties.Result; var releaseXml = String.Format("{0}{1}.xml", release["OutputPath"], Args.AssemblyName); release.CheckOptional("NoWarn", String.Empty, details); release.CheckRequired("DocumentationFile", releaseXml, details); }
public void Check(CheckContext context) { var file = context.LocalFiles.Result .Where(f => Path.GetFileName(f) == "AssemblyInfo.cs") .ToList(); if (file.Count == 0) throw new FailedCheckException("Cannot find assembly information file."); if (file.Count > 1) throw new FailedCheckException("There should be one assembly information file, but {0} files were found.", file.Count); if (file[0] != @"Properties\AssemblyInfo.cs") throw new FailedCheckException("Project file should be named 'AssemblyInfo.cs' and placed in 'Properties' folder."); }
public void Check(CheckContext context) { var projectFolder = Path.GetFileName(Args.TfsPath); if (projectFolder == Args.ProjectName) return; const string prefix = "CnetContent."; if (Args.ProjectName.StartsWith(prefix)) { var custom = Args.ProjectName.Substring(prefix.Length); if (projectFolder == custom) return; } throw new FailedCheckException("Project folder '{0}' does not conform with project name '{1}'.", projectFolder, Args.ProjectName); }
public void Check(CheckContext context) { var packages = context.TfsSolutionItems.Result .Where(item => Path.GetFileName(item) == "packages") .FirstOrDefault(); if (packages == null) return; var files = context.TfsPackagesItems.Result; if (files.Count == 1 && files[0] == Paths.TfsRepositoriesConfig) return; throw new FailedCheckException(@"Solution folder 'packages' should contain only a single file named 'repositories.config'. It should not contain binary contents from other packages as it leads to TFS overfill."); }
public void Check(CheckContext context) { var nuget = context.TfsSolutionItems.Result .Where(item => Path.GetFileName(item) == ".nuget") .FirstOrDefault(); if (nuget == null) throw new FailedCheckException(@"There should be a folder named '.nuget' under solution folder. Please refer to a different solution and copy it from there."); var config = context.TfsNugetItems.Result; if (config.Count == 1 && config[0] == Paths.TfsNugetConfig) return; throw new FailedCheckException(@"Solution folder '.nuget' should contain only a single file named 'nuget.config'. Please refer to a different solution and copy it from there."); }
public void Check(CheckContext context) { var project = context.ProjectDocument.Result; var platforms = project.GetUsedPlatforms(); if (platforms.Count != 1) { throw new FailedCheckException( "We agreed project should only have one platform defined, but {0} platforms were found: {1}.", platforms.Count, String.Join(", ", platforms.Select(name => "'" + name + "'"))); } var platform = platforms[0]; if (platform != "AnyCPU" && platform != "x64" && platform != "x86") { throw new FailedCheckException( @"Found unknown configuration '{0}'. Please use standard platforms only, the most common and recommended one is 'Any CPU'.", platform); } var debug = context.ProjectDebugProperties.Result; debug.CheckOptional("PlatformTarget", platform); var release = context.ProjectReleaseProperties.Result; release.CheckOptional("PlatformTarget", platform); var condition = project.GetDefaultPlatform(); if (condition != platform) { throw new FailedCheckException( @"According to the project configuration, the default value for the '$(Platform)' build variable should be set to '{0}', but now it's '{1}'. This might happen, especially if project platform was changed after the project was initially created with another platform (e.g. from AnyCPU to x64). Please consider editing project file manually, by locating the tag <Platform Condition="" '$(Platform)' == '' "">... and changing its value.", platform, condition); } }
public void Check(CheckContext context) { var file = context.LocalFiles.Result .Where(f => Path.GetFileName(f) == "AssemblyInfo.cs") .ToList(); if (file.Count == 0) { throw new FailedCheckException("Cannot find assembly information file."); } if (file.Count > 1) { throw new FailedCheckException("There should be one assembly information file, but {0} files were found.", file.Count); } if (file[0] != @"Properties\AssemblyInfo.cs") { throw new FailedCheckException("Project file should be named 'AssemblyInfo.cs' and placed in 'Properties' folder."); } }
public void Check(CheckContext context) { var packages = context.TfsSolutionItems.Result .Where(item => Path.GetFileName(item) == "packages") .FirstOrDefault(); if (packages == null) { return; } var files = context.TfsPackagesItems.Result; if (files.Count == 1 && files[0] == Paths.TfsRepositoriesConfig) { return; } throw new FailedCheckException(@"Solution folder 'packages' should contain only a single file named 'repositories.config'. It should not contain binary contents from other packages as it leads to TFS overfill."); }
public void Check(CheckContext context) { var nuget = context.TfsSolutionItems.Result .Where(item => Path.GetFileName(item) == ".nuget") .FirstOrDefault(); if (nuget == null) { throw new FailedCheckException(@"There should be a folder named '.nuget' under solution folder. Please refer to a different solution and copy it from there."); } var config = context.TfsNugetItems.Result; if (config.Count == 1 && config[0] == Paths.TfsNugetConfig) { return; } throw new FailedCheckException(@"Solution folder '.nuget' should contain only a single file named 'nuget.config'. Please refer to a different solution and copy it from there."); }
public void Check(CheckContext context) { var lines = File.ReadAllLines(Paths.AssemblyInfoFile); var properties = ParseProperties(lines); properties.CheckRequired("Title", Args.AssemblyName); properties.CheckRequired("Description", String.Empty); properties.CheckRequired("Configuration", String.Empty); properties.CheckRequired("Company", Args.CompanyName); properties.CheckRequired("Product", Args.AssemblyName); var copyrightRegex = new Regex(String.Format(@"^Copyright © {0} 20[0-2]\d$", Args.CompanyName)); properties.CheckRequired( "Copyright", copyrightRegex.IsMatch, String.Format("Usually it should end with '... {0} {1}', or another year.", Args.CompanyName, DateTime.UtcNow.Year)); properties.CheckRequired("Trademark", String.Empty); properties.CheckRequired("Culture", String.Empty); properties.CheckRequired("Version", "1.0.0.0"); properties.CheckOptional("FileVersion", "1.0.0.0"); }
public void Check(CheckContext context) { var projectFolder = Path.GetFileName(Args.TfsPath); if (projectFolder == Args.ProjectName) { return; } const string prefix = "CnetContent."; if (Args.ProjectName.StartsWith(prefix)) { var custom = Args.ProjectName.Substring(prefix.Length); if (projectFolder == custom) { return; } } throw new FailedCheckException("Project folder '{0}' does not conform with project name '{1}'.", projectFolder, Args.ProjectName); }
private static void CheckProject() { var tfs = new TfsClient(Config.TfsUrl); var context = new CheckContext(tfs); foreach (var issue in Args.CheckIssues.Split('|')) { var checker = GetChecker(issue); try { checker.Check(context); } catch (FailedCheckException e) { throw new InvalidOperationException( String.Format( @" *** FAILED CHECK {0} // {1} *** {2} If you beleive everything is correct please talk to Oleg Shuruev to improve this check. ", issue, checker.GetType().Name, e.Message), e); } Console.WriteLine("{0}... OK", issue); } }
public virtual void Check(CheckContext context) { Check(context.LocalFiles.Result, ".csproj"); }
private Dictionary<string, int> GetTfsEncodings(CheckContext context) { Console.WriteLine("Getting file encodings from TFS..."); var files = context.Tfs.GetAllItems(Args.TfsPath) .Where(item => item.Encoding > 0) .ToDictionary( item => item.ServerPath.ReplaceIgnoreCase(Args.TfsPath + '/', String.Empty), item => item.Encoding); Console.WriteLine("Found {0} text files.", files.Count); return files; }
public void Check(CheckContext context) { var properties = context.ProjectCommonProperties.Result; properties.CheckOptional("StartupObject", String.Empty); }
public void Check(CheckContext context) { var encodings = GetTfsEncodings(context); var signatures = GetLocalUtf8BomSignatures(encodings.Keys); // skip files which are marked as UTF-8 in TFS and using BOM var exclude = encodings .Where(i => i.Value == 65001) .Select(i => i.Key) .Where(signatures.ContainsKey) .Where(i => signatures[i]) .ToList(); foreach (var file in exclude) { encodings.Remove(file); signatures.Remove(file); } var required = new List <string>(); var mismatched = new List <string>(); var exceptional = new List <string>(); var ansi = GetLocalOnlyAnsiCharacters(encodings); foreach (var file in encodings.Keys) { if (ShouldAlwaysUseUtf8WithBom(file)) { // some files (like *.cs or *.config) should always be saved with BOM and marked as UTF-8 in TFS required.Add(file); } else if (signatures[file]) { // file saved with BOM but not marked as UTF-8 in TFS mismatched.Add(file); } else if (!ansi[file]) { // all other files are forced to be UTF-8 + BOM only if they are using non-ANSI characters exceptional.Add(file); } } if (required.Count == 0 && exceptional.Count == 0) { return; } var sb = new StringBuilder(); Func <string, string> format = file => { return(String.Format( "- {0} ({1} BOM, marked as {2})", file, signatures[file] ? "uses" : "no", encodings[file])); }; if (required.Count > 0) { sb.AppendLine("The following files should always be saved with BOM and marked as UTF-8 (65001) in TFS:"); foreach (var file in required) { sb.AppendLine(format(file)); } } if (mismatched.Count > 0) { if (sb.Length > 0) { sb.AppendLine(" "); } sb.AppendLine("The following files are saved with BOM, so they should rather be marked as UTF-8 (65001) in TFS:"); foreach (var file in mismatched) { sb.AppendLine(format(file)); } } if (exceptional.Count > 0) { if (sb.Length > 0) { sb.AppendLine(" "); } sb.AppendLine("The following files use non-ANSI characters, so they should rather be saved with BOM and marked as UTF-8 (65001) in TFS:"); foreach (var file in exceptional) { sb.AppendLine(format(file)); } } throw new FailedCheckException( @"{0} Please update TFS encodings using 'Advanced/Properties...' dialog, and/or save required files using 'Advanced Save Options...' command in Visual Studio. This should help other team memebers to avoid possible conflicts while working with such files in Visual Studio and other tools.", sb.ToString()); }
public void Check(CheckContext context) { var encodings = GetTfsEncodings(context); var signatures = GetLocalUtf8BomSignatures(encodings.Keys); // skip files which are marked as UTF-8 in TFS and using BOM var exclude = encodings .Where(i => i.Value == 65001) .Select(i => i.Key) .Where(signatures.ContainsKey) .Where(i => signatures[i]) .ToList(); foreach (var file in exclude) { encodings.Remove(file); signatures.Remove(file); } var required = new List<string>(); var mismatched = new List<string>(); var exceptional = new List<string>(); var ansi = GetLocalOnlyAnsiCharacters(encodings); foreach (var file in encodings.Keys) { if (ShouldAlwaysUseUtf8WithBom(file)) { // some files (like *.cs or *.config) should always be saved with BOM and marked as UTF-8 in TFS required.Add(file); } else if (signatures[file]) { // file saved with BOM but not marked as UTF-8 in TFS mismatched.Add(file); } else if (!ansi[file]) { // all other files are forced to be UTF-8 + BOM only if they are using non-ANSI characters exceptional.Add(file); } } if (required.Count == 0 && exceptional.Count == 0) return; var sb = new StringBuilder(); Func<string, string> format = file => { return String.Format( "- {0} ({1} BOM, marked as {2})", file, signatures[file] ? "uses" : "no", encodings[file]); }; if (required.Count > 0) { sb.AppendLine("The following files should always be saved with BOM and marked as UTF-8 (65001) in TFS:"); foreach (var file in required) { sb.AppendLine(format(file)); } } if (mismatched.Count > 0) { if (sb.Length > 0) sb.AppendLine(" "); sb.AppendLine("The following files are saved with BOM, so they should rather be marked as UTF-8 (65001) in TFS:"); foreach (var file in mismatched) { sb.AppendLine(format(file)); } } if (exceptional.Count > 0) { if (sb.Length > 0) sb.AppendLine(" "); sb.AppendLine("The following files use non-ANSI characters, so they should rather be saved with BOM and marked as UTF-8 (65001) in TFS:"); foreach (var file in exceptional) { sb.AppendLine(format(file)); } } throw new FailedCheckException( @"{0} Please update TFS encodings using 'Advanced/Properties...' dialog, and/or save required files using 'Advanced Save Options...' command in Visual Studio. This should help other team memebers to avoid possible conflicts while working with such files in Visual Studio and other tools.", sb.ToString()); }
private static List<string> ParseLines(CheckContext context) { var file = context.TfsSolutionFile.Result; return file.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).ToList(); }
private static List <string> ParseLines(CheckContext context) { var file = context.TfsSolutionFile.Result; return(file.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).ToList()); }