Re: Packing a C# project.
"Neil Munro" <[email protected]>
| Newsgroups | gmane.comp.autopackage.devel |
|---|---|
| Message-ID | <[email protected]> |
2008/6/4 Isak Savo <[email protected]>: > On Wed, Jun 4, 2008 at 10:33 PM, Neil Munro <[email protected]> wrote: > > > > 2008/6/4 Isak Savo <[email protected]>: > >> > >> On Wed, Jun 4, 2008 at 9:46 PM, Neil Munro <[email protected]> wrote: > >> > > >> > >> Just a reminder: Binreloc solves the problem when the software is > >> *INSTALLED* on the target system. It does make it a bit trickier for > >> us poor developers but IMO that's a fair price to pay. > > > > It's why I want to learn autopackage, tis easier for end users, I'm just > > trying to work out the quirks for developing with it. So do I just move > > files and folders around until it works? > > You have two options: > 1) Don't use binreloc when you are running from your source directory > (i.e. when you are running from MonoDevelop) > 2) Use "custom commands" in monodevelop to copy everything to the > directory layout that is equal to the one it would be on the user's > system. > > For 1) you can either do it by using #if statements (which are > pre-processor macros): > > > #if DEBUG > string myImageFile = "../../images/image.png" // Assuming the image > is in the main source directory > #else > string myImageFile = Path.Combine(BinReloc.DataDir, > "yourprogram/images/image.png"); // Assuming image is installed in > $PREFIX/share/yourprogram/images/image.png > #endif > > Image myImage = new Image(myImageFile); > //... and so on > > If using this method, you would just compile in Debug mode (there's a > combo box in monodevleop to change) when debugging, and then compile > in release mode when you make a release (when you make your > autopackage). Monodevelop will then use the first line when in Debug > mode, and the second line when in Release mode. > > You could also do it without #if-statements, and rely on normal > if-statements that are checked when the program is running (instead of > #if, which is checked when compiling): > > if (File.Exist("../../images/image.png")) > myImageFile = "../../images/image.png"; > else > myImageFile = Path.Combine(Binreloc.DataDir ... //etc... > > That way, it doesn't matter which compile mode you build the program > in, it'll always just work. I like this method. Looks like a lot of work initially, but I don't mind too much. > > > For 2), you'd have to setup MonoDevelop to actually copy everything to > a location on your disk and run it from there. This method would > require you to write some shell scripts. You can configure custom > commands by right clicking on your project file in monodevelop, select > properties and then navigate to > Configurations -> Debug (Active) -> Custom Commands. > So what are the custom commands I need to set up, what do I need to copy where? Could I not have the folder in ../share and a sym-link that BinReloc looks in? I have set the binary output directory to be Debug and data should be in share/ below that and I would like to have the binary in bin/ so what script magic do I need? > > (I'm not sure about the names, I'm running monodevelop in swedish) > > The benefit of doing 2) is that you will always test your code the way > it would run on the users system. > > > I set the output directory in MD to be /whatever/bin/Debug/bin with the > > intention of /whatever/bin/Debug/share /whatever/bin/Debug/etc being > there > > as well, with the clear separation of binarys, data files and config > files. > > My problem is that this set up does not work. It is in fact looking for > > /whatever/bin/share I don't understand why this is. > > > > Unless it's working relative to the current working directory I imagine a > > work around Path.Combine( BinReloc.DataDir, "../file" ) would work, but > > that's not really the point is it? > > No :) > > > Could this all just be a quirk of the .Net framework, MonoDevelop, me or > a > > combination of all of the above? > > It's just that it's a bit hard to get everything to play nice > together. Use one of the solutions I highlighted above (1 or 2) and > you should be fine... > > > In which case, I am half tempted to say the files I am working with > should be in $PREFIX/etc since the files I am > > working with are probably best described as configuration files. > > I was a bit unclear, "/etc" is mostly used for system configuration > files. Normal applications rarely place anything there, mostly servers > and fundamental system tools do that. (There are a few exceptions to > this rule though, for example programs that use the GConf > configuration system, like the GNOME apps, they put their default > configuration values there.. but that's a completely different story.. > let's not go there right now :) > > Configuration files which are ment to be changed by the user should be > stored in the users home directory. Typically, you would store them in > ~/.config/yourprogram or something like that (either just one file, or > a directory with multiple files depending on how much configuration > files you need.. probably just one!) > > Anything else should most likely go to $prefix/share/yourprogram. Got ya, only really use bin and share, right? > > > -Isak > > --------------------------------------------------------------------- > To unsubscribe, e-mail: autopackage-dev-unsubscribe-OfajU3CKLf1/[email protected] > For additional commands, e-mail: autopackage-dev-help-OfajU3CKLf1/[email protected] > >