Own package is not listed in installed packages li...
# help-with-umbraco
b
I have created an Umbraco package. Published this to a nuGet feed (Azure Artifacts). I can see the package in Visual Studio and I'm able to install it. So far so good. However, when I login into the Umbraco backoffice > Packages > installed, there is no plugin listed there. What do I need to do to get my own created package showing up in that list?
d
Hi there! A package is identified by a package manifest. Does your package have a package manifest?
You can read more about package manifest in the Umbraco documentation: https://docs.umbraco.com/umbraco-cms/extending/property-editors/package-manifest
b
Hi! Yes, it does have a package.manifest file. The current structure I have: UmbracoPackages.sln - BackofficeCustom.csproj -- App_Plugins --- BackofficeCustom ---- custom.css ---- package.manifest -- buildTransitive --- BackofficeCustom.targets - nuget.config My package.manifest file: { "version": "1.0.0", "id": "BackofficeCustom", "name": "BackofficeCustom", "allowPackageTelemetry": true, "css": [ "~/App_Plugins/BackofficeCustom/custom.css" ] } I've pack the project into a 'BackofficeCustom.1.0.0.nupkg' file (by DevOps) and push it into AzureArtifacts. Then in my Umbraco solution, I used the NuGet package manager, and installed my plugin. Somehow it just isn't listed in the list of Umbraco installed packages.
d
I see, looks good to me. And you have confirmed that this package manifest is included in the nupkg file and shows up in the application where you installed it?
b
Hmm.. good question. I've created the nupkg file, pushed it to Azure Artifacts. Then used Visual Studio NuGetpackage manager to install the package (added package source our Azure Artifact feed). Installation seems to succeed. I can see it as installed inside visual studio. When I start Umbraco and go to the backoffice > packages > installed, it just isn't showing up. Have I confirmed the manifest is inside the nupkg file: no. How can I check that? I noticed that the package.manifest was set to 'Copy to output directory: do not copy'. Just changed it to 'Copy always'. Still need to test that out if it makes a difference. Or... are only packages listed there that came from the Umbraco marketplace? Or are own created packages also listed here?
update: test when I set the manifest to 'Copy Always' gives the same result: the backoffice keeps saying; No packages have been installed.
d
A .nupkg file is just a zip file with a different extension, so you can simply "unzip" it locally and check the contents. Alternatively (and recommended), you can install the nuget package explorer and explore the files through there: https://apps.microsoft.com/detail/9WZDNCRDMDM3?hl=en-US&gl=US I opened the "godmode" plugin in the package explorer and you can see in the App_Plugins folder that the package indeed contains a package.manifest file: https://cdn.discordapp.com/attachments/1189559943209177170/1189853207254544435/image.png?ex=659fac27&is=658d3727&hm=4b35af17984b2cec7d5f7ef63b81eb07fef745328043eb75b2adbc84ef971c4c&
Also after installing godmode into my project and running a build, I find the package.manifest in my project under the App_Plugins folder: https://cdn.discordapp.com/attachments/1189559943209177170/1189853862744559646/image.png?ex=659facc3&is=658d37c3&hm=c229e683b16512e43c642dd432880d528c508a053aff7b842202c79ddd910e1f&
h
Did you use the Umbraco package template to create your package? If not perhaps something is not quite right with your package setup.
b
When I open my local builded nupkg file with NuGet Package Explorer I can see the manifest. I also see health problems: I'm not sure if that is part of my original problem? After instelling I do not see files copied into the App_Plugins folder of my Umbraco installation... so I guess that indicates a problem? https://cdn.discordapp.com/attachments/1189559943209177170/1189879038341304411/image.png?ex=659fc435&is=658d4f35&hm=5c5f562c4f4095b9d4039804d2dc789c254f0dbc676c2104f584ce840a3ade3b&
I tried to follow https://docs.umbraco.com/umbraco-cms/extending/packages/creating-a-package at the beginning. So I used the command: dotnet new umbracopackage --name BackofficeCustom to get started.
h
"when I set the manifest to 'Copy Always' " That should not be necessary as the Umbraco package template takes care of copying the App_Plugins folder
b
That copy action is listed in the .targets file if I'm correct? As I do not see any files in App_plugins after I installed the package, there might be a malformed path in this .target file perhaps?
h
what does your targets file look like? It should be something like
Copy code
json
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <UmbracoCommunityPollsContentFilesPath>$(MSBuildThisFileDirectory)..\App_Plugins\Polls\**\*.*</UmbracoCommunityPollsContentFilesPath>
  </PropertyGroup>

  <Target Name="CopyUmbracoCommunityPollsAssets" BeforeTargets="Build">
    <ItemGroup>
      <UmbracoCommunityPollsContentFiles Include="$(UmbracoCommunityPollsContentFilesPath)" />
    </ItemGroup>
    <Message Text="Copying Umbraco.Community.Polls files: $(UmbracoCommunityPollsContentFilesPath) - #@(UmbracoCommunityPollsContentFiles->Count()) files" Importance="high" />
    <Copy SourceFiles="@(UmbracoCommunityPollsContentFiles)" DestinationFiles="@(UmbracoCommunityPollsContentFiles->'$(MSBuildProjectDirectory)\App_Plugins\Polls\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
  </Target>

  <Target Name="ClearUmbracoCommunityPollsAssets" BeforeTargets="Clean">
    <ItemGroup>
      <UmbracoCommunityPollsDir Include="$(MSBuildProjectDirectory)\App_Plugins\Polls\" />
    </ItemGroup>
    <Message Text="Clear old Umbraco.Community.Polls data" Importance="high" />
    <RemoveDir Directories="@(UmbracoCommunityPollsDir)" />
  </Target>
</Project>
b
Hmm yea, it kinds looks like that:
Copy code
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <BackofficeCustomContentFilesPath>$(MSBuildThisFileDirectory)..\App_Plugins\BackofficeCustom\**\*.*</BackofficeCustomContentFilesPath>
  </PropertyGroup>

  <Target Name="CopyBackofficeCustomAssets" BeforeTargets="BeforeBuild">
    <ItemGroup>
      <BackofficeCustomContentFiles Include="$(BackofficeCustomContentFilesPath)" />
    </ItemGroup>
    <Message Text="Copying BackofficeCustom files: $(BackofficeCustomContentFilesPath) - #@(BackofficeCustomContentFiles->Count()) files" Importance="high" />
    <Copy SourceFiles="@(BackofficeCustomContentFiles)" DestinationFiles="@(BackofficeCustomContentFiles->'$(MSBuildProjectDirectory)\App_Plugins\BackofficeCustom\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
  </Target>

  <Target Name="ClearBackofficeCustomAssets" BeforeTargets="Clean">
    <ItemGroup>
      <BackofficeCustomDir Include="$(MSBuildProjectDirectory)\App_Plugins\BackofficeCustom\" />
    </ItemGroup>
    <Message Text="Clear old BackofficeCustom data" Importance="high" />
    <RemoveDir Directories="@(BackofficeCustomDir)" />
  </Target>
</Project>
Just figuring out now if my structure matches with the paths in this .target file
h
When you build your website, do you see a message like "Copying BackofficeCustom files" in the console?
b
No, I do not see that. Here is the build output: Rebuild started at 12:01... 1>------ Rebuild All started: Project: BackofficeCustom, Configuration: Release Any CPU ------ Restored D:\Projects\UmbracoPackages\BackofficeCustom\BackofficeCustom.csproj (in 3,57 sec). 1>BackofficeCustom -> D:\Projects\UmbracoPackages\BackofficeCustom\bin\Release\net8.0\BackofficeCustom.dll 1>The package BackofficeCustom.1.0.0 is missing a readme. Go to https://aka.ms/nuget/authoring-best-practices/readme to learn why package readmes are important. 1>Successfully created package 'D:\Projects\UmbracoPackages\BackofficeCustom\bin\Release\BackofficeCustom.1.0.0.nupkg'. ========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ========== ========== Rebuild completed at 12:01 and took 09,857 seconds ==========
h
That is the build for your package, what do you see when you build the website?
b
Well, not much more than the build of the package: Rebuild started at 12:03... Restored D:\Projects\UmbracoPackages\BackofficeCustom\BackofficeCustom.csproj (in 799 ms). 1>------ Rebuild All started: Project: Umbraco13Test, Configuration: Debug Any CPU ------ Restored C:\Users\xxx\Downloads\opinionated-package-starter-main\template\src\PackageStarter\PackageStarter.csproj (in 869 ms). Restored D:\Projects\Umbraco\Umbraco13Test\Umbraco13Test\Umbraco13Test.csproj (in 915 ms). 1>Umbraco13Test -> D:\Projects\Umbraco\Umbraco13Test\Umbraco13Test\bin\Debug\net8.0\Umbraco13Test.dll 1>Copying JSON schema files into project directory: appsettings-schema.Umbraco.Cms.json 1>Adding JSON schema references to appsettings-schema.json: https://json.schemastore.org/appsettings.json;appsettings-schema.Umbraco.Cms.json# ========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ========== ========== Rebuild completed at 12:03 and took 15,103 seconds ========== Note; the PackageStarter is just a test package that is loaded in the same solution. So that can be ignored. I do not see the installed 'BackofficeCustom' package in the console output.
h
sounds like it is not running the targets code
b
Indeed. I've checked the .csproj file, and noticed there isn't a reference to the .targets file. So I added this line: When I now build my package, it removes the files in App_Plugin. Then it throws an build error, as there are no files to copy https://cdn.discordapp.com/attachments/1189559943209177170/1189897207030218812/image.png?ex=659fd521&is=658d6021&hm=4ec9a1a98fa7fa121991fbc9f1016560d0acb36ecdeacfa43d10ead07cf44de0&
Update: seems to be happening when I do a rebuild. I guess that triggers the clean. When I trigger a normal build that issue won't occur. I'll try to update the nupkg file and install the update to see what happens.
Update: I've removed the 'ClearBackofficeCustomAssets' target for now. When I build my packge, I can see the copy action:
1>Copying BackofficeCustom files: D:\Projects\UmbracoPackages\BackofficeCustom\buildTransitive\..\App_Plugins\BackofficeCustom\**\*.* - #2 files
So that's great. When I check the DevOps logs, I also see some files that are included in the .nupkg file:
Copy code
Add file 'D:\a\1\s\BackofficeCustom\bin\release\net8.0\BackofficeCustom.dll' to package as 'lib\net8.0\BackofficeCustom.dll'
Add file 'D:\a\1\s\BackofficeCustom\App_Plugins\BackofficeCustom\custom.css' to package as 'content\App_Plugins\BackofficeCustom\custom.css'
Add file 'D:\a\1\s\BackofficeCustom\App_Plugins\BackofficeCustom\package.manifest' to package as 'content\App_Plugins\BackofficeCustom\package.manifest'

Added file '[Content_Types].xml'.
Added file '_rels/.rels'.
Added file 'BackofficeCustom.nuspec'.
Added file 'content/App_Plugins/BackofficeCustom/custom.css'.
Added file 'content/App_Plugins/BackofficeCustom/package.manifest'.
Added file 'lib/net8.0/BackofficeCustom.dll'.
Added file 'package/services/metadata/core-properties/e337fab9745540fdbe57da7e1a2ff16b.psmdcp'.

Successfully created package 'D:\a\1\a\PackgeToPublishAsArtifact\BackofficeCustom.1.0.0-CI-20231228-121741.nupkg'.
Unfortunately after installing the update and run a build of the Umbraco13Test solution, there is no copy action. The plugin does not seems to be installed, and does not work... I installed UmbracoForms in my Umbraco13Test project, just to see if there is a diference. Well; the umbraco forms plugin does show up in the installed packages. Altough I also don't see a copy action in the output. So I guess I have multiple problems with my package; the copy action works now, but I guess there is more... Does it matter by the way that my version that I use is auto-created by DevOps, so the version number isn't dust x.y.z, but has a suffix '-CI-20231228...'?
h
You shouldn't need to touch the csproj file
d
The version shouldn't matter here. In my experience it is important that the targets file has the same name as the nuget package id, but it seems that that is already the case, so that shouldn't be an issue.
b
I'll try to add a second clean package tomorrow and see how that goes. Maybe there is some config file or setting that I just don't see at the moment... I'll get back to you later. Thank you for all the help so far. I'll keep you posted!
Okay, new day... let's see. I've created a new package using this command:
dotnet new umbracopackage --name BackofficeCustom2
I've added in the App_Plugins folder the .css, and altered the manifest so it includes the .css file. As a test, I've copied the App_Plugins/BackofficeCustom2 folder into the App_Plugins folder of my Umbraco 13 installation: tada - that works. I can see the package in the list and the package is actually working. So, next steps: - I've removed files from my Umbraco 13 solution (App_Plugins/BackofficeCustom2). - I used DevOps to create a nuget pack and uploaded it to my Azure Artifacts -- When I download this file and check the contents, it looks like this:
- I've installed the new package, but the App_Plugins folder in my solution is still empty... the plugin won't show up and isn't working. So.... is the conents of my nuget package not correct? Inside the 'content' folder I can see the App_Plugins/BackofficeCustom2/package.manifest (and the .css file). When I take a look at the 'godmode' package screenshot, I notice that in my package the .targets file isn't included in the .nupkg file... When I use the 'pack' command from Visual Studio itself, I got a different content in my .nupkg file then after my DevOps pipeline packs it. Not sure why yet... Below the contents from the DevOps .nupkg created file:
h
Not sure exactly what you are doing, but I just performed the following steps
Copy code
dotnet new umbracopackage --name MyCustomDashboard
cd MyCustomDashboard
dotnet pack
I then created a project to test the package
Copy code
cd ..
dotnet new umbraco -n CustomWelcomeDashboardProject -p MyCustomDashboard
cd CustomWelcomeDashboardProject
dotnet build
dotnet run
The packagee appears in the installed packages
b
Awesome. This works indeed (altough, almost. I got an error when running dotnet run, something with permissions, even though started visual studio as administrator... but I can work arround it by just starting the project: works great). So when I do this all locally, things work out great. So the package I create isn't the problem at all. I guess there is something wrong with my DevOps pipeline where I run the 'dotnet pack' command, as I do not see the .targets file included in the .nupkg file that is created by that pipline. I need to look into that I guess...
h
d
I think you're on the right track! If there's a difference between your local results and that of your pipeline, the pipeline would be the place to look. Here's a thought: is your targets file ignored in git?
b
It is included in git, good suggestion though! I used the 'NuGet pack' task in DevOps. Just replaced it with the 'dotnet pack' command, as that is what locally works. After fixing versioning issues, it worked! Not sure what the difference is between NuGet pack and dotnet pack. Will dive into that another time. Thank you all for the support!
j
For what it’s worth I’ve had mixed success with manifest files on disk, I know in previous versions it didn’t work at all. I made the decision to create the manifest via C# and added a composer and never had any issues since. Then have never needed to mess with .targets etc so maybe worth a consideration
d
I agree with this. I prefer C# code over files on disk. Even better: use a razor class library and completely get rid of file handling in your plugins: https://dev.to/kevinjump/umbraco-10-razor-class-library-packages-pt1-3nfa
b
Awesome, thanks folks. I'll take a look into that as an improvement
8 Views