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())
|
if (_title.IsNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
// Entry assembly is null in tests
|
// Entry assembly is null in tests
|
||||||
var title = EntryAssembly?.GetName().Name ?? "App";
|
UseTitle(EntryAssembly?.GetName().Name ?? "App");
|
||||||
|
|
||||||
UseTitle(title);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_executableName.IsNullOrWhiteSpace())
|
if (_executableName.IsNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
// Entry assembly is null in tests
|
// Entry assembly is null in tests
|
||||||
var entryAssemblyLocation = EntryAssembly?.Location;
|
var entryAssemblyLocation = EntryAssembly?.Location;
|
||||||
var executableName = Path.GetFileNameWithoutExtension(entryAssemblyLocation) ?? "app";
|
|
||||||
|
|
||||||
// Set proper executable name for apps launched with dotnet SDK
|
// Set different executable name depending on location
|
||||||
if (string.Equals(Path.GetExtension(entryAssemblyLocation), ".dll", StringComparison.OrdinalIgnoreCase))
|
if (!entryAssemblyLocation.IsNullOrWhiteSpace())
|
||||||
executableName = "dotnet " + executableName;
|
{
|
||||||
|
// Prepend 'dotnet' to assembly file name if the entry assembly is a dll file (extension needs to be kept)
|
||||||
UseExecutableName(executableName);
|
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())
|
if (_versionText.IsNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
// Entry assembly is null in tests
|
// Entry assembly is null in tests
|
||||||
var versionText = EntryAssembly?.GetName().Version.ToString() ?? "1.0";
|
UseVersionText(EntryAssembly?.GetName().Version.ToString() ?? "1.0");
|
||||||
|
|
||||||
UseVersionText(versionText);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_console == null)
|
if (_console == null)
|
||||||
|
|||||||
Reference in New Issue
Block a user