/// <summary>Analyzes the project.</summary> /// <param name="project">The project.</param> /// <param name="allProjects">All projects.</param> /// <param name="allSolutions">All solutions.</param> /// <returns>The results.</returns> public async Task <IEnumerable <AnalyzeResult> > AnalyzeAsync(VsProject project, IList <VsProject> allProjects, IList <VsSolution> allSolutions) { var results = new List <AnalyzeResult>(); if (project.NuGetPackageTitle != null && project.NuGetPackageTitle.Contains(".") && project.NuGetPackageTitle.Contains(" ") == false && project.NuGetPackageId != project.NuGetPackageTitle) { var result = new AnalyzeResult( "NuGet Package ID does not match the ID-styled title", "The project's NuGet Package ID '" + project.NuGetPackageId + "' does not match the ID-styled (contains dots and no spaces) title '" + project.NuGetPackageTitle + "'."); results.Add(result); } return(results); }
public async Task <IEnumerable <AnalyzeResult> > AnalyzeAsync( VsProject project, IList <VsProject> allProjects, IList <VsSolution> allSolutions) { var results = new List <AnalyzeResult>(); foreach (var assembly in project.AssemblyReferences.Where(a => a.IsNuGetReference)) { var isAnyNuGetVersionMissing = project.NuGetReferences .All(r => r.Name != assembly.NuGetPackageName); if (isAnyNuGetVersionMissing) { var result = new AnalyzeResult( "Assembly reference has no NuGet dependency in packages.config", "The project references a DLL in the NuGet packages directory but the " + "packages.config does not contain a NuGet dependency with the given name. \n" + " Assembly: " + assembly.Name + "\n" + " HintPath: " + assembly.HintPath); results.Add(result); } else { var missmatchingNuGetReference = project.NuGetReferences .FirstOrDefault(r => r.Name == assembly.NuGetPackageName && r.Version != assembly.NuGetPackageVersion); if (missmatchingNuGetReference != null) { var result = new AnalyzeResult( "Assembly reference version does not match corresponding NuGet version", "The project references a DLL in the NuGet packages directory but the " + "packages.config does not contain a NuGet dependency with the referenced version. \n" + " NuGet Package: " + missmatchingNuGetReference.Name + "\n" + " Version: " + missmatchingNuGetReference.Version + "\n" + " Assembly: " + assembly.Name + "\n" + " HintPath: " + assembly.HintPath); results.Add(result); } } } return(results); }
/// <summary>Analyzes the project.</summary> /// <param name="project">The project.</param> /// <param name="allProjects">All projects.</param> /// <param name="allSolutions">All solutions.</param> /// <returns>The results.</returns> public async Task <IEnumerable <AnalyzeResult> > AnalyzeAsync(VsProject project, IList <VsProject> allProjects, IList <VsSolution> allSolutions) { var results = new List <AnalyzeResult>(); if (project.NuGetPackageTitle != null) { var otherProjects = allProjects .Where(p => p.Name != project.Name && p.NuGetPackageId == project.NuGetPackageId) .Select(p => p.Name) .ToList(); if (otherProjects.Any()) { var result = new AnalyzeResult( "NuGet Package ID is used multiple times", "The projects " + string.Join(", ", otherProjects) + " have the same NuGet Package IDs."); results.Add(result); } } return(results); }
public async Task <IEnumerable <AnalyzeResult> > AnalyzeAsync(VsProject project, IList <VsProject> allProjects, IList <VsSolution> allSolutions) { var results = new List <AnalyzeResult>(); var headIndex = project.Path.ToLower().IndexOf("\\head\\", StringComparison.InvariantCulture); if (headIndex != -1) { var buildScope = project.Path.Substring(0, headIndex + 6); if (File.Exists(Path.Combine(buildScope, "start.proj"))) { foreach (var nuGetReference in project.NuGetReferences) { foreach (var nuGetProject in allProjects.Where(p => p.NuGetPackageId == nuGetReference.Name)) { var nuGetHeadIndex = nuGetProject.Path.ToLowerInvariant().IndexOf("\\head\\", StringComparison.InvariantCulture); if (nuGetHeadIndex != -1) { var nuGetBuildScope = nuGetProject.Path.Substring(0, nuGetHeadIndex + 6); if (buildScope == nuGetBuildScope) { var result = new AnalyzeResult( "Project references a NuGet from the same build scope", "The project references the NuGet package '" + nuGetReference.Name + "' which is located in the same build scope. \n" + "To avoid problems, remove the NuGet reference and add an assembly reference instead."); results.Add(result); } } } } } } return(results); }