代码之家  ›  专栏  ›  技术社区  ›  Liran Friedman

C#-如何使用引用创建nuget包

  •  1
  • Liran Friedman  · 技术社区  · 6 年前

    我有一个5个项目的解决方案,2个是。netstandard2.0和3是。net核心2.1。

    • 项目 Api 参考资料 Common Models
    • 项目 常见的
    • 项目“逻辑”参考 常见的 “模型”和“接口”。
    • 项目 Interfaces 参考资料 模型 .
    • 模型 常见的 .

    我加了这个 Api.nuspec Api.csproj 文件是:

    <?xml version="1.0"?>
    <package >
      <metadata>
        <id>API</id>
        <version>1.0.0</version>
        <title>title</title>
        <authors>Liran Friedman</authors>
        <owners>Liran Friedman</owners>
        <licenseUrl></licenseUrl>
        <projectUrl></projectUrl>
        <iconUrl></iconUrl>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
        <description>desc</description>
        <releaseNotes>Initial version</releaseNotes>
        <copyright>Copyright 2018</copyright>
        <tags>api</tags>
        <dependencies>
          <group targetFramework=".NETCoreApp2.1">
            <dependency id="Logic" version="1.0.0" exclude="Analyzers" />
            <dependency id="Models" version="1.0.0" exclude="Analyzers" />
            <dependency id="Microsoft.AspNetCore" Version="2.1.4" exclude="Build,Analyzers" />
            <dependency id="Microsoft.AspNetCore.Authentication" Version="2.1.2" exclude="Build,Analyzers" />
            <dependency id="Microsoft.AspNetCore.Authentication.Cookies" Version="2.1.2" exclude="Build,Analyzers" />
            <dependency id="Microsoft.AspNetCore.Authentication.JwtBearer" Version="2.1.2" exclude="Build,Analyzers" />
            <dependency id="Microsoft.AspNetCore.Authorization" Version="2.1.2" exclude="Build,Analyzers" />
            <dependency id="Microsoft.AspNetCore.CookiePolicy" Version="2.1.2" exclude="Build,Analyzers" />
            <dependency id="Microsoft.Extensions.DependencyInjection" Version="2.1.1" exclude="Build,Analyzers" />
            <dependency id="Newtonsoft.Json" Version="11.0.2" exclude="Build,Analyzers" />
            <dependency id="System.IdentityModel.Tokens.Jwt" Version="5.2.4" exclude="Build,Analyzers" />
          </group>
        </dependencies>
      </metadata>
      <files>
        <file src="C:\XXX\Api\bin\Release\netcoreapp2.1\Api.dll" target="lib\netcoreapp2.1\Api.dll" />
        <file src="C:\XXX\Logic\bin\Release\netcoreapp2.1\Logic.dll" target="lib\netcoreapp2.1\Logic.dll" />
        <file src="C:\XXX\Models\bin\Release\netcoreapp2.1\Models.dll" target="lib\netcoreapp2.1\Models.dll" />
      </files>
    </package>
    

    应用程序编程接口

    • 右键单击项目并选择 pack
    • nuget.exe pack Api.csproj -Build -IncludeReferencedProjects -Version 1.0.0 -OutputDirectory O:\Nugets -Properties Configuration=Release;Desc="desc";Authors="Liran Friedman"

    当我在本地PC上引用nuget时,它工作正常,但从其他PC上引用时,它会出错 NU1101 Models' and 缺少逻辑参考。

    我做错了什么?

    0 回复  |  直到 6 年前