Deploy project with xUnit reference as NuGet package

久未见 提交于 2021-02-07 17:29:50

问题


I have a library that contains some classes, which I need in several Unit Test projects. The library should be deployed as a NuGet package in my private repository. I already deployed some NuGet packages there, so I know what I have to do.

BUT: Inside of this library I need a reference to xUnit. And as soon as I add this reference, there is no more .nupkg file created when execute dotnet pack.

Another interesting effect is, that the project icon turns into a Unit Test icon as soon as I add xUnit:

Steps to reproduce:

  1. Create a Class Library

  2. Add a reference to the xUnit NuGet package

  3. Right click the project and click on pack

Expected Behvior: there should be a .nupkg file in ./bin/Debug

Actual Behevior: there is no such file.


回答1:


According to https://github.com/dotnet/cli/issues/7539, some projects seem to be "not packable" by default. You have to enable this manually by adding the following lines to your .csproj file:

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

After that, the .nupkg file is created expected.



来源:https://stackoverflow.com/questions/56124671/deploy-project-with-xunit-reference-as-nuget-package

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!