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

Commit c1a1230

Browse files
TimMurphystajs
authored andcommitted
Make tools version configurable (#59)
* Make tools version configurable Resolved #56 with a new optional command line argument --tools-version. --tools-version defaults to 14.0. When running SpecFlow.NetCore on an machine with only Visual Studio 2017 installed then set --tools-version to 4.0. * Set toolsVerision to "14.0" in the optional argument instead of having it as nul
1 parent 529f47f commit c1a1230

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/SpecFlow.NetCore/Args.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ internal class Args
1010
public const string SpecFlowPathArgName = "--specflow-path";
1111
public const string WorkingDirectoryArgName = "--working-directory";
1212
public const string TestFrameworkArgName = "--test-framework";
13+
public const string ToolsVersionArgName = "--tools-version";
1314

1415
public string SpecFlowPath { get; }
1516
public DirectoryInfo WorkingDirectory { get; }
1617
public string TestFramework { get; }
18+
public string ToolsVersion { get; }
1719

1820
public Args(string[] args)
1921
{
@@ -55,6 +57,10 @@ public Args(string[] args)
5557
TestFramework = value;
5658
break;
5759

60+
case ToolsVersionArgName:
61+
ToolsVersion = value;
62+
break;
63+
5864
default:
5965
throw new Exception("Unknown argument: " + name);
6066
}

src/SpecFlow.NetCore/Fixer.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ internal class Fixer
1414
private readonly string _specFlowExe;
1515
private string _testFramework;
1616
private FileInfo[] _featureFiles;
17+
private readonly string _toolsVersion;
1718

18-
public Fixer(string specFlowPath = null, string testFramework = null)
19+
public Fixer(string specFlowPath = null, string testFramework = null, string toolsVersion = "14.0")
1920
{
2021
_specFlowExe = FindSpecFlow(specFlowPath);
2122
WriteLine("Found: " + _specFlowExe);
2223

2324
_testFramework = testFramework;
25+
_toolsVersion = toolsVersion;
2426
}
2527

2628
private string FindSpecFlow(string path)
@@ -184,8 +186,8 @@ private FileInfo SaveFakeCsProj(DirectoryInfo directory, FileInfo csproj)
184186
var sb = new StringBuilder();
185187

186188
// Set the "ToolsVersion" to VS2013, see: https://github.com/techtalk/SpecFlow/issues/471
187-
sb.Append(@"<?xml version=""1.0"" encoding=""utf-8""?>
188-
<Project ToolsVersion=""14.0"" DefaultTargets=""Build"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
189+
sb.Append($@"<?xml version=""1.0"" encoding=""utf-8""?>
190+
<Project ToolsVersion=""{_toolsVersion}"" DefaultTargets=""Build"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
189191
<PropertyGroup>
190192
<RootNamespace>SpecFlow.GeneratedTests</RootNamespace>
191193
<AssemblyName>SpecFlow.GeneratedTests</AssemblyName>

src/SpecFlow.NetCore/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public static int Main(string[] args)
1010
try
1111
{
1212
var a = new Args(args);
13-
var fixer = new Fixer(a.SpecFlowPath, a.TestFramework);
13+
var fixer = new Fixer(a.SpecFlowPath, a.TestFramework, a.ToolsVersion);
1414
fixer.Fix(a.WorkingDirectory);
1515

1616
PrintUsingColor("SpecFlow fixed.", ConsoleColor.Green);

0 commit comments

Comments
 (0)