@@ -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