Add-Ons and dependencies to EPiServer core packages

Member since: 2011

Hi,

I'm trying to create simple add-on that contains one block type. I created new project and installed EPiServer.Framework and EPiServer.CMS.Core packages from nuget feed to get required namespaces available for block creation. Everything ok so far.

Now when I build add-on package with NuGet it automatically adds dependencies to EPiServer.Framework and EPiServer.CMS.Core based on package.config it finds from project root. Well I this is ok as those are real dependencies. 

BUT when I try to install my add-on to patched Alloy site I get

Add-on "xxxxxxx" requires "EPiServer.CMS.Core (≥ 7.0.586.16)" to be installed


The problem is that I have that version installed, it is in packages.config of my Alloy site so why do I still get this error? 

#73653 Aug 05, 2013 8:40
  • Member since: 2011

    What you should do is to create package from .nuspec file a not from .csproj file. For instance:

    nuget pack YourProject.nuspec -Properties Configuration="Release"

        

     

    In .nuspec file you are able to control dependencies yourself. Here goes dependencies to EPiServer core packages:

    <dependencies>
      <dependency id="EPiServer" version="[7.0, 8.0)" />
      <dependency id="EPiServer.Shell" version="[7.0, 8.0)" />
    </dependencies>

        

    #73663 Aug 05, 2013 12:14
  • Member since: 2011

    Ok, I did that now, added Dependency to EPiServer.CMS.Core using version="[7.0, 8.0]" but still get complaint about depency:

    Add-On "xxxxx" requires "EPiServer.CMS.Core (≥ 7.0 && ≤ 8.0)" to be installed. How does NuGet/EPiServer Add-On system figure out if dependencies are installed or not?

    #73664 Aug 05, 2013 12:51
  • Member since: 2011

    Can you post your .nuspec file content?

    #73666 Edited, Aug 05, 2013 13:11
  • Member since: 2011
    <?xml version="1.0"?>
    <package>
      <metadata>
        <id>FancyCalculator</id>
        <version>1.0.0</version>
        <authors>Janne Kuusela</authors>
        <owners>Janne Kuusela</owners>
        <description>Fancy calculator block for EPiServer</description>
        <releaseNotes>First release.</releaseNotes>
        <copyright>Copyright 2013</copyright>
        <tags>EPiServerPublicModulePackage</tags>
        <dependencies>
          <dependency id="EPiServer.CMS.Core" version="[7.0,8.0]" />
        </dependencies>
      </metadata>
      <files>
      <file src="..\..\FancyCalculator\bin\FancyCalculator.dll" target="lib/net40" />
      <file src="..\..\FancyCalculator\Views\web.config" target="content/Views" />
      <file src="..\..\FancyCalculator\Views\**\*.cshtml" target="content/Views" />
      <file src="..\..\FancyCalculator\Styles\*.css" target="content/Styles" />
      <file src="..\..\FancyCalculator\Scripts\*.js" target="content/Scripts" />
      </files>
    </package>

        

    #73667 Edited, Aug 05, 2013 13:15
  • Member since: 2011

    Change dependency name to "EPiServer". Great post on this topic: http://dmytroduk.com/techblog/dependencies-and-versioning-for-episerver-add-ons

    #73669 Aug 05, 2013 14:01
  • Member since: 2011

    Ok, this worked but I still didn't understand where this came from. Why I should use ID "EPiServer" for package with ID EPiServer.CMS.Core". The article you linked said "use package ID instead of assembly name".

    #73712 Aug 06, 2013 16:25
  • Member since: 2011

    Well... :) Haven't dig into this so far, but at least you can see some of the built-in packages, like CMS or Framework if you click on "Dependencies" tab for some of the packages ("EPiServer Edit UI" for instance).

    #73717 Aug 06, 2013 23:24
  • Member since: 2008

    I think that blog post contains the folowing recommendations:

    • Use the add-on package ID when defining a dependency on that add-on.
    • Use the corresponding assembly name when defining a prerequisite.

    There are 2 kind of dependencies that can be specified for an add-on.

    You can define dependency on other add-on. In this case dependencies should also be installed when installing dependents. Use add-on package ID to specify dependency on add-ons.

    Example: EPiServer Edit UI (add-on package ID: CMS) add-on depends on EPiServer UI Platform add-on (add-on package ID: Shell). Note that EPiServer UI Platform is updated automatically when you update EPiServer Edit UI add-on.

    Another case is a prerequisite; it is a dependency on a component that should be presented on website to be able to install your add-on. Usually this component is not an add-on and cannot be installed by Add-ons system.

    Example from my blog post: let's say you develop some add-on for EPiServer Commerce. You can define Commerce as a prerequisite and specify the name of some Commerce core assmblies, like EPiServer.Business.Commerce. As a result your add-on will be available only for websites where Commerce is deployed.

    Assembly name is used as prerequisite identifier in order to be able to require any backend component. In this case it doesn't matter whether this component was installed in Visual Studio as part of some nuget package or the assembly was referenced directly.

    I can see some confusion with add-on packages and packages from the EPiServer nuget feed. I would say that components from EPiServer Nuget feed in most cases can be considered as prerequisites.

    Does it sound reasonable?

    #74076 Aug 20, 2013 13:37
  • Member since: 2003

    If you still want to use

    nuget pack [PROJECT-FILE] -Properties Configuration="Release" (and not nuget pack [NUSPEC-FILE])

    and you want to avoid the added dependency to EPiServer.CMS.Core you can add the "developmentDependency" attribute to your package file (the package file in the Add-On project)

    E.g:

    <?xml version="1.0" encoding="utf-8"?>
    <packages>
            <package id="Castle.Core" version="3.2.0" targetFramework="net45" developmentDependency="true" />
            <package id="Castle.Windsor" version="3.2.0" targetFramework="net45" developmentDependency="true" />
            <package id="EPiServer.CMS.Core" version="7.14.2" targetFramework="net45" developmentDependency="true" />
            <package id="EPiServer.Framework" version="7.14.2" targetFramework="net45" developmentDependency="true" />
            <package id="log4net" version="1.2.10" targetFramework="net45" developmentDependency="true" />
            <package id="Microsoft.AspNet.Mvc" version="4.0.20710.0" targetFramework="net45" developmentDependency="true" />
            <package id="Microsoft.AspNet.Razor" version="2.0.20710.0" targetFramework="net45" developmentDependency="true" />
            <package id="Microsoft.AspNet.WebPages" version="2.0.20710.0" targetFramework="net45" developmentDependency="true" />
            <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" developmentDependency="true" />
            <package id="Newtonsoft.Json" version="5.0.8" targetFramework="net45" developmentDependency="true" />
            <package id="structuremap" version="2.6.4.1" targetFramework="net45" developmentDependency="true" />
    </packages>

    This means that the packages in the project are only there for development and will not be added as dependencies.

    Regards Hans

    #112111 Oct 22, 2014 22:01