How to pack a nuget addon for #Episerver, Example FotoWare Plugin

Demo how we are working with the FotoWare AddOn and automatically nuget package it from Visual Studio.

Published 20th august 2019
Episerver CMS version 11.15 and Commerce > 11

Had the opportunity to work on this addon together with Epinova, which is publically available for all FotoWare customer in the new Market Place https://marketplace.episerver.com/apps/fotoware/fotoware-connector/

About Fotoware

FotoWare is an enterprise digital asset management (DAM) system for your image, video, audio, graphics and documents archives. Founded in 1997, it was one of the first in the world to offer a DAM system. In the space of 20 years, has become a world-leading provider of DAM with more than 200,000 users and 4,000 customers in a wide range of industries worldwide.

That was the selling part 😉

… aaaand the link www.fotoware.com

About the addon/plugin

The addon integrates the Episerver Media Property and Rich Text Editor with FotoWare DAM, available from Episerver Nuget Feed. Both for CMS and Commerce.

 Example Rich Text Editor (TinyMce):

Example Episerver Media Property CMS:

Example Episerver Media Property Commerce Asset List:

How To package a zip with build tasks in visual studio

Episerver has this cool feature where you can install a zip under modules/_protected and it unzips and loads the modules/route the files.

End product files looks like this (after installation):

Nuget package content example:

But in working project, it is unpacked:

We do use an Alloy template as host web project, also the client side files resides in the host project, why? easier to work/debug and change while runing the application.

Solution overview:

Using Build Tasks

Create a new files named whatever “buildtasks/makeapackage.targets”
throw it in your csproj:

<Import Project=“$(MSBuildToolsPath)\buildtasks\makeapackage.targets” />

Set parameters

These will be used in the targets files (SolutionDir, NugetExe, TmpOutDir, NuspecFile)

The main point of doing all this is to build up your package structure in “TmpOutDir” before building the nuget package

Example:

Versioning

We will be using the versioning in AssemblyInfo.cs

so in makeapackage.targets do a “function” GetVersion:

Using the GetVersion

Updating modules.config with version

zipping files

Using the ZipDirectory

MakeDir

RemoveDir

Moving/Copying a bunch of files

Copying all clientside files at once

Adding and removing stuff in web.config

By applying XmlTransforms in web.config.install.xdt and web.config.uninstall.xdt, it can be accomplished.

Renaming files

Copy the readme.md and change name to readme.txt

Using .nuspec to build the nuget package

Executing .nuspec:

Example .nuspec

Conclutions

  • Build Task are used to build up a folder structure and zip files, you can use code and set parameters.
  • Nuspec is used to build a nuget package, including files from the Build tasks.
  • Versioning is working automatically.
  • Store your Clientside files in host project, easiest way to work, debug at runtime.

Find the complete code here: [Gist Link]

Further reading:

About the author

Luc Gosso
– Independent Senior Web Developer
working with Azure and Episerver

Twitter: @LucGosso
LinkedIn: linkedin.com/in/luc-gosso/
Github: github.com/lucgosso

Like it? please up vote
1