@@ -86,24 +86,31 @@ public Task<int> RunAsync(string[] args)
8686
8787 public static string GetEntryApplicationPath ( )
8888 {
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
9096#pragma warning disable IL3000
9197 bool isSingleFile = string . IsNullOrEmpty ( Assembly . GetEntryAssembly ( ) ? . Location ) ;
9298#pragma warning restore IL3000
9399
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.
96102 string [ ] args = Environment . GetCommandLineArgs ( ) ;
97103 string candidatePath = args [ 0 ] ;
98104
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.
101107 if ( ! isSingleFile && Path . HasExtension ( candidatePath ) )
102108 {
103109 return Path . ChangeExtension ( candidatePath , null ) ;
104110 }
105111
106112 return candidatePath ;
113+ #endif
107114 }
108115
109116 /// <summary>
0 commit comments