8000 Add IUninstallable interface to enable custom module uninstallation logic by Copilot · Pull Request #6559 · dnnsoftware/Dnn.Platform · GitHub
[go: up one dir, main page]

Skip to content

Add IUninstallable interface to enable custom module uninstallation logic #6559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

Copilot
Copy link
@Copilot Copilot AI commented May 23, 2025

Overview

This PR adds a new IUninstallable interface that module developers can implement in their business controller classes to run custom code during module uninstallation. This is similar to how the existing IUpgradeable interface allows custom code to run during installation or upgrade.

Problem

Previously, there was no official way for module developers to run custom uninstall code. When uninstalling a module that had created content outside its standard file structure (e.g., custom folders, cache files), the only cleanup option was an uninstall SQL script. This left potentially orphaned files and folders in the file system.

Solution

The implementation includes:

  1. A new IUninstallable interface with a single method:
string UninstallModule(bool deleteFiles);
  1. The deleteFiles parameter is passed in from the uninstall UI screen, allowing module developers to know if the user requested file deletion.

  2. Modified the module uninstallation process to:

    • Check if a module's business controller implements IUninstallable
    • Call the UninstallModule method if it exists
    • Pass along the "Delete Files" flag from the UI
    • Log any success messages or errors

Example Usage

Module developers can implement the interface like this:

public class MyModuleController : IUpgradeable, IUninstallable
{
    // Existing upgrade method
    public string UpgradeModule(string version)
    {
        // Upgrade logic
        return "Upgraded successfully";
    }

    // New uninstall method
    public string UninstallModule(bool deleteFiles)
    {
        // Clean up custom folders or files
        if (deleteFiles)
        {
            // De
8000
lete media cache or other custom files
            DeleteCustomFiles();
        }
        return "Uninstalled successfully";
    }
}

Fixes #2160.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: mitchelsellers <5659113+mitchelsellers@users.noreply.github.com>
@bdukes
Copy link
Contributor
bdukes commented May 23, 2025

popcorn GIF

@Copilot Copilot AI changed the title [WIP] Add an uninstall Interface to run custom module code Add IUninstallable interface to enable custom module uninstallation logic May 23, 2025
@Copilot Copilot AI requested a review from mitchelsellers May 23, 2025 20:01
Copilot finished work on behalf of mitchelsellers May 23, 2025 20:01
@valadas
Copy link
Contributor
valadas commented May 23, 2025

Hey, that was for me to play with...

MichaelJacksonComendoPicocaGIF

@mitchelsellers mitchelsellers marked this pull request as ready for review May 23, 2025 20:06
@mitchelsellers
Copy link
Contributor

We may want to add custom instructions to help, I can look at this a bit this weekend. I did blog about this a bit as well

@valadas
Copy link
Contributor
valadas commented May 23, 2025

@copilot we have a couple of build issues here:

image

@valadas
Copy link
Contributor
valadas commented May 23, 2025

@mitchelsellers looks like copilot is not listening to my mentions...

@valadas
Copy link
Contributor
valadas commented Jun 2, 2025

This was just a test of copilot agent mode, I think I'll submit a more proper PR for this later...

@valadas valadas closed this Jun 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully me 410B rging this pull request may close these issues.

Add an uninstall Interface to run custom module code
4 participants
0