Merge pull request #2744 from cdmihai/cdmihai/throwWhenRedirectingBadDlls
Add exception handling when makerunable fails
This commit is contained in:
commit
57a684c912
3 changed files with 48 additions and 33 deletions
|
@ -178,6 +178,8 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
|
||||||
}
|
}
|
||||||
|
|
||||||
private static AssemblyReferenceInfo GetAssemblyInfo(LibraryAsset arg)
|
private static AssemblyReferenceInfo GetAssemblyInfo(LibraryAsset arg)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
using (var peReader = new PEReader(File.OpenRead(arg.ResolvedPath)))
|
using (var peReader = new PEReader(File.OpenRead(arg.ResolvedPath)))
|
||||||
{
|
{
|
||||||
|
@ -208,6 +210,11 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
|
||||||
return new AssemblyReferenceInfo(identity, references.ToArray());
|
return new AssemblyReferenceInfo(identity, references.ToArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
throw new InvalidDataException($"Could not read assembly info for {arg.ResolvedPath}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static string GetPublicKeyToken(byte[] bytes)
|
private static string GetPublicKeyToken(byte[] bytes)
|
||||||
{
|
{
|
||||||
|
|
|
@ -58,7 +58,8 @@ namespace Microsoft.DotNet.Cli
|
||||||
}
|
}
|
||||||
catch (GracefulException e)
|
catch (GracefulException e)
|
||||||
{
|
{
|
||||||
Console.WriteLine(e.Message.Red().Bold());
|
Console.WriteLine(CommandContext.IsVerbose() ? e.ToString().Red().Bold() : e.Message.Red().Bold());
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|
|
@ -112,6 +112,8 @@ namespace Microsoft.DotNet.Tools.Build
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MakeRunnable(ProjectGraphNode graphNode)
|
private void MakeRunnable(ProjectGraphNode graphNode)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var runtimeContext = graphNode.ProjectContext.ProjectFile.HasRuntimeOutput(_args.ConfigValue) ?
|
var runtimeContext = graphNode.ProjectContext.ProjectFile.HasRuntimeOutput(_args.ConfigValue) ?
|
||||||
_args.Workspace.GetRuntimeContext(graphNode.ProjectContext, _args.GetRuntimes()) :
|
_args.Workspace.GetRuntimeContext(graphNode.ProjectContext, _args.GetRuntimes()) :
|
||||||
|
@ -125,6 +127,11 @@ namespace Microsoft.DotNet.Tools.Build
|
||||||
var executable = new Executable(runtimeContext, outputPaths, libraryExporter, _args.ConfigValue);
|
var executable = new Executable(runtimeContext, outputPaths, libraryExporter, _args.ConfigValue);
|
||||||
executable.MakeCompilationOutputRunnable();
|
executable.MakeCompilationOutputRunnable();
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
throw new Exception($"Failed to make the following project runnable: {graphNode.ProjectContext.GetDisplayName()}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override CompilationResult RunCompile(ProjectGraphNode projectNode)
|
protected override CompilationResult RunCompile(ProjectGraphNode projectNode)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue