Creating a Nuget package

I have 2 projects, one for “core” code and functionality and one for adding sections, menus, etc to the backend.

I want to create a Nuget package that installs both.

If I add the projects to the consuming solution then everything works as expected. If I create a nuget package, it doesn’t (the backoffice extras do not appear)

To create the Nuget package I created a project that includes the DLLs from each project (core and backoffice). It also includes the files from the App_Plugins folder of the BackOffice project.

The Nuget package is constructing OK and it installs, but it must be missing something as the backoffice functionality doesn’t work. The “Core” code seems to be OK though.

Any help, pointers, etc would be most welcome!

Hi Gordon
If I understand your project structure, then in theory you will need to ship multiple Nuget packages.

  • YourAwesomeThing.Core
  • YourAwesomeThing

The YourAwesomeThing nuget package will need a dependancy to the other created Nuget package YourAwesomeThing.Core.

Hi Warren,

so, I created the 2 separate projects for separation - not because one could / would be installed without the other. Would it help at all if I were to merge the two projects?

I think the key issue is that the vite / backoffice elements do not seem to be properly included - or work when the nuget package is installed. Is there something specific that I need in order to fix that?

Is your App_Plugins folder located in wwwroot? This is an example of the project file of a NuGet package I have. Maybe you’ll see something you missed

<!-- Make sure you use a razor class libary -->
<Project Sdk="Microsoft.NET.Sdk.Razor">

	<PropertyGroup>
		<TargetFramework>net9.0</TargetFramework>
		<ImplicitUsings>enable</ImplicitUsings>
		<Nullable>enable</Nullable>

		<ContentTargetFolders>.</ContentTargetFolders>
		<Product>Umbraco.ContentExpiration</Product>
		<PackageId>Umbraco.ContentExpiration</PackageId>
		<Title>Umbraco.ContentExpiration</Title>
		<Description>Package for handling content that expires when it’s not updated regularly.</Description>
		<PackageTags>proudnerds package umbraco</PackageTags>
		<RootNamespace>Umbraco.ContentExpiration</RootNamespace>
		<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
		<Authors>Proud Nerds .NET team</Authors>
		<Company>Proud Nerds</Company>
		<RepositoryUrl></RepositoryUrl>
		<GenerateDocumentationFile>True</GenerateDocumentationFile>
		<PackageIcon>Package-image_128_128.png</PackageIcon>
		<VersionPrefix>15.1.0</VersionPrefix>
		<PackageReadmeFile>readme.md</PackageReadmeFile>
		<StaticWebAssetBasePath>/</StaticWebAssetBasePath>
	</PropertyGroup>

I can’t find a good source, but as far as I know, it’s not recommended to place multiple dll’s in a single NuGet package, you should create a NuGet package per project.

Also, you can use dotPeek to see the content of your NuGet package, so you can see what files are in it:

I created a Nuget package for each project and added them both to the consuming project and (with some other little tweaks / fixes) it is now working :slight_smile:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.