From 5cdf1e7ab6a45fb22c3dd19af071ab0a54bebf01 Mon Sep 17 00:00:00 2001 From: Noah Falk Date: Fri, 8 Jan 2016 19:20:22 -0800 Subject: [PATCH] Allow ilcpath argument to include "ilc.exe" Allows the argument passed to dotnet compile --native --ilcpath to be either end with ilc.exe, or with the directory that contains ilc.exe. Fix #768 --- .../ArgValues.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.DotNet.Tools.Compiler.Native/ArgValues.cs b/src/Microsoft.DotNet.Tools.Compiler.Native/ArgValues.cs index 16b519a74..c05ccd7ee 100644 --- a/src/Microsoft.DotNet.Tools.Compiler.Native/ArgValues.cs +++ b/src/Microsoft.DotNet.Tools.Compiler.Native/ArgValues.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.IO; namespace Microsoft.DotNet.Tools.Compiler.Native { @@ -56,8 +57,20 @@ namespace Microsoft.DotNet.Tools.Compiler.Native if (!string.IsNullOrEmpty(IlcPath)) { - config.IlcPath = IlcPath; - config.IlcSdkPath = IlcPath; + // We want a directory path. If the user gave us the exact path to the executable + // then we can be helpful and convert that to the directory rather than forcing + // the command to be re-typed. + string ilcDir = IlcPath; + if (File.Exists(IlcPath) && !Directory.Exists(IlcPath)) + { + string potentialIlcDir = Path.GetDirectoryName(IlcPath); + if (Directory.Exists(potentialIlcDir)) + { + ilcDir = potentialIlcDir; + } + } + config.IlcPath = ilcDir; + config.IlcSdkPath = ilcDir; } if (!string.IsNullOrEmpty(IlcSdkPath))