This commit is contained in:
Bryan 2016-03-23 12:40:10 -07:00 committed by Bryan Thornbury
parent 850e02a1ce
commit 07f3d60355

View file

@ -59,7 +59,7 @@ namespace Microsoft.DotNet.Cli.Utils
IEnumerable<string> args, IEnumerable<string> args,
string projectDirectory) string projectDirectory)
{ {
var projectContext = GetProjectContextFromDirectory(projectDirectory, s_toolPackageFramework); var projectContext = GetProjectContextFromDirectoryForFirstTarget(projectDirectory);
if (projectContext == null) if (projectContext == null)
{ {
@ -162,29 +162,19 @@ namespace Microsoft.DotNet.Cli.Utils
s_toolPackageFramework); s_toolPackageFramework);
} }
private ProjectContext GetProjectContextFromDirectory(string directory, NuGetFramework framework) private ProjectContext GetProjectContextFromDirectoryForFirstTarget(string projectRootPath)
{ {
if (directory == null || framework == null) if (projectRootPath == null)
{ {
return null; return null;
} }
var projectRootPath = directory;
if (!File.Exists(Path.Combine(projectRootPath, Project.FileName))) if (!File.Exists(Path.Combine(projectRootPath, Project.FileName)))
{ {
return null; return null;
} }
var projectContext = ProjectContext.Create( var projectContext = ProjectContext.CreateContextForEachTarget(projectRootPath).FirstOrDefault();
projectRootPath,
framework,
PlatformServices.Default.Runtime.GetAllCandidateRuntimeIdentifiers());
if (projectContext.RuntimeIdentifier == null)
{
return null;
}
return projectContext; return projectContext;
} }