首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么我的Nuget-lib在.NetStandard 2.0中不可用?

为什么我的Nuget-lib在.NetStandard 2.0中不可用?
EN

Stack Overflow用户
提问于 2019-10-07 02:40:52
回答 1查看 148关注 0票数 0

我用下面的Nuspec创建了Nuget "Uplink.NET“:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd">
  <metadata>
    <id>uplink.NET</id>
    <version>1.3.1</version>
    <title>Connector to the storj-network</title>
    <authors>TopperDEL,Storj Labs Inc.</authors>
    <owners>TopperDEL,Storj Labs Inc.</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <projectUrl>https://github.com/TopperDEL/uplink.net</projectUrl>
    <iconUrl>https://storj.io/press-kit/Storj-symbol.png</iconUrl>
    <description>This library provides access to the secure and decentralised Storj-network. It allows you to:
- create and delete buckets
- upload and download files

It is - like Storj itself - open source and developed on GitHub.</description>
    <releaseNotes>Initial release</releaseNotes>
    <copyright>(c) 2019 TopperDEL, Storj Labs Inc.</copyright>
    <tags>storj tardigrade storage decentralised secure bucket file xamarin android</tags>
    <repository type="git" url="https://github.com/TopperDEL/uplink.net.git" />

    <contentFiles>
      <files include="uplink.NET\bin\release\netstandard2.0\storj_uplink.dll" buildAction="None" copyToOutput="true" flatten="true" />
    </contentFiles>
  </metadata>
  <files>
    <file src="uplink.NET.targets" target="build\uplink.NET.targets" />
    <file src="uplink.NET.Droid\bin\Release\uplink.NET.Droid.dll" target="lib\MonoAndroid7.0\uplink.NET.Droid.dll" />
    <file src="uplink.NET.Droid\bin\Release\uplink.NET.Droid.dll" target="lib\MonoAndroid7.1\uplink.NET.Droid.dll" />
    <file src="uplink.NET.Droid\bin\Release\uplink.NET.Droid.dll" target="lib\MonoAndroid8.0\uplink.NET.Droid.dll" />
    <file src="uplink.NET.Droid\bin\Release\uplink.NET.Droid.dll" target="lib\MonoAndroid8.1\uplink.NET.Droid.dll" />
    <file src="uplink.NET.Droid\bin\Release\uplink.NET.Droid.dll" target="lib\MonoAndroid9.0\uplink.NET.Droid.dll" />
    <file src="uplink.NET\bin\Release\netstandard2.0\uplink.NET.dll" target="lib\netstandard2.0\uplink.NET.dll" />
    <file src="uplink.NET\bin\Release\netstandard2.0\uplink.NET.dll" target="netstandard2.0\uplink.NET.dll" />
    <file src="uplink.NET\bin\Release\netstandard2.0\uplink.NET.dll" target="lib\uap10.0.16299\uplink.NET.dll" />
    <file src="uplink.NET\storj_uplink.dll" target="storj_uplink.dll" />
  </files>
</package>

我可以将其添加到NetStandard2.0类库中,但会将其添加为包含以下条目的PackageReference:

代码语言:javascript
复制
<PackageReference Include="uplink.NET" Version="1.3.1">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>

我现在不能访问我的库中的对象。但同样的Nuget正在与Xamarin.Android和UWP一起工作。

有人能帮上忙吗?

EN

回答 1

Stack Overflow用户

发布于 2019-10-08 01:18:13

是,当包是开发依赖项时,如our NuGet docs say

如果使用PackageReference (NuGet 4.8+),则此标志还意味着它将从编译中排除编译时资产。

A linked page进一步解释:

当package的developmentDependency为true时,将PrivateAssets设置为All,将ExcludeAssets设置为编译项目中的PackageReference项,而:

  • 通过VS NuGet UI或PMC
  • 安装软件包执行dotnet添加软件包命令将现有项目从packages.config迁移到PackageReference

即使developmentDependency是真的,也不要做任何事情,把它当做普通的PackageReference,而:

为了将package

  • Upgrading现有VS实例从以前的版本添加到最新版本(开始支持developmentDependency)

),

  • 在项目中手动添加PackageReference项
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58260234

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档