在Visual Studio 2017中创建nuget包

时间:2023-01-09 03:29:59

In Visual Studio 2017, I have a C# class library that targets netcoreapp2.0. It is a csproj type project. I have installed nuget v4.5.

在Visual Studio 2017中,我有一个针对netcoreapp2.0的C#类库。这是一个csproj类型的项目。我安装了nuget v4.5。

I would like to generate nuget packages from that library. In the project properties, I filled out the relevant package information. I followed this guide to set everything up.

我想从该库生成nuget包。在项目属性中,我填写了相关的包信息。我按照本指南设置了所有内容。

When I click on the pack command for that project, the project gets rebuild but no nupgk is generated. Output is this:

当我单击该项目的pack命令时,项目将重建,但不会生成nupgk。输出是这样的:

1>------ Build started: Project: DuDiKiCommon, Configuration: Debug Any CPU ------ 1>DuDiKiCommon -> E:\repositories\DuDiKiCommon\DuDiKiCommon\bin\Debug\netcoreapp2.0\DuDiKiCommon.dll ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

1> ------ Build build:项目:DuDiKiCommon,配置:调试任何CPU ------ 1> DuDiKiCommon - > E:\ repositories \ DuDiKiCommon \ DuDiKiCommon \ bin \ Debug \ netcoreapp2.0 \ DuDiKiCommon。 dll ==========构建:1成功,0失败,0最新,0跳过==========

What might I be missing here?

我可能会在这里失踪什么?

1 个解决方案

#1


0  

You can use dotnet pack -c Release or (in the developer command prompt) msbuild /restore /t:Pack /p:Configuration=Release to trigger the .nupkg generation.

您可以使用dotnet pack -c Release或(在开发人员命令提示符下)msbuild / restore / t:Pack / p:Configuration = Release来触发.nupkg生成。

You do not need nuget.exe for that.

你不需要nuget.exe。

Int this specific case, the dependency on xunit marks the project as test project which are not packable by default.

在这种特定情况下,对xunit的依赖性将项目标记为测试项目,默认情况下不可打包。

Use the xunit.extensibility.core package instead to ship helper logic or set this in the .csproj file:

使用xunit.extensibility.core包来发送帮助程序逻辑或在.csproj文件中设置它:

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

See this GitHub issue for more details.

有关更多详细信息,请参阅此GitHub问题。

#1


0  

You can use dotnet pack -c Release or (in the developer command prompt) msbuild /restore /t:Pack /p:Configuration=Release to trigger the .nupkg generation.

您可以使用dotnet pack -c Release或(在开发人员命令提示符下)msbuild / restore / t:Pack / p:Configuration = Release来触发.nupkg生成。

You do not need nuget.exe for that.

你不需要nuget.exe。

Int this specific case, the dependency on xunit marks the project as test project which are not packable by default.

在这种特定情况下,对xunit的依赖性将项目标记为测试项目,默认情况下不可打包。

Use the xunit.extensibility.core package instead to ship helper logic or set this in the .csproj file:

使用xunit.extensibility.core包来发送帮助程序逻辑或在.csproj文件中设置它:

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

See this GitHub issue for more details.

有关更多详细信息,请参阅此GitHub问题。