Fix run behaviour when only single target exists
This commit is contained in:
parent
f81ba05a7c
commit
6ca22e4a56
15 changed files with 197 additions and 7 deletions
|
@ -61,6 +61,7 @@ namespace Microsoft.DotNet.Tools.Run
|
|||
}
|
||||
|
||||
var rids = PlatformServices.Default.Runtime.GetAllCandidateRuntimeIdentifiers();
|
||||
|
||||
if (Framework == null)
|
||||
{
|
||||
var defaultFrameworks = new[]
|
||||
|
@ -69,14 +70,23 @@ namespace Microsoft.DotNet.Tools.Run
|
|||
FrameworkConstants.FrameworkIdentifiers.NetStandardApp,
|
||||
};
|
||||
|
||||
var contexts = ProjectContext.CreateContextForEachFramework(Project, null, rids);
|
||||
_context = contexts.FirstOrDefault(c =>
|
||||
defaultFrameworks.Contains(c.TargetFramework.Framework) && !string.IsNullOrEmpty(c.RuntimeIdentifier));
|
||||
var contexts = ProjectContext.CreateContextForEachFramework(Project, null);
|
||||
|
||||
if (_context == null)
|
||||
ProjectContext context;
|
||||
if (contexts.Count() == 1)
|
||||
{
|
||||
throw new InvalidOperationException($"Couldn't find default target with framework: {string.Join(",", defaultFrameworks)}");
|
||||
context = contexts.Single();
|
||||
}
|
||||
else
|
||||
{
|
||||
context = contexts.FirstOrDefault(c => defaultFrameworks.Contains(c.TargetFramework.Framework));
|
||||
if (context == null)
|
||||
{
|
||||
throw new InvalidOperationException($"Couldn't find target to run. Defaults: {string.Join(", ", defaultFrameworks)}");
|
||||
}
|
||||
}
|
||||
|
||||
_context = context.CreateRuntimeContext(rids);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue