From 69c0375b3f9288b6eef06fae80c2c95918b78e63 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Fri, 19 Feb 2016 14:43:30 -0800 Subject: [PATCH] Add error message when runtime target is not found --- src/Microsoft.DotNet.ProjectModel/ProjectContext.cs | 8 +++++++- test/dotnet-compile.UnitTests/GivenACompilationDriver.cs | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.DotNet.ProjectModel/ProjectContext.cs b/src/Microsoft.DotNet.ProjectModel/ProjectContext.cs index 8741d1c8a..0a70f373c 100644 --- a/src/Microsoft.DotNet.ProjectModel/ProjectContext.cs +++ b/src/Microsoft.DotNet.ProjectModel/ProjectContext.cs @@ -143,7 +143,13 @@ namespace Microsoft.DotNet.ProjectModel public ProjectContext CreateRuntimeContext(IEnumerable runtimeIdentifiers) { - return Create(ProjectFile.ProjectFilePath, TargetFramework, runtimeIdentifiers); + var context = Create(ProjectFile.ProjectFilePath, TargetFramework, runtimeIdentifiers); + if (context.RuntimeIdentifier == null) + { + var rids = string.Join(",", runtimeIdentifiers); + throw new InvalidOperationException($"Can not find runtime target for framework '{TargetFramework}' and RID's {rids}."); + } + return context; } public OutputPaths GetOutputPaths(string configuration, string buidBasePath = null, string outputPath = null) diff --git a/test/dotnet-compile.UnitTests/GivenACompilationDriver.cs b/test/dotnet-compile.UnitTests/GivenACompilationDriver.cs index 0a1e1d47b..b277c4169 100644 --- a/test/dotnet-compile.UnitTests/GivenACompilationDriver.cs +++ b/test/dotnet-compile.UnitTests/GivenACompilationDriver.cs @@ -36,7 +36,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Tests _contexts = new List { - ProjectContext.Create(_projectJson, new NuGetFramework(string.Empty)) + ProjectContext.Create(_projectJson, NuGetFramework.Parse("dnxcore50")) }; _args = new CompilerCommandApp("dotnet compile", ".NET Compiler", "Compiler for the .NET Platform");