简体   繁体   中英

Recover custom code of Umbraco from compiled code

I lost the custom source code of Umbraco (controllers, models) but I have my site running on IIS.

Can I recover the code from the compiled version. If yes, how can I achieve this ?

Any help will be highly appreciated.

Strictly speaking, you won't recover your source code, but as already said you can decompile using a tool like ILSpy or dotPeek to see a code representation of what the .NET binary is doing.

I've had the unfortunate position of having to decompile a website of a new client that had lost its source code due to extenuating circumstances, so here is what I ended up doing to get back to square one.

  1. Set up new solution, with the same project structure as what you had before.
  2. Port the existing binaries over to a test server, and change the config to point databases to a new copy. You'll want the exact same code running on this server, but all external dependencies (db, logging, blob storage, etc) to be separate.
  3. Put your decompiled code on one screen and Visual Studio on another, and go through each file one-by-one until you've got a buildable solution. If the solution contains tests, do these first.
  4. Put your code into source control! Also, make sure that your repository lives elsewhere, whether it's on GitHub/Gitlab or another machine - just as long as it's not in one location.
  5. Once you're in a position where you feel the code works, build your new binaries in Release mode and decompile again. From here, compare your old binaries with the new binaries to see if there are any differences.
  6. If this doesn't exist, build a test framework to ensure that all functionality that you're porting over to your new code will continue to work.
  7. Once you feel you've got an accurate port, deploy. If you've got a blue/green setup, this will work really well to check production issues.

Since you've tagged your post as Umbraco, I assume that this is an Umbraco site. Make sure that you're using the same versions of Umbraco as your existing site, otherwise you'll be in for a world of hurt. Also make sure that all your third-party libraries are configured correctly and any assets/artefacts are backed up. The last thing you want to do when you deploy new code is to wipe out your media library or kill off all of your logs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM