Quantcast
Channel: Active questions tagged nuget-package - Stack Overflow
Viewing all articles
Browse latest Browse all 3067

How to include referenced projects

$
0
0

I have a solution with 4 projects inside. One of them we pack as a Nuget package, the others are just some common code shared between the projects. We want to publish the package but we do not want to publish a separate packages for every dependent project.

I tried following this tutorial, and I took the .csproj approach.Here is what I have in the .csproj file on the project that I pack:

<Project Sdk="Microsoft.NET.Sdk"><PropertyGroup><TargetFramework>net8.0</TargetFramework><Title>LookupListCache</Title><Authors>Yulian Dimitrov</Authors><Description>This package contains everything for setting up a LookupListCache. Please configure LookupListCache connection string.</Description><PackageReleaseNotes>        Some release notes</PackageReleaseNotes><GeneratePackageOnBuild>true</GeneratePackageOnBuild><Version>9.0.0-pg-03</Version><AssemblyVersion>9.0.0.0</AssemblyVersion><FileVersion>9.0.0.0</FileVersion><TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput></PropertyGroup><ItemGroup><PackageReference Include="EFCore.NamingConventions" Version="8.0.3" /><PackageReference Include="AutoMapper" Version="13.0.1" /><PackageReference Include="FluentValidation.AspNetCore" Version="11.3.0" /><PackageReference Include="Hangfire.Core" Version="1.8.6" /><PackageReference Include="LEXolutionServiceBus" Version="1.5.175.63106" /><PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.8" /><PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.8"><PrivateAssets>all</PrivateAssets><IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets></PackageReference><PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" /><PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" /><PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" /><PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.0" /><PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" /><PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.8" /><PackageReference Include="Newtonsoft.Json" Version="13.0.3" /></ItemGroup><ItemGroup><None Remove="appsettings.json" /><EmbeddedResource Include="appsettings.json" /></ItemGroup><ItemGroup><ProjectReference Include="..\LookupListCache.Common\LookupListCache.Common.csproj" PrivateAssets="All" /><ProjectReference Include="..\LookupListCache.Migrations.CamelCase\LookupListCache.Migrations.CamelCase.csproj" PrivateAssets="All" /><ProjectReference Include="..\LookupListCache.Migrations.SnakeCase\LookupListCache.Migrations.SnakeCase.csproj" PrivateAssets="All"/></ItemGroup><Target Name="CopyProjectReferencesToPackage" DependsOnTargets="BuildOnlySettings;ResolveReferences"><ItemGroup><!-- Filter out unnecessary files --><_ReferenceCopyLocalPaths Include="@(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference')->WithMetadataValue('PrivateAssets', 'All'))"/></ItemGroup><!-- Print batches for debug purposes --><Message Text="Batch for .nupkg: ReferenceCopyLocalPaths = @(_ReferenceCopyLocalPaths), ReferenceCopyLocalPaths.DestinationSubDirectory = %(_ReferenceCopyLocalPaths.DestinationSubDirectory) Filename = %(_ReferenceCopyLocalPaths.Filename) Extension = %(_ReferenceCopyLocalPaths.Extension)" Importance="High" Condition="'@(_ReferenceCopyLocalPaths)' != ''" /><ItemGroup><!-- Add file to package with consideration of sub folder. If empty, the root folder is chosen. --><BuildOutputInPackage Include="@(_ReferenceCopyLocalPaths)" TargetPath="%(_ReferenceCopyLocalPaths.DestinationSubDirectory)"/></ItemGroup></Target></Project>

When I try to pack the LookupListCache project I got the LookupListCache.9.0.0-pg-03.nupkg file, and in it's lib folder inside it has the 3 referenced .dll files:generated filesIn the .LookupListCache.nuspec file I have:

<?xml version="1.0" encoding="utf-8"?><package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd"><metadata><id>LookupListCache</id><version>9.0.0-pg-03</version><title>LookupListCache</title><authors>Yulian Dimitrov</authors><description>This package contains everything for setting up a LookupListCache. Please configure LookupListCache connection string.</description><releaseNotes>Some release notes</releaseNotes><repository type="git" commit="5f74f5b8b658ff9995b648a3c09e5bd09b263515" /><dependencies><group targetFramework="net8.0"><dependency id="AutoMapper" version="13.0.1" exclude="Build,Analyzers" /><dependency id="EFCore.NamingConventions" version="8.0.3" exclude="Build,Analyzers" /><dependency id="FluentValidation.AspNetCore" version="11.3.0" exclude="Build,Analyzers" /><dependency id="Hangfire.Core" version="1.8.6" exclude="Build,Analyzers" /><dependency id="LEXolutionServiceBus" version="1.5.175.63106" exclude="Build,Analyzers" /><dependency id="Microsoft.EntityFrameworkCore" version="8.0.8" exclude="Build,Analyzers" /><dependency id="Microsoft.Extensions.Configuration" version="8.0.0" exclude="Build,Analyzers" /><dependency id="Microsoft.Extensions.Configuration.Abstractions" version="8.0.0" exclude="Build,Analyzers" /><dependency id="Microsoft.Extensions.Configuration.EnvironmentVariables" version="8.0.0" exclude="Build,Analyzers" /><dependency id="Microsoft.Extensions.Configuration.FileExtensions" version="8.0.0" exclude="Build,Analyzers" /><dependency id="Microsoft.Extensions.Configuration.Json" version="8.0.0" exclude="Build,Analyzers" /><dependency id="Newtonsoft.Json" version="13.0.3" exclude="Build,Analyzers" /><dependency id="Npgsql.EntityFrameworkCore.PostgreSQL" version="8.0.8" exclude="Build,Analyzers" /></group></dependencies></metadata></package>

And when I try to install this package in other solution it says that it cant find the nuget packages:

NU1101: Unable to find package LookupListCache.Common. No packages exist with this id in source(s): C:\Program Files\dotnet\library-packs, Local, Microsoft Visual Studio Offline Packages, nuget.org, standard_pdeNU1101: Unable to find package LookupListCache.Migrations.CamelCase. No packages exist with this id in source(s): C:\Program Files\dotnet\library-packs, Local, Microsoft Visual Studio Offline Packages, nuget.org, standard_pdeNU1101: Unable to find package LookupListCache.Migrations.SnakeCase. No packages exist with this id in source(s): C:\Program Files\dotnet\library-packs, Local, Microsoft Visual Studio Offline Packages, nuget.org, standard_pde

Is there a way that I can pack this project without the need to create separate nuget packages for the rest of the referenced projects?


Viewing all articles
Browse latest Browse all 3067

Trending Articles