November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Erik, the dojo part hasn't changed. It's just that we no longer have web.config nad you need to add your custom module.
Example of adding a protected module:
services.Configure<ProtectedModuleOptions>(
pm =>
{
if (!pm.Items.Any(i =>
i.Name.Equals("episerver-labs-content-manager", System.StringComparison.OrdinalIgnoreCase)))
{
pm.Items.Add(new ModuleDetails() { Name = "episerver-labs-content-manager" });
}
});
module.config format has not changed significantly (there are a few additional properties like the type of json serializer type or default authorization)
Thanks Bartosz! How to register the module was the missing piece I needed. This page helped me https://world.optimizely.com/documentation/developer-guides/CMS/user-interface/configuring-shell-modules/
The dojo add-on is working fine in CMS 12. But I have trouble with packing the add-on in a nuget.
Apparently content files are handled a bit differently in .net5/core projects. They are not copied to the project directory. They are included in the project, but the files reside in the nuget package location.
It seems that the dojo module requires the files to physically be in the project directory (modules/_protected/mymodule/mymodule.zip), otherwise the js-files are not found.
A hacky way of moving the files to the project directory is to use msbuild to copy the files when the project is built (https://stackoverflow.com/a/64167211/1249390), but I can see several problems with that approach.
There must be a better way. Either to have the dojo module work with referenced files, or some clever nuget/nuspec way of doing it.
How are the other nugets containing modules packed?
What we are doing is to specify in the nuspec file to add the zip file as a content file, like:
<contentFiles>
<files include="any/any/modules/_protected/EPiServer.Cms.UI.Admin/EPiServer.Cms.UI.Admin.zip" buildAction="None" copyToOutput="true" />
</contentFiles>
The n when you run 'dotnet' publish it will put the zip files correctly (that is under folder /modules/_protected/ relative the root of your application.
We also have this hack with a target that copies the zip files from output to the root of the application:
CopyZipFiles.targets
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<ItemGroup>
<SourceScripts Include="$(MSBuildThisFileDirectory)..\..\contentFiles\any\any\modules\_protected\**\*.zip"/>
</ItemGroup>
<Target Name="CopyZipFiles" BeforeTargets="Build">
<Copy
SourceFiles="@(SourceScripts)"
DestinationFolder="$(MSBuildProjectDirectory)\modules\_protected\%(RecursiveDir)"
/>
</Target>
</Project>
Then in the nuspec file:
<contentFiles>
<files include="any/any/modules/_protected/EPiServer.Cms.TinyMce/EPiServer.Cms.TinyMce.zip" buildAction="None" copyToOutput="true" />
</contentFiles>
And also in the nuspec file:
<files>
<file src="src\EPiServer.Cms.TinyMce\license.txt" target="" />
<file src="src\EPiServer.Cms.TinyMce\bin\$configuration$\EPiServer.Cms.TinyMce.dll" target="lib\net5.0" />
<file src="src\EPiServer.Cms.TinyMce\bin\$configuration$\EPiServer.Cms.TinyMce.pdb" target="lib\net5.0" />
<file src="out\EPiServer.Cms.TinyMce.zip" target="contentFiles\any\any\modules\_protected\EPiServer.Cms.TinyMce" />
<file src="build\CopyZipFiles.targets" target="build\net5.0\Episerver.Cms.TinyMce.targets" />
</files>
Thanks!
If you are doing it, then I feel confident in doing it myself 😊.
I have spent way too much time on this... but this approach seems to be what people are doing.
My main issue is that the content file is not removed from the project directory when you uninstall the nuget.
Wrote about this some time ago - https://blog.tech-fellow.net/2021/09/03/how-to-pack-your-shell-module-for-optimizely-content-cloud/
Can someone please point me in the right direction on how to create an add-on (dojo module) for CMS 12?
This documentaion is not yet updated for CMS 12: https://world.optimizely.com/documentation/developer-guides/CMS/add-ons/