C
C#2y 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 in B.csproj:
<PackageReference Include="A" Condition=" $(ReferenceA) == 'true' " />
<PackageReference Include="A" Condition=" $(ReferenceA) == 'true' " />
but because I have the --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?
0 Replies
No replies yetBe the first to reply to this messageJoin