Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Adam 3 posts 73 karma points
    Jun 09, 2022 @ 14:47
    Adam
    0

    New Nuget and file removal on uninstall

    Hi,

    As of recent, it would appear that Powershell scripts are no longer used to populate and remove files on Nuget package installation/ uninstallation. It would appear that it is all managed using MsBuild. I am creating a package for Umbraco and have successful migrations on installation. The files are populated on a Build target like so:

    <Target Name="CopyMyAssets" BeforeTargets="Build">
        <ItemGroup>
            <MyAssets Include="$(MyAssetsPath)" />
        </ItemGroup>
        <Copy SourceFiles="@(MyAssets)" DestinationFiles="@(MyAssets->'$(MSBuildProjectDirectory)\App_Plugins\MyPlugin\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
    </Target>
    

    And I also see the method to remove files with clean using:

    <Target Name="ClearMyAssets" BeforeTargets="Clean">
        <ItemGroup>
            <MyPluginDir Include="$(MSBuildProjectDirectory)\App_Plugins\MyPlugin\" />
        </ItemGroup>
        <RemoveDir Directories="@(MyPluginDir)"  />
    </Target>
    

    My question is, on package uninstall through the Nuget package manager, how do I ensure that these files are removed during the uninstall process? The user may not remember to clean before uninstalling, which will leave these orphaned files, and with no package to tell the project what to do, they will no longer be removed on subsequent cleans. Do I need to somehow invoke a project clean on uninstallation, or is there a way of scripting file removal? Any help would be appreciated.

    Thanks, Adam

Please Sign in or register to post replies

Write your reply to:

Draft