I want to make small pieces of source code (e.g. helper classes) available for use in .NET Core projects (.csproj).
At this point I packaged the source code with NuGet in many different ways according to different blog posts and the official nuget docs. I used a nuspec file to control where my source files will end up in the nuget package, e.g.:
<files>
<file src="*.cs" target="content/LruCache" />
<file src="*.cs" target="contentFiles/cs/any/LruCache" />
</files>
I did not include any msbuild targets file or install script.
Whenever I install the NuGet package into a .NET Core project (https://docs.microsoft.com/en-us/dotnet/core/tools/csproj) I simply don't get anything there. No source files will be included into my project. I tried different settings for the <PackageReference/>
node in the .csproj (PrivateAssets, etc.) without success.
Is it meant to be possible at all? If so, how should it be done?
Background:
The reason for doing this is some kind of diamond problem where we have projects B and C both using helper class A and a third project D using B and C.
In this situation I don't want to deal with assembly version conflicts when different (incompatible) versions of A have been used in B and C.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…