简体   繁体   中英

how to publish nuget package

I'm trying to publish NuGet package following this doc .

when I run dotnet pack , I get this response

Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Core Copyright (C) Microsoft Corporation. All rights reserved.

Restore completed in 59.66 ms for /Users/ali/Desktop/earthlink/AutoCrud/AutoCrud.csproj.

while in the document I'm following the output should be this :

Microsoft (R) Build Engine version 15.5.180.51428 for .NET Core Copyright (C) Microsoft Corporation. All rights reserved.

Restore completed in 29.91 ms for D:\\proj\\AppLoggerNet\\AppLogger\\AppLogger.csproj. AppLogger -> D:\\proj\\AppLoggerNet\\AppLogger\\bin\\Debug\\netstandard2.0\\AppLogger.dll Successfully created package 'D:\\proj\\AppLoggerNet\\AppLogger\\bin\\Debug\\AppLogger.1.0.0.nupkg'.

as you can see, in my case no .nupkg file created.

here is my .csproj file :

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <TargetFramework>netcoreapp3.1</TargetFramework>
        <PackageId>AutoCrud</PackageId>
        <Version>1.0.0</Version>
        <Authors>Ali Faris</Authors>
        <Company>Ali Faris</Company>
        <PackageLicenseExpression>MIT</PackageLicenseExpression>
        <RepositoryUrl>https://github.com/alicompiler/AutoCrud.NetCore</RepositoryUrl>
        <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
    </PropertyGroup>

    <ItemGroup>
        <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.7"/>
        <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.7"/>
        <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1"/>
        <PackageReference Include="Moq" Version="4.14.5"/>
        <PackageReference Include="xunit" Version="2.4.1"/>
        <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
            <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
            <PrivateAssets>all</PrivateAssets>
        </PackageReference>
        <FrameworkReference Include="Microsoft.AspNetCore.App"/>
    </ItemGroup>
</Project>

how could I generate this .nupkg file.

by the way, I'm using macOS

with the help of this

The issue seemed to be related to some dependencies, in particular: xunit and Microsoft.NET.Test.Sdk , these dependencies are "not packable".

the solution was by adding <IsPackable>true</IsPackable> to PropertyGroup

<PropertyGroup>
    <IsPackable>true</IsPackable>
     ...
</PropertyGroup>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM