mirror of
https://github.com/Tyrrrz/CliFx.git
synced 2025-10-25 15:19:17 +00:00
Fix incorrect default executable name for .NET Core apps
This commit is contained in:
@@ -93,30 +93,39 @@ namespace CliFx
|
||||
if (_title.IsNullOrWhiteSpace())
|
||||
{
|
||||
// Entry assembly is null in tests
|
||||
var title = EntryAssembly?.GetName().Name ?? "App";
|
||||
|
||||
UseTitle(title);
|
||||
UseTitle(EntryAssembly?.GetName().Name ?? "App");
|
||||
}
|
||||
|
||||
if (_executableName.IsNullOrWhiteSpace())
|
||||
{
|
||||
// Entry assembly is null in tests
|
||||
var entryAssemblyLocation = EntryAssembly?.Location;
|
||||
var executableName = Path.GetFileNameWithoutExtension(entryAssemblyLocation) ?? "app";
|
||||
|
||||
// Set proper executable name for apps launched with dotnet SDK
|
||||
if (string.Equals(Path.GetExtension(entryAssemblyLocation), ".dll", StringComparison.OrdinalIgnoreCase))
|
||||
executableName = "dotnet " + executableName;
|
||||
|
||||
UseExecutableName(executableName);
|
||||
// Set different executable name depending on location
|
||||
if (!entryAssemblyLocation.IsNullOrWhiteSpace())
|
||||
{
|
||||
// Prepend 'dotnet' to assembly file name if the entry assembly is a dll file (extension needs to be kept)
|
||||
if (string.Equals(Path.GetExtension(entryAssemblyLocation), ".dll", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
UseExecutableName("dotnet " + Path.GetFileName(entryAssemblyLocation));
|
||||
}
|
||||
// Otherwise just use assembly file name without extension
|
||||
else
|
||||
{
|
||||
UseExecutableName(Path.GetFileNameWithoutExtension(entryAssemblyLocation));
|
||||
}
|
||||
}
|
||||
// If location is null then just use a stub
|
||||
else
|
||||
{
|
||||
UseExecutableName("app");
|
||||
}
|
||||
}
|
||||
|
||||
if (_versionText.IsNullOrWhiteSpace())
|
||||
{
|
||||
// Entry assembly is null in tests
|
||||
var versionText = EntryAssembly?.GetName().Version.ToString() ?? "1.0";
|
||||
|
||||
UseVersionText(versionText);
|
||||
UseVersionText(EntryAssembly?.GetName().Version.ToString() ?? "1.0");
|
||||
}
|
||||
|
||||
if (_console == null)
|
||||
|
||||
Reference in New Issue
Block a user