NuGet: references to assemblies in runtimes folder not added

后端 未结 6 1872
孤独总比滥情好
孤独总比滥情好 2021-01-01 15:23

I have a project that targets two different operating systems/frameworks:

  1. net461 on Windows and
  2. netcoreapp2.0 on OSX
  3. <
6条回答
  •  被撕碎了的回忆
    2021-01-01 16:14

    I spent a fair amount of time trying your project on OSX in both Visual Studio for Mac and VS Code. I'll try to stick with factual observations without getting into "why don't you do X instead".

    • The runtimes/{rid}/lib/{tfm}/*.dll paths look ok
    • target="lib/{tfm}/..." assemblies are automatically referenced, runtimes/... are not
    • Using target framework of netstandard seems like it would make your package work in both netcoreapp and netstandard projects (e.g. use target="lib/netstandard1.6/..."). Compare with this
    • runtimes/ seems to be intended for platform-dependent assemblies you'll load at runtime. For example, 32/64-bit native assemblies in runtimes/win-x64/native/ and runtimes/win-x86/native/) loaded with AssemblyLoadContext (another post by McMaster)
    • Using separate slns for Windows and OSX, or separate platform-specific projects that reference platform-agnostic projects (like Xamarin) would obviate some of the configuration wrangling
    • I found no documentation on target="ref/...", but you can add Explicit Assembly (inside the nuspec block)
    • Packaged assemblies won't appear in the output directory, but when prepared for distribution with dotnet publish they'll be included:

提交回复
热议问题