Skip to content
This repository was archived by the owner on Nov 7, 2019. It is now read-only.

Commit 00d573a

Browse files
thomasbrugginkstajs
authored andcommitted
SpecFlow 2.4.0 does not work with Specflow.NetCore (#79)
* Fixed the regex for removing MSTest descriptions * Use -p when using specflow.exe 2.4.0 or above * All parameters should be -- instead of /
1 parent 40acf79 commit 00d573a

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/SpecFlow.NetCore/Fixer.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ internal class Fixer
1717
private string _testFramework;
1818
private FileInfo[] _featureFiles;
1919
private readonly string _toolsVersion;
20+
private string _specFlowVersion;
2021

2122
public Fixer(string specFlowPath = null, string testFramework = null, string toolsVersion = "14.0")
2223
{
@@ -147,12 +148,12 @@ private void EnsureSpecFlow(FileInfo csproj)
147148
{
148149
if (string.IsNullOrWhiteSpace(_specFlowExe))
149150
{
150-
if (!TryGetSpecFlowVersion(csproj, out string specFlowVersion))
151+
if (!TryGetSpecFlowVersion(csproj, out _specFlowVersion))
151152
{
152153
throw new XmlException("Could not get SpecFlow version from: " + csproj.FullName);
153154
}
154155

155-
_specFlowExe = FindSpecFlow(specFlowVersion);
156+
_specFlowExe = FindSpecFlow(_specFlowVersion);
156157
WriteLine("Found: " + _specFlowExe);
157158
return;
158159
}
@@ -220,7 +221,16 @@ private static string FixNunit(string content)
220221
private void RunSpecFlow(string csproj)
221222
{
222223
// Credit: http://www.marcusoft.net/2010/12/specflowexe-and-mstest.html
223-
var arguments = $@"generateall ""{csproj}"" /force /verbose";
224+
var arguments = "generateall ";
225+
// Version 2.4.0 and higher require the -p parameter
226+
// Version 2.3.2 and below cannot work with the -p parameter so we can't add
227+
var projectParameterVersion = Version.Parse("2.4.0");
228+
var localSpecFlowVersion = Version.Parse(_specFlowVersion);
229+
if (localSpecFlowVersion >= projectParameterVersion)
230+
arguments += $@"-p ""{csproj}"" --force --verbose";
231+
else
232+
arguments += $@"""{csproj}"" /force /verbose";
233+
224234
WriteLine($"Calling: {_specFlowExe} {arguments}");
225235

226236
var p = new Process

0 commit comments

Comments
 (0)