Merge pull request #1565 from dotnet/pakrym/messages

Add better messages for run scenarios
This commit is contained in:
Pavel Krymets 2016-02-24 17:31:45 -08:00
commit 6013ee0981
2 changed files with 9 additions and 3 deletions

View file

@ -146,8 +146,12 @@ namespace Microsoft.DotNet.ProjectModel
var context = Create(ProjectFile.ProjectFilePath, TargetFramework, runtimeIdentifiers); var context = Create(ProjectFile.ProjectFilePath, TargetFramework, runtimeIdentifiers);
if (context.RuntimeIdentifier == null) if (context.RuntimeIdentifier == null)
{ {
var rids = string.Join(",", runtimeIdentifiers); var rids = string.Join(", ", runtimeIdentifiers);
throw new InvalidOperationException($"Can not find runtime target for framework '{TargetFramework}' and RID's {rids}."); throw new InvalidOperationException($"Can not find runtime target for framework '{TargetFramework}' and RID's '{rids}'. " +
"Possible causes:" + Environment.NewLine +
"1. Project is not restored or restore failed - run `dotnet restore`" + Environment.NewLine +
"2. Project is not targeting `runable` framework (`netstandardapp*` or `net*`)"
);
} }
return context; return context;
} }

View file

@ -82,7 +82,9 @@ namespace Microsoft.DotNet.Tools.Run
context = contexts.FirstOrDefault(c => defaultFrameworks.Contains(c.TargetFramework.Framework)); context = contexts.FirstOrDefault(c => defaultFrameworks.Contains(c.TargetFramework.Framework));
if (context == null) if (context == null)
{ {
throw new InvalidOperationException($"Couldn't find target to run. Defaults: {string.Join(", ", defaultFrameworks)}"); throw new InvalidOperationException($"Couldn't find target to run. Possible causes:" + Environment.NewLine +
"1. No project.lock.json file or restore failed - run `dotnet restore`" + Environment.NewLine +
$"2. project.lock.json has multiple targets none of which is in default list ({string.Join(", " , defaultFrameworks)})");
} }
} }