From 1313db19114da7288c19a5df4370dc3c604f4403 Mon Sep 17 00:00:00 2001 From: Erik Ejlskov Jensen Date: Sun, 22 Oct 2023 14:21:04 +0200 Subject: [PATCH] Bug fix: old packages wer auto installed Bug fix: Generate database diagram never shown --- .../EFCorePowerToolsPackage.cs | 6 +++++ src/GUI/RevEng.Shared/Providers.cs | 24 +++++++++++-------- .../Shared/Handlers/Compare/CompareHandler.cs | 11 +++++---- src/GUI/Shared/Handlers/MigrationsHandler.cs | 5 ++-- .../Shared/Handlers/ModelAnalyzerHandler.cs | 5 ++-- .../ReverseEngineer/ReverseEngineerHandler.cs | 3 ++- src/GUI/Shared/Helpers/NuGetHelper.cs | 5 ++-- 7 files changed, 37 insertions(+), 22 deletions(-) diff --git a/src/GUI/EFCorePowerTools/EFCorePowerToolsPackage.cs b/src/GUI/EFCorePowerTools/EFCorePowerToolsPackage.cs index b9452892a..58c16f7ff 100644 --- a/src/GUI/EFCorePowerTools/EFCorePowerToolsPackage.cs +++ b/src/GUI/EFCorePowerTools/EFCorePowerToolsPackage.cs @@ -328,6 +328,12 @@ private async void OnProjectMenuBeforeQueryStatus(object sender, EventArgs e) menuCommand.Visible = false; + if (menuCommand.CommandID.ID == PkgCmdIDList.cmdidDbDgml) + { + menuCommand.Visible = true; + return; + } + var project = await VS.Solutions.GetActiveProjectAsync(); if (project == null) diff --git a/src/GUI/RevEng.Shared/Providers.cs b/src/GUI/RevEng.Shared/Providers.cs index 4f64d7cb6..12b37cc97 100644 --- a/src/GUI/RevEng.Shared/Providers.cs +++ b/src/GUI/RevEng.Shared/Providers.cs @@ -88,14 +88,14 @@ public static List GetNeededPackages(DatabaseType databaseType, bo if (databaseType == DatabaseType.SQLServer || databaseType == DatabaseType.SQLServerDacpac) { - var pkgVersion = "7.0.9"; + var pkgVersion = "7.0.12"; switch (codeGenerationMode) { case CodeGenerationMode.EFCore6: - pkgVersion = "6.0.20"; + pkgVersion = "6.0.23"; break; case CodeGenerationMode.EFCore8: - pkgVersion = "8.0.0-preview.6.23329.4"; + pkgVersion = "8.0.0-rc.2.23480.1"; break; } @@ -149,7 +149,7 @@ public static List GetNeededPackages(DatabaseType databaseType, bo pkgVersion = "3.0.1"; break; case CodeGenerationMode.EFCore8: - pkgVersion = "8.0.0-preview.6.23329.4"; + pkgVersion = "8.0.0-rc.2.23480.1"; break; } @@ -216,14 +216,14 @@ public static List GetNeededPackages(DatabaseType databaseType, bo if (databaseType == DatabaseType.SQLite) { - var pkgVersion = "7.0.9"; + var pkgVersion = "7.0.12"; switch (codeGenerationMode) { case CodeGenerationMode.EFCore6: - pkgVersion = "6.0.20"; + pkgVersion = "6.0.23"; break; case CodeGenerationMode.EFCore8: - pkgVersion = "8.0.0-preview.6.23329.4"; + pkgVersion = "8.0.0-rc.2.23480.1"; break; } @@ -259,14 +259,14 @@ public static List GetNeededPackages(DatabaseType databaseType, bo if (databaseType == DatabaseType.Npgsql) { - var pkgVersion = "7.0.4"; + var pkgVersion = "7.0.11"; switch (codeGenerationMode) { case CodeGenerationMode.EFCore6: - pkgVersion = "6.0.8"; + pkgVersion = "6.0.22"; break; case CodeGenerationMode.EFCore8: - pkgVersion = "8.0.0-preview.4"; + pkgVersion = "8.0.0-rc.2"; break; } @@ -312,6 +312,10 @@ public static List GetNeededPackages(DatabaseType databaseType, bo case CodeGenerationMode.EFCore6: pkgVersion = "6.0.2"; break; + + case CodeGenerationMode.EFCore8: + pkgVersion = "8.0.0-beta.1"; + break; } packages.Add(new NuGetPackage diff --git a/src/GUI/Shared/Handlers/Compare/CompareHandler.cs b/src/GUI/Shared/Handlers/Compare/CompareHandler.cs index df41c18a7..292d56e37 100644 --- a/src/GUI/Shared/Handlers/Compare/CompareHandler.cs +++ b/src/GUI/Shared/Handlers/Compare/CompareHandler.cs @@ -12,6 +12,7 @@ using EFCorePowerTools.Locales; using Microsoft.VisualStudio.Data.Services; using Microsoft.VisualStudio.Shell; +using NuGet.Versioning; namespace EFCorePowerTools.Handlers.Compare { @@ -74,17 +75,17 @@ public async System.Threading.Tasks.Task HandleComparisonAsync(string outputPath var nugetHelper = new NuGetHelper(); if (version.Major == 6) { - nugetHelper.InstallPackage("EfCore.SchemaCompare", project, new Version(6, 0, 0)); + nugetHelper.InstallPackage("EfCore.SchemaCompare", project, new NuGetVersion(6, 0, 0)); } else if (version.Major == 7) { - nugetHelper.InstallPackage("EfCore.SchemaCompare", project, new Version(7, 0, 0)); - nugetHelper.InstallPackage("Microsoft.EntityFrameworkCore.Design", project, new Version(7, 0, 0)); + nugetHelper.InstallPackage("EfCore.SchemaCompare", project, new NuGetVersion(7, 0, 0)); + nugetHelper.InstallPackage("Microsoft.EntityFrameworkCore.Design", project, new NuGetVersion(7, 0, 0)); } else if (version.Major == 8) { - nugetHelper.InstallPackage("EfCore.SchemaCompare", project, new Version(8, 0, 0)); - nugetHelper.InstallPackage("Microsoft.EntityFrameworkCore.Design", project, new Version(8, 0, 0)); + nugetHelper.InstallPackage("EfCore.SchemaCompare", project, new NuGetVersion(8, 0, 0)); + nugetHelper.InstallPackage("Microsoft.EntityFrameworkCore.Design", project, new NuGetVersion(8, 0, 0)); } VSHelper.ShowError(CompareLocale.InstallingEfCoreSchemaCompare); diff --git a/src/GUI/Shared/Handlers/MigrationsHandler.cs b/src/GUI/Shared/Handlers/MigrationsHandler.cs index 407401de1..7ad1426ac 100644 --- a/src/GUI/Shared/Handlers/MigrationsHandler.cs +++ b/src/GUI/Shared/Handlers/MigrationsHandler.cs @@ -6,6 +6,7 @@ using EFCorePowerTools.Helpers; using EFCorePowerTools.Locales; using Microsoft.VisualStudio.Shell; +using NuGet.Versioning; namespace EFCorePowerTools.Handlers { @@ -65,8 +66,8 @@ public async System.Threading.Tasks.Task ManageMigrationsAsync(string outputPath if (!result.Item1) { var nugetHelper = new NuGetHelper(); - nugetHelper.InstallPackage("Microsoft.EntityFrameworkCore.Design", project, version); - VSHelper.ShowError(string.Format(SharedLocale.InstallingEfCoreDesignPackage, version)); + nugetHelper.InstallPackage("Microsoft.EntityFrameworkCore.Design", project, new NuGetVersion(result.Item2)); + VSHelper.ShowError(string.Format(SharedLocale.InstallingEfCoreDesignPackage, new NuGetVersion(result.Item2))); return; } diff --git a/src/GUI/Shared/Handlers/ModelAnalyzerHandler.cs b/src/GUI/Shared/Handlers/ModelAnalyzerHandler.cs index d9320bfc2..c59319e99 100644 --- a/src/GUI/Shared/Handlers/ModelAnalyzerHandler.cs +++ b/src/GUI/Shared/Handlers/ModelAnalyzerHandler.cs @@ -9,6 +9,7 @@ using EFCorePowerTools.Locales; using Microsoft.VisualStudio.Shell; using Microsoft.VisualStudio.Threading; +using NuGet.Versioning; namespace EFCorePowerTools.Handlers { @@ -63,8 +64,8 @@ public async System.Threading.Tasks.Task GenerateAsync(string outputPath, Projec if (!result.Item1) { var nugetHelper = new NuGetHelper(); - nugetHelper.InstallPackage("Microsoft.EntityFrameworkCore.Design", project, version); - VSHelper.ShowError(string.Format(SharedLocale.InstallingEfCoreDesignPackage, version)); + nugetHelper.InstallPackage("Microsoft.EntityFrameworkCore.Design", project, new NuGetVersion(result.Item2)); + VSHelper.ShowError(string.Format(SharedLocale.InstallingEfCoreDesignPackage, new NuGetVersion(result.Item2))); return; } diff --git a/src/GUI/Shared/Handlers/ReverseEngineer/ReverseEngineerHandler.cs b/src/GUI/Shared/Handlers/ReverseEngineer/ReverseEngineerHandler.cs index 76db20c3d..67eb02ab8 100644 --- a/src/GUI/Shared/Handlers/ReverseEngineer/ReverseEngineerHandler.cs +++ b/src/GUI/Shared/Handlers/ReverseEngineer/ReverseEngineerHandler.cs @@ -15,6 +15,7 @@ using EFCorePowerTools.Locales; using Microsoft.VisualStudio.Data.Services; using Microsoft.VisualStudio.Shell; +using NuGet.Versioning; using RevEng.Common; namespace EFCorePowerTools.Handlers.ReverseEngineer @@ -305,7 +306,7 @@ private static async Task InstallNuGetPackagesAsync(Project project, bool onlyGe foreach (var nuGetPackage in packagesToInstall) { - nuGetHelper.InstallPackage(nuGetPackage.PackageId, project, new Version(nuGetPackage.Version)); + nuGetHelper.InstallPackage(nuGetPackage.PackageId, project, new NuGetVersion(nuGetPackage.Version)); } } } diff --git a/src/GUI/Shared/Helpers/NuGetHelper.cs b/src/GUI/Shared/Helpers/NuGetHelper.cs index 7b70b2c17..8713d589e 100644 --- a/src/GUI/Shared/Helpers/NuGetHelper.cs +++ b/src/GUI/Shared/Helpers/NuGetHelper.cs @@ -1,17 +1,18 @@ using System; using System.Diagnostics; using Community.VisualStudio.Toolkit; +using NuGet.Versioning; namespace EFCorePowerTools.Helpers { public class NuGetHelper { - public void InstallPackage(string packageId, Project project, Version version = null) + public void InstallPackage(string packageId, Project project, NuGetVersion version = null) { var args = $"add \"{project.FullPath}\" package {packageId} "; if (version != null) { - args += "-v " + version.ToString(3); + args += "-v " + version.ToString(); } var startInfo = new ProcessStartInfo