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

时间:2018-10-08 10:33:12

标签: c# nuget asp.net-core-2.1 .net-core-2.1

我有5个项目的解决方案,其中2个是.netstandard 2.0,而3个是.net core 2.1。 这些项目之间的引用如下:

  • 项目Api引用了CommonModels
  • 项目Common没有引用。
  • 项目“逻辑”引用Common,“模型”和“接口”。
  • 项目Interfaces引用了Models
  • 项目Models引用了Common

我已经将此Api.nuspec文件添加到了Api.csproj文件所在的Api项目的根文件夹中:

<?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>

我正在尝试为项目Api创建一个nuget包,并将其发布到我们工作网络中的本地共享文件夹中。我尝试了两种方式:

  • 右键单击项目,然后选择pack
  • 在cmd上运行: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上引用该nuget时,会出现错误NU1101,表明缺少Models' and Logic`引用。

我在这里做什么错了?

0 个答案:

没有答案