@@ -86,24 +86,31 @@ public Task<int> RunAsync(string[] args)
86
86
87
87
public static string GetEntryApplicationPath ( )
88
88
{
89
- // Assembly::Location always returns an empty string if the application was published as a single file
89
+ #if NETFRAMEWORK
90
+ // Single file publishing does not exist with .NET Framework so
91
+ // we can just use reflection to get the entry assembly path.
92
+ return Assembly . GetEntryAssembly ( ) . Location ;
93
+ #else
94
+ // Assembly::Location always returns an empty string if the application
95
+ // was published as a single file
90
96
#pragma warning disable IL3000
91
97
bool isSingleFile = string . IsNullOrEmpty ( Assembly . GetEntryAssembly ( ) ? . Location ) ;
92
98
#pragma warning restore IL3000
93
99
94
- // Use "argv[0]" to get the full path to the entry executable - this is consistent across
95
- // .NET Framework and .NET >= 5 when published as a single file.
100
+ // Use "argv[0]" to get the full path to the entry executable in
101
+ // .NET 5+ when published as a single file.
96
102
string [ ] args = Environment . GetCommandLineArgs ( ) ;
97
103
string candidatePath = args [ 0 ] ;
98
104
99
- // If we have not been published as a single file on .NET 5 then we must strip the ".dll" file extension
100
- // to get the default AppHost/SuperHost name.
105
+ // If we have not been published as a single file then we must strip the
106
+ // ".dll" file extension to get the default AppHost/SuperHost name.
101
107
if ( ! isSingleFile && Path . HasExtension ( candidatePath ) )
102
108
{
103
109
return Path . ChangeExtension ( candidatePath , null ) ;
104
110
}
105
111
106
112
return candidatePath ;
113
+ #endif
107
114
}
108
115
109
116
/// <summary>
0 commit comments