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

Commit c0c09d2

Browse files
zdeneksejcekstajs
authored andcommitted
SpecFlow path compatibility fix for Linux and Mac systems + user profile path improvement (#70)
1 parent f3112ed commit c0c09d2

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/SpecFlow.NetCore/Fixer.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public Fixer(string specFlowPath = null, string testFramework = null, string too
2828
private static string FindSpecFlow(string version)
2929
{
3030
string path;
31-
var relativePathToSpecFlow = string.Format(@"SpecFlow\{0}\tools\specflow.exe", version);
31+
var relativePathToSpecFlow = Path.Combine("SpecFlow", version, "tools", "specflow.exe");
3232

3333
var nugetPackagesPath = Environment.GetEnvironmentVariable("NUGET_PACKAGES");
3434

@@ -41,11 +41,14 @@ private static string FindSpecFlow(string version)
4141

4242
throw new FileNotFoundException("NUGET_PACKAGES environment variable found, but SpecFlow doesn't exist: " + path);
4343
}
44-
45-
// For full .NET Framework, you can get the user profile with: Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)
46-
// This isn't available yet in .NET Core, so rely on the environment variable for now.
44+
4745
var userProfile = Environment.GetEnvironmentVariable("USERPROFILE");
4846

47+
if (string.IsNullOrWhiteSpace(userProfile))
48+
{
49+
userProfile = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
50+
}
51+
4952
path = Path.Combine(userProfile, ".nuget", "packages", relativePathToSpecFlow);
5053

5154
if (File.Exists(path))

0 commit comments

Comments
 (0)