Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sotiris Filippidis 286 posts 1501 karma points
    Sep 07, 2022 @ 14:31
    Sotiris Filippidis
    1

    Nuget Package with AutomaticMigrationPlan failing to get embedded package.xml file

    I recently tried to create a Nuget package which had the sole purpose of creating some doctypes on the target installation. For testing purposes, I created a "dummy" doctype without any dependencies in an existing Umbraco setup, got the package.xml file and went on to create an automatic package migration as described here: https://our.umbraco.com/Documentation/Extending/Packages/Creating-a-Package/

    When I try to install the package on a new Umbraco site, though, I get the message "Missing embedded files for planType:" - I made sure I had included the package.xml file as an embedded resource, and also made a zip and added that as well. I can't make it work.

    I even switched to a custom migration - this time it was set up, but during running the new Umbraco site I got an "object reference not set to an instance of an object". Again, it seemed like it couldn't find the embedded resource.

    What am I missing? I have seen others doing the same (searched for code on GitHub) in exactly the same way. Must be something extremely silly!

  • Sotiris Filippidis 286 posts 1501 karma points
    Sep 08, 2022 @ 21:05
    Sotiris Filippidis
    0

    Answering my own question here since I've probably spotted what is wrong:

    I was trying to set up the package together with installing a new umbraco instance, i.e.

    dotnet new umbraco -n somename -p mypackageid
    

    But this would cause issues. Reason unknown.

    When I set up the package in a private feed and set it up on an existing Umbraco installation from the command line (dotnet add package) everything went smoothly.

    So setting up a package together with an Umbraco installation probably has some issues when the package has migrations? Can't find any other explanation.

  • Emma Garland 41 posts 123 karma points MVP 7x c-trib
    May 23, 2023 @ 09:47
    Emma Garland
    0

    Hi,

    I just came across the same issue when trying to do:

    dotnet new umbraco -n ProjectXYZ -p PRPackageXYZ

    I debugged it and it seems like the issue (for me, anyway) is that it is expecting a package.zip, but I only had a package.xml file because I didn't have any content or media etc, just a doctype and composition.

    I got around it by:

    1. Changing it to a package.zip in the package project
    2. Making that the embedded resource
    3. Repacking the package

    The issue seems to be in ..\Umbraco.Core\Packaging\PackageMigrationResource.cs line 31 GetEmbeddedPackageZipStream method.

    It turns out there is an existing issue that I think covers this at https://github.com/umbraco/Umbraco-CMS/issues/12125

    Thanks for sharing the post

    Emma

  • Gregor Tušar 7 posts 78 karma points
    Jun 20, 2023 @ 05:16
    Gregor Tušar
    0

    I was able to solve it with only changing the build action of the package.xml. I set it to Embedded resource and I didn't get the exception anymore.

      <ItemGroup>
        <EmbeddedResource Include="Migrations\package.xml">
          <CopyToOutputDirectory>Always</CopyToOutputDirectory>
        </EmbeddedResource>
      </ItemGroup>
    
Please Sign in or register to post replies

Write your reply to:

Draft