diff --git a/Changelog.md b/Changelog.md index 58c1d1a..446f1ed 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,6 +4,7 @@ Improvements: * Support for .NET 5 projects (Issue #67, thx for Timothée Lecomte) * Support for SpecFlow v3.7 projects (Issue #69) +* Do not warn for missing 'SpecFlow.Tools.MsBuild.Generation' package when SpecFlow v3.3 or later is used # v1.6.1 - 2020-05-13 diff --git a/Deveroom.VisualStudio/ProjectSystem/Settings/SpecFlowProjectSettingsProvider.cs b/Deveroom.VisualStudio/ProjectSystem/Settings/SpecFlowProjectSettingsProvider.cs index 38f73c5..5c852ec 100644 --- a/Deveroom.VisualStudio/ProjectSystem/Settings/SpecFlowProjectSettingsProvider.cs +++ b/Deveroom.VisualStudio/ProjectSystem/Settings/SpecFlowProjectSettingsProvider.cs @@ -122,7 +122,9 @@ private NuGetPackageReference GetSpecFlowPackage(IProjectScope projectScope, IEn var specFlowPackage = detector.GetSpecFlowPackage(packageReferencesArray); if (specFlowPackage != null) { - if (detector.IsMsBuildGenerationEnabled(packageReferencesArray)) + var specFlowVersion = specFlowPackage.Version.Version; + if (detector.IsMsBuildGenerationEnabled(packageReferencesArray) || + IsImplicitMsBuildGeneration(detector, specFlowVersion, packageReferencesArray)) specFlowProjectTraits |= SpecFlowProjectTraits.MsBuildGeneration; if (detector.IsXUnitAdapterEnabled(packageReferencesArray)) specFlowProjectTraits |= SpecFlowProjectTraits.XUnitAdapter; @@ -133,6 +135,12 @@ private NuGetPackageReference GetSpecFlowPackage(IProjectScope projectScope, IEn return specFlowPackage; } + private bool IsImplicitMsBuildGeneration(SpecFlowPackageDetector detector, Version specFlowVersion, NuGetPackageReference[] packageReferencesArray) + { + return specFlowVersion >= new Version(3, 3) && + detector.IsSpecFlowTestFrameworkPackagesUsed(packageReferencesArray); + } + private string GetSpecFlowConfigFilePath(IProjectScope projectScope) { var projectFolder = projectScope.ProjectFolder; diff --git a/Deveroom.VisualStudio/ProjectSystem/SpecFlowPackageDetector.cs b/Deveroom.VisualStudio/ProjectSystem/SpecFlowPackageDetector.cs index 2af0ae6..ad0afa8 100644 --- a/Deveroom.VisualStudio/ProjectSystem/SpecFlowPackageDetector.cs +++ b/Deveroom.VisualStudio/ProjectSystem/SpecFlowPackageDetector.cs @@ -11,16 +11,24 @@ internal class SpecFlowPackageDetector public const string SpecFlowToolsMsBuildGenerationPackageName = "SpecFlow.Tools.MsBuild.Generation"; public const string SpecFlowXUnitAdapterPackageName = "SpecFlow.xUnitAdapter"; public const string CucumberExpressionPluginPackageNamePrefix = "CucumberExpressions.SpecFlow"; + public const string SpecFlowPlusRunnerPluginPackageNamePrefix = "SpecRun.SpecFlow"; - private static readonly string[] KnownSpecFlowPackages = + private static readonly string[] SpecFlowTestFrameworkPackages = { "SpecFlow.MsTest", "SpecFlow.xUnit", "SpecFlow.NUnit", - "SpecFlow.MsTest", - SpecFlowToolsMsBuildGenerationPackageName + "SpecFlow.MsTest" }; + private static readonly string[] KnownSpecFlowPackages = + SpecFlowTestFrameworkPackages + .Concat(new[] + { + SpecFlowToolsMsBuildGenerationPackageName + }) + .ToArray(); + private const string SpecRunPackageRe = @"^SpecRun.SpecFlow.(?[\d-]+)$"; private const string SpecSyncPackageRe = @"^SpecSync.AzureDevOps.SpecFlow.(?[\d-]+)$"; @@ -52,6 +60,11 @@ public bool IsCucumberExpressionPluginEnabled(IEnumerable return packageReferences.Any(pr => pr.PackageName != null && pr.PackageName.StartsWith(CucumberExpressionPluginPackageNamePrefix)); } + public bool IsSpecFlowTestFrameworkPackagesUsed(NuGetPackageReference[] packageReferences) + { + return packageReferences.Any(pr => SpecFlowTestFrameworkPackages.Contains(pr.PackageName) || pr.PackageName.StartsWith(SpecFlowPlusRunnerPluginPackageNamePrefix)); + } + public NuGetPackageReference GetSpecFlowPackage(IEnumerable packageReferences) { NuGetPackageReference knownSpecFlowPackage = null;