Skip to content

Commit

Permalink
Bug fix: old packages wer auto installed
Browse files Browse the repository at this point in the history
Bug fix: Generate database diagram never shown
  • Loading branch information
ErikEJ committed Oct 22, 2023
1 parent caa1f09 commit 1313db1
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 22 deletions.
6 changes: 6 additions & 0 deletions src/GUI/EFCorePowerTools/EFCorePowerToolsPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 14 additions & 10 deletions src/GUI/RevEng.Shared/Providers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ public static List<NuGetPackage> 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;
}

Expand Down Expand Up @@ -149,7 +149,7 @@ public static List<NuGetPackage> 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;
}

Expand Down Expand Up @@ -216,14 +216,14 @@ public static List<NuGetPackage> 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;
}

Expand Down Expand Up @@ -259,14 +259,14 @@ public static List<NuGetPackage> 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;
}

Expand Down Expand Up @@ -312,6 +312,10 @@ public static List<NuGetPackage> 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
Expand Down
11 changes: 6 additions & 5 deletions src/GUI/Shared/Handlers/Compare/CompareHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using EFCorePowerTools.Locales;
using Microsoft.VisualStudio.Data.Services;
using Microsoft.VisualStudio.Shell;
using NuGet.Versioning;

namespace EFCorePowerTools.Handlers.Compare
{
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions src/GUI/Shared/Handlers/MigrationsHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using EFCorePowerTools.Helpers;
using EFCorePowerTools.Locales;
using Microsoft.VisualStudio.Shell;
using NuGet.Versioning;

namespace EFCorePowerTools.Handlers
{
Expand Down Expand Up @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions src/GUI/Shared/Handlers/ModelAnalyzerHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using EFCorePowerTools.Locales;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Threading;
using NuGet.Versioning;

namespace EFCorePowerTools.Handlers
{
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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));
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/GUI/Shared/Helpers/NuGetHelper.cs
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 1313db1

Please sign in to comment.