© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago
swagrid

Referencing a nuget package without ever restoring it

I have a nuget package A that only includes native binaries (packaged using a .nuspec file).

I have a C# project B that depends on A.

In the local build environment B uses the binaries of A directly, because I don't have a nuget package at that stage (A is packaged in a CI job later).

B is a nuget package itself and I want A to show up as a dependency of B when it's packaged.

Usually I'd just add A as a package reference in B.csproj but that doesn't work because A.nupkg doesn't exist yet. I tried to conditionally reference it and only include reference A when packing with
dotnet pack B.csproj --no-build -p:ReferenceA
dotnet pack B.csproj --no-build -p:ReferenceA


in B.csproj:
<PackageReference Include="A" Condition=" $(ReferenceA) == 'true' " />
<PackageReference Include="A" Condition=" $(ReferenceA) == 'true' " />


but because I have the
--no-build
--no-build
flag, properties don't seem to be reevaluated and thus the resulting nuget package for B doesn't contain the reference to A.

I know that I could use a .nuspec for B as well but then I'd have to list all dependencies manually again, which I don't want. Essentially, I just want to always skip the restore of one specific nuget package (A). Is this somehow possible?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Custom project templates within a solution, without a nuget package?
C#CC# / help
8mo ago
NuGet package project references
C#CC# / help
17mo ago
nuget package compatibility issues
C#CC# / help
2y ago
Add private nuget package
C#CC# / help
3y ago