mono / ngit

Automated jgit port to c#
261 stars 152 forks source link

Cannot do a clean compile on Win7 64-bit due to missing reference #34

Closed WilbertOnGithub closed 12 years ago

WilbertOnGithub commented 12 years ago

I'm trying to compile the latest HEAD of the NGit repository (4ff676bd2c595684c6bd4137fa1f770545d205b9) and this fails because of a missing Mono.Posix reference in the Sharpen project.

The instructions say:

" If you are compiling on Windows using the Microsoft .NET framework you can obtain these libraries (ICSharpCode.SharpZipLib and Mono.Security) .by installing the Mono Libraries package: http://monodevelop.com/files/Windows/MonoLibraries.msi "

However, there is no mention of Mono.Posix and that setup does not install any Mono.Posix library. This is the list of libraries I have in C:\Program Files (x86)\MonoLibraries\2.6:

ICSharpCode.SharpZipLib.dll mautil.exe
Mono.Addins.CecilReflector.dll Mono.Addins.dll Mono.Addins.Gui.dll Mono.Addins.Setup.dll Mono.GetOptions.dll Mono.Security.dll monodoc.dll

Where can I get the correct library to add as a reference? And should the documentation change to reflect this issue?

(I'm trying to verify if #Num: #9 is actually closed by using a new version of NGit - hence the need for a compile)

alanmcgovern commented 12 years ago

Ah, yes. The Sharpen library had to take a dependency on Mono.Posix in order to properly deal with symlinks on non-windows platforms. I'm not sure what the best way to handle this is. On windows the code will never be executed so it would be safe to remove the reference and then comment out every reference to UnixFileInfo in FilePath.cs.

I'll think about this and hopefully commit something soon to work around the problem.

WilbertOnGithub commented 12 years ago

I'll look into it as well. Interested in a pull request that at least gives you a branch in which you can compile it under Windows?

alanmcgovern commented 12 years ago

Ah hah, the Mono.Posix.dll dependency is provided by the gtk-sharp installer for windows. The current installer for this is: http://download.mono-project.com/gtk-sharp/gtk-sharp-2.12.10.win32.msi . Installing this is probably the best way of fulfilling the dependency without complicating things too much. I'll update the README with this additional information.

The internals will probably need to be refactored slightly to prevent the library from being loaded when running on windows. It's easy enough to do this so it's the approach I'll take. After the changes, Mono.Posix will be a compile-time only dependency on windows, but on mac and linux it will be loaded and actively used.

dprothero commented 12 years ago

I took a look at this. The only class using this library is Sharpen.FilePath. It has this flag it sets:

static bool RunningOnLinux = !Environment.OSVersion.Platform.ToString ().StartsWith ("Win");

Which I confirmed is False on my Windows 7 x64 machine. Then, all calls to the Mono.Unix namespace (in the Mono.Posix.dll) are wrapped in a if (RunningOnLinux) check.

Is this what you were referring to by "refactored slightly" or were you going to go further and not have the DLL loaded at all?

WilbertOnGithub commented 12 years ago

Maybe we should load the Mono.Posix assembly dynamically if needed (ie. not running on Windows). This way, we could remove the compile time dependency of the Mono.Posix assembly.

alanmcgovern commented 12 years ago

@dprothero , that's the way the code was initially written to separate out the platform specific codepaths. I rewrote it in commit a84093ff0 to completely separate the platform specific code into two separate classes so the Mono.Posix.dll assembly will definitely not be required at runtime for JITing.

@WilbertOnGithub, I'd be happy to accept a pull request doing that. A simpler approach might be to create a Sharpen.Unix assembly which references Mono.Posix.dll and contains only the LinuxFileHelper class. The main Sharpen assembly would then dynamically load Sharpen.Unix and instantiate a LinuxFileHelper if the platform is unix based. It might be a simpler approach than writing lots of reflection based code to use Mono.Posix.dll dynamically. The code in question is all contained in this file: https://github.com/mono/ngit/blob/master/Sharpen/Sharpen/FileHelper.cs

WilbertOnGithub commented 12 years ago

Alan, I like your approach. Looks simpler indeed then dynamically loading Mono.Posix. Will try to work on this tomorrow.