Search code examples
msbuildnuget-packagexunitdotnet-cli

Cannot create Nuget package that has xunit as dependency


Steps

  1. Create a new .NETStandard 2.0 project e.g ClassLibrary1
  2. Add xunit package as dependency
  3. Open the command prompt and go to the location
  4. Execute following two commands to create package

Please check dotnet pack for more details

dotnet build /p:SourceLinkCreate=true -v:n -c:Release -p:ci=true

dotnet pack -v:n -c=Release --no-build --include-source --include-symbols --output .\bin

Result: Package not created

Instead of xunit if you add any other dependency it works, for example NUnit and test framework, or Newtonsoft.Json. I have also tried with msbuild command, same result

Is there anything I am missing, or it's a bug?


Solution

  • This github issue says the behaviour is by design and your library needs the IsPackable setting in .csproj:

    <Project Sdk="Microsoft.NET.Sdk.Web" ToolsVersion="15.0">
      <PropertyGroup>
        <TargetFramework>netcoreapp2.0</TargetFramework>
        <IsPackable>true</IsPackable>
        ...