【问题标题】:Created nuget package's dll can not be accessable from package's loaded project无法从包加载项目中访问创建的 nuget 包 dll
【发布时间】:2017-03-29 17:53:06
【问题描述】:

我想为我的 .net 核心类库创建一个 nuget 包。

  1. 我将 nuget.exe 文件复制到了我的解决方案的根文件夹中
  2. 运行 nuget spec 和创建的 Solution.nuspec 文件。我修改如下:

    <?xml version="1.0"?>
    <package >
    <metadata>
    <id>Solution</id>
    <version>1.0.0</version>
    <authors>cc Team</authors>
    <owners>cc</owners>
    <licenseUrl></licenseUrl>
    <projectUrl></projectUrl>
    <iconUrl></iconUrl>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description></description>
    <releaseNotes></releaseNotes>
    <copyright>Copyright 2017</copyright>
    <tags>c# .net</tags>
    <dependencies>
        <dependency id="NETStandard.Library" version="1.6.1" />
    </dependencies>
    <references>
        <reference file="Solution.dll" />
    </references>
    </metadata>
    <files>
    <file src="Solution.dll" target="lib\netstandard1.6\Solution.dll"/>
    


我的解决方案的文件的节点 src 值 outpupath。 (bin\Release\netstandard1.6\Solution.dll)

  1. 运行 nuget pack Solution.nuspec 并创建 Solution.nupkg 文件。
  2. 我把它放到了我的包源中。
  3. 创建一个新的 .net 核心类库并从本地包源中选择我的解决方案 nuget 包。它添加到我的项目中。没有错误或警告。但是当我尝试从我的解决方案 nuget 包中访问一个类时,找不到它。我下载了“Nuget 包资源管理器”并打开了我的 Solution.nupkg。我可以在 lib --> netstandart1.6 下看到 Solution.dll 和 Solution.pdb 文件。

然后我搜索了错误并发现了这个:

"scripts": {
"postcompile": [
  "dotnet pack --no-build --configuration %compile:Configuration%"
]
}

编译我的解决方案项目后,它会创建解决方案.1.0.0-0.nupkg 文件和解决方案.1.0.0-0.symbols。我把它放到我的本地包源中,但这些包没有在“Nuget 包管理器”中列出。

你有什么想法吗?

【问题讨论】:

    标签: c# .net visual-studio-2015 nuget-package nuget-spec


    【解决方案1】:

    我的经验是从解决方案创建包有时很糟糕。从项目文件创建包可以解决问题。

    【讨论】:

      【解决方案2】:

      在我清理 'C:\Users\XXX.nuget\packages\Solution' 文件夹并再次添加包后解决了我的问题。

      因为我之前尝试过的格式错误的 nutget 包。

      【讨论】:

        猜你喜欢
        • 2017-09-02
        • 2019-03-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-06-03
        • 1970-01-01
        相关资源
        最近更新 更多