Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit ebb6689

Browse files
committed
fallback to looking at v4* dirs in reference assemblies directory
1 parent ffdf69c commit ebb6689

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/ServiceStack.Text/Env.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,7 @@ public static string ReferenceAssembyPath
8787
{
8888
var programFilesPath = PclExport.Instance.GetEnvironmentVariable("ProgramFiles(x86)") ?? @"C:\Program Files (x86)";
8989
var netFxReferenceBasePath = programFilesPath + @"\Reference Assemblies\Microsoft\Framework\.NETFramework\";
90-
if ((netFxReferenceBasePath + @"v4.6\").DirectoryExists())
91-
referenceAssembyPath = netFxReferenceBasePath + @"v4.6\";
92-
else if ((netFxReferenceBasePath + @"v4.5.2\").DirectoryExists())
90+
if ((netFxReferenceBasePath + @"v4.5.2\").DirectoryExists())
9391
referenceAssembyPath = netFxReferenceBasePath + @"v4.5.2\";
9492
else if ((netFxReferenceBasePath + @"v4.5.1\").DirectoryExists())
9593
referenceAssembyPath = netFxReferenceBasePath + @"v4.5.1\";
@@ -98,9 +96,24 @@ public static string ReferenceAssembyPath
9896
else if ((netFxReferenceBasePath + @"v4.0\").DirectoryExists())
9997
referenceAssembyPath = netFxReferenceBasePath + @"v4.0\";
10098
else
99+
{
100+
var dir = new DirectoryInfo(netFxReferenceBasePath);
101+
if (dir.Exists)
102+
{
103+
var fxDirs = dir.GetDirectories();
104+
foreach (var fxDir in fxDirs)
105+
{
106+
if (fxDir.Name.StartsWith("v4"))
107+
{
108+
return referenceAssembyPath = netFxReferenceBasePath + fxDir.Name + @"\";
109+
}
110+
}
111+
}
112+
101113
throw new FileNotFoundException(
102114
"Could not infer .NET Reference Assemblies path, e.g '{0}'.\n".Fmt(netFxReferenceBasePath + @"v4.0\") +
103115
"Provide path manually 'Env.ReferenceAssembyPath'.");
116+
}
104117
}
105118
#endif
106119
return referenceAssembyPath;

0 commit comments

Comments
 (0)