Unfortunately for your situation, ex post facto protections would not apply to your case. This protection only applies to a case where the legislature makes something illegal that you already did and tries to punish you for actions done before the law was enacted. Also, since the Supreme Court first interpreted the ex post facto protection in 1798, it has held consistently that this protection only applies to criminal laws, not civil laws.
In your case, it sounds like you are required to make renovations that require a permit, and that the government is requiring you update your building to more modern codes as part of the process. While this does seem unfair in many circumstances, governments do have the right to impose such burdens on property owners.
In most cases, such upgrade requirements are imposed only if you are making improvements, not repairs to damage. If they a denying the right even to make simple repairs to a building to protect your property, it is conceivable that you have a property rights case, although I would think even that is an uphill fights given court precedents.
If you want to pursue this, you might want to consider contacting the Institute for Justice. This is a property rights / economic liberty foundation that provides free legal assistance in cases where they think they can make a difference. You can find their web site here:
I cannot guarantee they will take the case, but the should be able to evaluate its merits more completely than I can do in this forum.
I hope this helps!
Please keep in mind that information in this forum is for informational purposes only. It is not legal advice and does not constitute creation of an attorney client relationship. Before acting on any such information, you are always advised to consult with an attorney licensed to practice in your jurisdiction who can take the time to review all the facts and laws relevant to your situation.