Clobbered project file

If I’m understanding the question correctly:

In text format every project item is stored in a separate file. So all the code in the App object is in a file called App.xojo_code, windows are stored as .xojo_window. The project file (xxx.xojo_project) only stores a few project settings and a list of the other project elements. Folders are represented as Folders etc

1 Like

Thanks Ian.

Ah … code items are in files with the extension .xojo_code and since I made the mistake of saving the project initially to my Documents folder I have to go and find all those files and back them up as well.

Clearly I need to create a folder for each project and save the project to that folder. I just only had this one project and a couple of small test projects and had not noticed I was making a mess in the root of Documents. I’m used to IDEs that default to creating a separate folder per project and/or solution. It is just something I haven’t thought about in years. If anything, Visual Studio has a tendency to make a folder structure named MyProject\MyProject which is overboard the other way.

Thanks for jogging me so I could see what was right in front of me. I am clearly doing too many things at once these days.

Yes, you certainly need to store text projects in a folder of their own. Binary projects are a single file and can be freely mixed anywhere. The text project format is designed for using with the likes of GitHub, or other version control systems. It has significant advantages, but saving more than one project into the same folder is a recipe for disaster. Names will clash and all hell would break loose. App.xojo_code for example, is rarely called anything else.

1 Like

Do you happen to know if Xojo finds the code files associated with a project file using relative paths? IOW if I copy my project file to a new folder along with the associated code files, will opening the project from that folder have everything properly tied together with the version of the code in that folder?

Boy this is going to be a white knuckle process because it is fragile and error prone, inherently …

Yes, they are project file relative. If you open the .xojo_project file in a text editor you can see the names of all the parts.

1 Like

OK project is properly isolated in its own folder now. Ian / all – what do you think about a feature request on this? To wit:

When creating a new project, when you pick the folder to save the project in, by default, a subfolder of that same name is created and the project file(s) saved within it. Also, if you try to save directly in any of the special folders (Desktop, Documents, Downloads, etc) a warning dialog appears requiring user confirmation with words to the effect “It is strongly recommended not to save a project in a folder that contains files other than Xojo project elements, or which might contain elements of more than one Xojo project”.

Apart from the warning dialog, the only UI change to the IDE would be the default folder creation / selection and a check box (checked by default) in the New Project dialog that is labeled something like “Create a project subfolder”. This is exactly what Visual Studio and other IDEs I’ve worked with do. Actually in general they require you to first pick a project folder and then optionally create a subfolder under it, which can occasionally result in an unintended MyProject\MyProject extra level of nesting but at least you are darned sure it’s out of a busy special folder.

I think what tripped me up here besides being new to the Xojo IDE was that the IDE design doesn’t give the impression of multiple files, it reminds me rather more of the old FoxPro IDE where you have a form file in which is embedded the various method and event code snippets.

It seems wrong to place project artifacts in harm’s way or to not discourage the user from inadvertently doing so, particularly considering that many new users will be student or beginner coders.

As it is, and making matters worse, when you create a new project, it’s an entirely in-memory affair; you don’t commit it to disk until you do a save and by default on my Mac anyway it just wants to put it in Documents. I think it would be better if a save is done immediately upon creation, and the user is forced to make safe decisions at that point. This would be especially helpful to people new to the product.

On the other hand, existing users might see this as “bondage and discipline” but that could be solved with a “Save New Projects Immediately” config item that could be turned off if desired.

Thoughts, anyone?

I dislike IDEs, or any other software, that creates folders for me. I always like to be in control of the folder I store it in.

If it was to warn if you saved (for the first time, or used saved as) and the folder selected already contained additional files. I could live with that, if it allowed you proceed anyway. Sometime you have image files or other resources you need to store.

You would also have only show the warning if XML or Text based project format was being used, binary projects are perfectly safe in a folder along with any other files.

Yes it would not be necessary for binary format, which is probably how it evolved this way in the first place.

Since the project file itself contains a list of all the other files it WOULD be quite simple to warn the user on first save or Save As if any other files with project-specific extensions exist in the target folder, such as .xojo_code, .xojo_menu. It wouldn’t matter if there were image files that way. I could live with that.

I will admit that the MyProject\MyProject thing is easy to do in Visual Studio and has annoyed me in the past, so I like your suggestion.

So now the “ask” is:

IF the project is not saved in binary format, give the user a warning if a project is either saved directly to an OS special folder or to a folder that contains files with xojo project extensions that are not referenced in the project file itself.

Better?

I would think for the likes of GitHub you want a folder with just the source (ie the files the IDE saves) in it.

When I talked of image files I wasn’t talking about images that are part of the project file, but the likes of a source PSD to make those images. I would typically store them in a folder along side the “source”.

I think you could have it as:

If saving as a non-binary format and the folder selected to save into has any files or folders then the IDE should warn you to use a clean empty folder. You should be able to continue anyway if you so desire.

1 Like

OK fair enough and simpler to implement anyway.

I think this would be a nice little improvement.

1 Like

Any special folder is likely to have files or folders already inside it, so it achieves that without saying anything. If you want to make a feature request I would be happy to sign-on.

1 Like

Yep, I agree, checking for special folders would not really add anything to the request if the trigger is just a non-empty target folder.

Appreciate your, and anyone else’s upvote here: https://tracker.xojo.com/xojoinc/xojo/-/issues/71145

1 Like

Done. Already up to 4. You can thumbs up your self if you haven’t already.

I put a thumb on it too.
I would love it if you could also have a way of auto incrementing a save version by enabling it in the preferences. That way if you aren’t using a versioning system at least each save would not step on the last save.

I can’t see why anyone would fail to use a version control system. GitHub is free even for private projects.

Off topic- I take issue with Microsoft having indoctrinated everyone into calling directories folders.

Git is free. GitHub is owned by Microsoft.

I don’t see a problem with that. But GitLab also has a free offering.

FWIW, it is possible to have two text projects share the same folder for the purposes of code sharing if you’re very, very careful about how you name things.

1 Like