I am creating a package for use in dotnet core web applications.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 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 have a removal method with a clean target:
<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? I have read the MsBuild documentation and I see no uninstall target or replacement for the old uninstall.ps1 scripts that used to be used. Any help would be appreciated.