PR Feedback
This commit is contained in:
parent
abff1f474c
commit
8d2733e147
3 changed files with 41 additions and 51 deletions
|
@ -106,9 +106,9 @@ namespace Microsoft.DotNet.Cli.Utils
|
||||||
{
|
{
|
||||||
if (framework == null) return null;
|
if (framework == null) return null;
|
||||||
|
|
||||||
var projectRootPath = PathUtility.GetProjectRootPath();
|
var projectRootPath = Directory.GetCurrentDirectory();
|
||||||
|
|
||||||
if (projectRootPath == null) return null;
|
if (!File.Exists(Path.Combine(projectRootPath, Project.FileName))) return null;
|
||||||
|
|
||||||
var commandName = Path.GetFileNameWithoutExtension(executable);
|
var commandName = Path.GetFileNameWithoutExtension(executable);
|
||||||
|
|
||||||
|
@ -124,15 +124,15 @@ namespace Microsoft.DotNet.Cli.Utils
|
||||||
.Where(n => Path.GetFileNameWithoutExtension(n) == commandName)
|
.Where(n => Path.GetFileNameWithoutExtension(n) == commandName)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
return fileNames.Contains(commandName + FileNameSuffixes.ExeSuffix) &&
|
return fileNames.Contains(commandName + FileNameSuffixes.DotNet.Exe) &&
|
||||||
fileNames.Contains(commandName + FileNameSuffixes.DynamicLib) &&
|
fileNames.Contains(commandName + FileNameSuffixes.DotNet.DynamicLib) &&
|
||||||
fileNames.Contains(commandName + FileNameSuffixes.Deps);
|
fileNames.Contains(commandName + FileNameSuffixes.DotNet.Deps);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (commandPackage == null) return null;
|
if (commandPackage == null) return null;
|
||||||
|
|
||||||
var commandPath = commandPackage.Library.Files
|
var commandPath = commandPackage.Library.Files
|
||||||
.First(f => Path.GetFileName(f) == commandName + FileNameSuffixes.ExeSuffix);
|
.First(f => Path.GetFileName(f) == commandName + FileNameSuffixes.DotNet.Exe);
|
||||||
|
|
||||||
return Path.Combine(projectContext.PackagesDirectory, commandPackage.Path, commandPath);
|
return Path.Combine(projectContext.PackagesDirectory, commandPackage.Path, commandPath);
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,41 +199,5 @@ namespace Microsoft.DotNet.Tools.Common
|
||||||
return GetPathWithBackSlashes(path);
|
return GetPathWithBackSlashes(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetProjectRootPath(string path = null)
|
|
||||||
{
|
|
||||||
var directoryPath = Directory.GetCurrentDirectory();
|
|
||||||
|
|
||||||
if (path != null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
directoryPath = Path.GetDirectoryName(path);
|
|
||||||
}
|
|
||||||
catch (ArgumentException)
|
|
||||||
{
|
|
||||||
throw new ArgumentException("Illegal Characters in Path", nameof(directoryPath));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!Directory.Exists(directoryPath))
|
|
||||||
{
|
|
||||||
throw new ArgumentException($"'{directoryPath}' does not exist.", nameof(directoryPath));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
string projectRootPath = null;
|
|
||||||
|
|
||||||
var directory = new DirectoryInfo(directoryPath);
|
|
||||||
|
|
||||||
while (projectRootPath == null && directory != null)
|
|
||||||
{
|
|
||||||
if (directory.GetFiles("project.json").Any())
|
|
||||||
projectRootPath = directory.FullName;
|
|
||||||
|
|
||||||
directory = directory.GetFiles("global.json").Any() ? null : directory.Parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
return projectRootPath;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,18 +4,44 @@ namespace Microsoft.DotNet.ProjectModel
|
||||||
{
|
{
|
||||||
public static class FileNameSuffixes
|
public static class FileNameSuffixes
|
||||||
{
|
{
|
||||||
public static readonly string DynamicLib =
|
public static PlatformFileNameSuffixes DotNet { get; } = new PlatformFileNameSuffixes
|
||||||
RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".dll" :
|
{
|
||||||
RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? ".dylib" : ".so";
|
DynamicLib = ".dll",
|
||||||
|
Exe = ".exe",
|
||||||
|
ProgramDatabase = ".pdb",
|
||||||
|
StaticLib = ".lib",
|
||||||
|
Deps = ".deps",
|
||||||
|
};
|
||||||
|
|
||||||
public static readonly string ExeSuffix =
|
public static PlatformFileNameSuffixes Windows { get; } = new PlatformFileNameSuffixes
|
||||||
RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".exe" : string.Empty;
|
{
|
||||||
|
DynamicLib = ".dll",
|
||||||
|
Exe = ".exe",
|
||||||
|
ProgramDatabase = ".pdb",
|
||||||
|
StaticLib = ".lib",
|
||||||
|
Deps = ".deps",
|
||||||
|
};
|
||||||
|
|
||||||
public const string ProgramDatabase = ".pdb";
|
public static PlatformFileNameSuffixes OSX { get; } = new PlatformFileNameSuffixes
|
||||||
|
{
|
||||||
|
DynamicLib = ".dylib",
|
||||||
|
Exe = "",
|
||||||
|
ProgramDatabase = ".pdb",
|
||||||
|
StaticLib = ".a",
|
||||||
|
Deps = ".deps"
|
||||||
|
};
|
||||||
|
|
||||||
public static readonly string StaticLib =
|
public struct PlatformFileNameSuffixes
|
||||||
RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".lib" : ".a" ;
|
{
|
||||||
|
public string DynamicLib { get; set; }
|
||||||
|
|
||||||
public static readonly string Deps = ".deps";
|
public string Exe { get; set; }
|
||||||
|
|
||||||
|
public string ProgramDatabase { get; set; }
|
||||||
|
|
||||||
|
public string StaticLib { get; set; }
|
||||||
|
|
||||||
|
public string Deps { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue