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

Commit

Permalink
Made reference assembly lookup work on 32bit machines
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfowl committed May 24, 2014
1 parent f4d707a commit bf084e8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 14 deletions.
32 changes: 28 additions & 4 deletions src/Microsoft.Framework.Runtime/FrameworkReferenceResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,29 @@ public string GetFriendlyFrameworkName(FrameworkName targetFramework)
return null;
}

public static string GetReferenceAssembliesPath()
{
// References assemblies are in %ProgramFiles(x86)% on
// 64 bit machines
var programFiles = Environment.GetEnvironmentVariable("ProgramFiles(x86)");

if (string.IsNullOrEmpty(programFiles))
{
// On 32 bit machines they are in %ProgramFiles%
programFiles = Environment.GetEnvironmentVariable("ProgramFiles");
}

if (string.IsNullOrEmpty(programFiles))
{
// Reference assemblies aren't installed
return null;
}

return Path.Combine(
programFiles,
"Reference Assemblies", "Microsoft", "Framework");
}

private void PopulateCache()
{
if (PlatformHelper.IsMono)
Expand Down Expand Up @@ -84,11 +107,12 @@ private void PopulateCache()
}
else
{
string defaultPath = Path.Combine(
Environment.ExpandEnvironmentVariables("%ProgramFiles(x86)%"),
"Reference Assemblies", "Microsoft", "Framework");
string referenceAssembliesPath = GetReferenceAssembliesPath();

PopulateReferenceAssemblies(defaultPath);
if (!string.IsNullOrEmpty(referenceAssembliesPath))
{
PopulateReferenceAssemblies(referenceAssembliesPath);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Runtime.Versioning;
using System.Security;
using System.Xml;
using Microsoft.Framework.Runtime;

namespace NuGet
{
Expand Down Expand Up @@ -70,21 +71,21 @@ private static NetPortableProfileCollection BuildPortableProfileCollection()
{
var profileCollection = new NetPortableProfileCollection();

#if NET45 // CORECLR_TODO: Environment.GetFolderPath
string portableRootDirectory =
Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86, Environment.SpecialFolderOption.DoNotVerify),
@"Reference Assemblies\Microsoft\Framework\.NETPortable");
var referenceAssembliesPath = FrameworkReferenceResolver.GetReferenceAssembliesPath();

if (Directory.Exists(portableRootDirectory))
if (!string.IsNullOrEmpty(referenceAssembliesPath))
{
foreach (string versionDir in Directory.EnumerateDirectories(portableRootDirectory, "v*", SearchOption.TopDirectoryOnly))
string portableRootDirectory = Path.Combine(referenceAssembliesPath, ".NETPortable");

if (Directory.Exists(portableRootDirectory))
{
string profileFilesPath = versionDir + @"\Profile\";
profileCollection.AddRange(LoadProfilesFromFramework(versionDir, profileFilesPath));
foreach (string versionDir in Directory.EnumerateDirectories(portableRootDirectory, "v*", SearchOption.TopDirectoryOnly))
{
string profileFilesPath = versionDir + @"\Profile\";
profileCollection.AddRange(LoadProfilesFromFramework(versionDir, profileFilesPath));
}
}
}
#endif

return profileCollection;
}
Expand Down

0 comments on commit bf084e8

Please sign in to comment.