public static FrameworkName ParseFrameworkNameFromFilePath(string filePath, out string effectivePath)
{
var knownFolders = new string[]
{
Constants.ContentDirectory,
Constants.LibDirectory,
Constants.ToolsDirectory
};
for (int i = 0; i < knownFolders.Length; i++)
{
string folderPrefix = knownFolders[i] + System.IO.Path.DirectorySeparatorChar;
if (filePath.Length > folderPrefix.Length &&
filePath.StartsWith(folderPrefix, StringComparison.OrdinalIgnoreCase))
{
string frameworkPart = filePath.Substring(folderPrefix.Length);
try
{
return VersionUtility.ParseFrameworkFolderName(
frameworkPart,
strictParsing: knownFolders[i] != Constants.ContentDirectory,
effectivePath: out effectivePath);
}
catch (ArgumentException)
{
// if the parsing fails, we treat it as if this file
// doesn't have target framework.
effectivePath = frameworkPart;
return null;
}
}
}
effectivePath = filePath;
return null;
}