public string GetDbContextClassName() { if (_dbContextName != null) { return(_dbContextName); } var dbContextTemplate = Project.FindTemplateInstance(DbContextTemplate.Identifier); if (dbContextTemplate != null) { return(_dbContextName = dbContextTemplate.GetMetaData().FileName); } _log.Warning($"{Identifier} - Could not find template with creates DbContext's name, default used instead."); return(_dbContextName = "DbContext"); }
/// <param name="saveProjectDelegate">T1 = path, T2 = content</param> internal void Execute( IEnumerable <IProject> applicationProjects, ITracing tracing, Action <string, string> saveProjectDelegate, Func <IProject, string> loadProjectDelegate) { string report; var(projectPackages, highestVersions) = DeterminePackages(applicationProjects, loadProjectDelegate); if (_settingConsolidatePackageVersions && !string.IsNullOrWhiteSpace(report = GetPackagesWithMultipleVersionsReport(projectPackages))) { tracing.Info( "Multiple versions exist for one or more NuGet packages within the solution. Intent will now automatically " + "upgrade any lower versions to the highest installed version within the solution. To disable this behaviour " + $"change the 'Consolidate Package Versions' option in Intent in the {Identifier} module configuration." + $"{Environment.NewLine}" + $"{Environment.NewLine}" + $"{report}"); ConsolidatePackageVersions(projectPackages, highestVersions); } foreach (var projectPackage in projectPackages) { if (!projectPackage.RequestedPackages.Any()) { continue; } var updatedProjectContent = projectPackage.Processor.InstallPackages( projectContent: projectPackage.Content, requestedPackages: projectPackage.RequestedPackages, installedPackages: projectPackage.InstalledPackages, projectName: projectPackage.Name, tracing: tracing); saveProjectDelegate(projectPackage.FilePath, updatedProjectContent); } if (_settingWarnOnMultipleVersionsOfSamePackage && !_settingConsolidatePackageVersions && !string.IsNullOrWhiteSpace(report = GetPackagesWithMultipleVersionsReport(projectPackages))) { tracing.Warning( "Multiple versions exist for one or more NuGet packages within the solution. You should consider " + "consolidating these package versions within Visual Studio or alternatively enable the 'Consolidate " + $"Package Versions' option in Intent in the {Identifier} module configuration." + $"{Environment.NewLine}" + $"{Environment.NewLine}" + $"{report}"); } }
public string InstallPackages( string projectContent, Dictionary <string, NuGetPackage> requestedPackages, Dictionary <string, NuGetPackage> installedPackages, string projectName, ITracing tracing) { // This format is now unsupported, but we will show a warnings for missing packages. var installationsRequired = requestedPackages .Where(x => !installedPackages.ContainsKey(x.Key)) .ToArray(); var upgradesRequired = requestedPackages .Where(x => installedPackages.TryGetValue(x.Key, out var nuGetPackage) && nuGetPackage.Version.MinVersion < x.Value.Version.MinVersion) .ToArray(); if (!installationsRequired.Any() && !upgradesRequired.Any()) { return(projectContent); } var sb = new StringBuilder(); sb.AppendLine($"Installations and upgrades of NuGet packages is not supported for project {projectName}, only .csproj files using " + "PackageReferences are. Refer to https://blog.nuget.org/20180409/migrate-packages-config-to-package-reference.html for information " + "on how to upgrade this existing project. You can alternatively manually install/upgrade the following packages using Visual Studio:"); foreach (var item in installationsRequired) { sb.AppendLine($" - Install {item.Key} version {item.Value.Version}"); } foreach (var item in upgradesRequired) { sb.AppendLine($" - Upgrade version of {item.Key} from {installedPackages[item.Key]} to {item.Value.Version}"); } tracing.Warning(sb.ToString()); return(projectContent); }
public void Warning(string message) => _tracing.Warning($"{_prefix}{message}");