I have a simple .NET Core 2.1 class library project and need to pack it as a Nuget package. For that I'm using this command:
dotnet pack <project>.csproj --output <outputFolder> /p:Configuration=Release
But, I'm getting this warning:
C:\Program Files\dotnet\sdk\2.1.502\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(202,5): warning NU5100: The assembly 'obj\Release\netcoreapp2.1\<assembly>.dll' is not inside the 'lib' folder and hence it won't be added as a reference when the package is installed into a project. Move it into the 'lib' folder if it needs to be referenced.
I understand that lib folders are for targeting multiple frameworks, but I don't want that. I only want to target .NET Core 2.1.
At the end my .nupkg file is created, but it has all the source code (don't know why) and when used in other projects, they cannot reference the assemblies, because they are inside the bin\Release\netcoreapp2.1 folder.
I've seen some guides to create Nuget packages from .Net Core projects and none of them mention something related to lib folders.
I need to understand if something is missing or if I'm doing something wrong.
Thanks.
Edit: Added the project file and the .nuspec file
Project File:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<Company>xxx</Company>
<RootNamespace>xxxx</RootNamespace>
<Product>xxxx</Product>
<Authors>xxxx</Authors>
<NuspecFile>xxxxx.nuspec</NuspecFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="5.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="2.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.3" />
</ItemGroup>
</Project>
.nuspec File:
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>xxxxxx</id>
<version>1.0.0</version>
<title>xxxx</title>
<owners>xxxx</owners>
<description>xxxx</description>
<authors>xxxx.</authors>
<copyright>Copyright 2019 xxxx.</copyright>
<summary>xxx is a common code library for internal projects.</summary>
</metadata>
</package>
.csproj? This one's going to be nice and juicy. - Joshua.csprojfile. - Gustavo Vargas.nuspecfiles are not needed anymore, so I like the idea to have the package properties in a separate file. But that was causing the issue. Once I removed the.nuspecfile, it started to create package as expected! - Gustavo Vargas