To begin with, I would like to ellaborate on what I think defines an Episerver AddOn:
- It is a nuget package that depends on some Episerver functionality
- It is marked with proper Episerver tags (EPiServerModulePackage & EPiServerPublicModulePackage)
- It has specific structure that Episerver installation expects
- It is useful for X number of Episerver CMS and/or Commerce instances
While this seem clear, still, an AddOn shouldn't be mixed with a simple nuget package that adds the files to solution (talking mostly about no 3.). You can still, ofc, create a nuget package that add the files to the solution. In some cases, this is desirable: when you don't want to type in same things over and over again, but you still need to change the implementation a lot. I have this little admin tool, where I literaly have a comment:
// this is the place where you do "something" with // each of the content items you are iterating through
If I wanted to make it an add-on, either I could remove this and leave the "something" part to a ContentInitializableModule or I would need to have an idea what useful thing this package could do instead (focusing on no 4.).
As opposed to this example, Grzegorz's Deleting a single file from trash is a splendid example of an Add-On - everybody needs this! (Just check out the comments :))
What I needed to do is the following:
- Renamed AddOn.Initial to SingleContentItemTrasher
- Grabbed the files and copied them in a structure that felt logical to me, see SingleContentItemTrasher github
- Changed alloy.extendedWastebasket to singleContentItemTrasher.extendedWastebasket (just because it felt right)
- Commented out the stylesheet import from TrashWidget.js, since it can be loaded through required resources.
- Changed the "App" (_getRestPath) in storeInitializer to SingleFileTrashed (it should match the assembly).
- modules.config looks a bit different, including the CSS loading and the paths are different.
- Added proper episerver dependencies to nuspec file.
- Added ClientResources to the package by adding this to Packager/Main.targets file:
<ItemGroup> <ClientResources Include="$(SolutionDir)\ClientResources\**\*" /> </ItemGroup> <Copy SourceFiles="@(ClientResources)" DestinationFiles="@(ClientResources -> '$(TmpOutDir)\content\$(Version)\ClientResources\%(RecursiveDir)%(Filename)%(Extension)')"/>
The speed of doing this amazed me: it took me less than 2h (including testing on two different Episerver versions), even though I haven't written the code myself!
UPDATE: I have also now renamed everything now to SingleContentItemTrasher, since it does not delete files but Episerver content items. I have also fixed the following issue.