Is It Possible To Downgrade A Mendix Project File?

Vinicius Strugata Ambrosio
7 min readAug 24, 2024

--

Mendix has a hectic schedule of new Studio Pro releases. Frequently, more than two new versions of Studio Pro are released every month, with new features and bug fixes. While it is recommended to keep the Mendix project file (MPR) always up to date with the latest version, sometimes you regret this movement. In this case, what are the available options?

Use the Revert All Changes menu or Rename the *.mpr.bak file

This is by far the easiest solution. If you identify the issue immediately after upgrading the MPR file using the latest release of Studio Pro (for example, caused by incompatible modules), and if you didn’t commit your code, follow the procedure below:

[1] Use the menu Version Control Revert All changes… to revert the changes to the previous state. Click Yes to confirm this action:

[2] Studio Pro shows a message confirming that your project was reverted and that it will be closed.

[3] Reopen your project using the original Studio Pro version and continue your work. This only works if your project is under Git version control.

Alternatively, if you haven’t saved your updated project yet, you can just rename the file my-project.mpr.bak to my-project.mpr and reopen the project using the previous Studio Pro version. Previously, you must also delete the updated and problematic my-project.mpr, or better rename it to something like my-project.mpr.issue.

Use your Version Control Software

Considering that the issue with the newest release of Studio Pro was identified a few commits after the upgrade, then a difficult decision must be made: revert your MPR project to the previous Studio Pro version (and potentially lose your changes).

In this scenario, GIT Version Control Software can help. Below is the procedure using PowerShell + GIT (this cannot be done inside Studio Pro):

[0] Firstly, use Windows Explorer to copy your problematic project’s entire folder structure to another place. We will use this MPR project as a basis to redo all the lost features in the recovered MPR project.

[1] You should identify the revision number of the commit to which you sent the problematic updated MPR to Version Control in the GIT history. Use the menu item TeamServer in your Sprintr, or the command line:

Team Server showing the Revision List of your app
Git Log with the latest commits
git log --oneline --graph

[2] Use the command below to revert your project to the version where your code was working (in this case, we are reverting from HEAD to c48f921:

git revert -n c48f921..HEAD

[3] Run the mx.exe tool to verify that the MPR was indeed downgraded:

mx.exe show-version .\mx_medium_app.mpr
10.6.13.43489

[4] Run the command git clean to clean up your project:

git clean -fxd

[5] Once you finish this step, you must commit the MPR project. This should be done via the command line since Studio Pro will show an error if you try to open the downgraded MPR now:

git commit -m "BREAKING CHANGE: Downgrade to 10.6.13"

[6] Now the tedious part. Open the downgraded MPR with the previous Studio Pro and also the MPR copied in step [0] with the newest Studio Pro and try to figure out the changes done in the newest version and redo such changes in the previous version. Unfortunately neither the Crtl+C/Ctrl+V nor the Export document to file…/Import document from file… from newest/previous works.

[7] Finally, you can use the Version Control Commit & Push menu in your Studio to confirm the changes to the Team Server

[8] The final history log will resemble like below:

Observe that the project was upgraded and then downgraded

A slight variation using Branches

A similar result can be achieved using branches. Here is the procedure:

[1] From the Studio Pro UI (the one on which your MPR project was upgraded), use the menu Version Control Manage Branche Lines… to create a new branch using as a starting point the release version where your code was working. Do not download and switch to the newly created branch when asked!

[2] You can keep the newest Studio Pro version open. Now let’s open the oldest Studio Pro and in the Welcome dialog box select the MPR project. After this, click on the button Chose Branch Line and select the branch newly created.

[3] Click on the button Check Out Branch Line. Then select the destination folder for this branch:

[4] Now you can redo all the features you’ve implemented in the newest Studio Pro in this branch. Having two screens is a plus in this activity.

[5] When done, you must abandon the branch which has the upgrading problem. In our case, this was the main branch. It seems weird to delete or abandon the main branch… I’ve tried to merge the branch-revert10.6.13 with the main and resolve any conflicts, but Studio Pro ended up upgrading again the project to 10.12.3. Maybe if I had done this via command line the result would have been different. To be investigated… A workaround solution for this would replace all files from the main branch (except the .git folder), with the correspondent files in branch-revert10.6.13 and then commit/push.

[6] Assuming that you can work on the downgraded branch, in theory, the solution is done. This case highlights the importance of using a branch development strategy.

Can I Use the mx command line tool?

The mx command line tool has many interesting options. One of them is the convert subcommand. Let’s use the command below to see the available options:

mx.exe convert --help

Sounds good, huh!? However, the Mendix documentation states that it is not possible to downgrade ☹️ using this command:

Even so, we’ll try, just in case…

mx.exe convert --in-place D:\work\mx_medium_app

As anticipated by the documentation, this procedure failed!

Use the MPR Tool

Our final attempt is to use the MPR tool. The MPR tool is a kind of project inspector, allowing us to see an X-ray of our project:

This tool is located in the same folder as mx.exe and studiopro.exe, that is, ..\Mendix\10.6.13.43489\modeler.

But how can we change the version number? Below is the procedure:

[1] Execute the MPR tool and open the problematic upgraded MPR project.

[2] Use the menu option Tools Edit metadata to see the project version number:

[3] Change the Product version and Build version to the number corresponding to the Studio Pro version you need to downgrade. In our case, 10.6.13.43489 , and click OK.

[4] Use the mx tool to verify that the project was indeed downgraded:

[5] Run the command git clean to clean up your project:

git clean -fxd

[6] Now you can try to open the project in the desired Studio Pro Version. A confirmation message will appear:

If you happen to have incompatible modules, you’ll get a lot of error messages. In this case, you can downgrade each module using Marketplace and replace the wrong module with the latest version available for the downgraded MPR project version.

Using this risky and unofficial procedure, I was able to downgrade a project from 9.24.23 to 9.20.0. And as a bonus, there’s a chance you won’t lose any work you’ve done after the update.

Recommendations & Conclusions

  • Always, always, always use the GIT Version Control Software to protect, organize, and track your project changes. In cases like this, you realize how important is to have all the history of changes done in your project, and that you can go “back in time” if needed.
  • Prefer to use the MTS/LTS versions of Studio Pro and try to follow the updates/fixes of the latest version monthly.
  • In case of an update, do this in a separate branch just to test if the new version is OK. Merge to the dev branch after QA approval.
  • The Git repository management inside Studio Pro covers only the basics. If you really need to handle the advanced features Git offers, you must use the command line or tools like Tortoise Git.

References

--

--

Vinicius Strugata Ambrosio
Vinicius Strugata Ambrosio

Written by Vinicius Strugata Ambrosio

Mendix Developer, Python Enthusiast and Flutter/Dart Learner — https://www.linkedin.com/in/vstram/

No responses yet