Bug 18768 - mkbundle Assembly CodeBase uses Current Working Directory
Summary: mkbundle Assembly CodeBase uses Current Working Directory
Alias: None
Product: Runtime
Classification: Mono
Component: Tools ()
Version: 3.2.x
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2014-04-02 17:59 UTC by dabitp
Modified: 2018-01-24 21:58 UTC (History)
4 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description dabitp 2014-04-02 17:59:42 UTC
Operating System: (Mac OSX Mavericks) Darwin Kernel Version 13.1.0: Thu Jan 16 19:40:37 PST 2014; root:xnu-2422.90.20~2/RELEASE_X86_64

Mono Version: Mono JIT compiler version 3.2.6 ((no/9b58377 Thu Jan 16 17:49:56 EST 2014)

Simple Console Application:

	class MainClass
		public static void Main (string[] args)
			Console.WriteLine (Assembly.GetExecutingAssembly().CodeBase);

When executing the produced program either in the Xamarin Studio debugger or via:

mono assemblyName.exe

it works as expected. 

When I use mkbundle to compile the application it returns the incorrect output. It appears to use the current directory appended by the assembly name instead of showing the directory of the assembly.

Expected and working output without using a mkbundle executable:

Incorrect output of the same executable generated by mkbundle:
Comment 1 dabitp 2014-04-02 18:38:56 UTC
I think I forgot to mention that this error occurs when you are in a directory that does not contain the executable. So I ran the mkbundle via ./Debug/testAssembly.mac
Comment 2 Ludovic Henry 2018-01-24 21:02:17 UTC

This is because mkbundle embed the assembly inside the executable, to make it possible to ship as a standalone executable. This is then not a bug, but the expected behavior.

Could you please explain how that breaks your existing solution?

Thank you,
Comment 3 dabitp 2018-01-24 21:58:46 UTC
I honestly don't remember the issue, since it's been a while now (don't work on the project anymore).

We can go ahead and resolve this.