创建包含其他nuget软件包的nuget软件包

时间:2018-12-05 23:01:42

标签: reference nuget nuget-package packagereference

我创建了一个 .NET Standard 项目,在其中安装了4.4.4 nuget软件包的版本System.ServiceModel.Http。该软件包还包括dll System.ServiceModel.Primitives ...我添加了图像:

enter image description here

我已经使用命令从项目中创建了一个nuget包

.\nuget.exe pack MyProjectFile.csproj -Build -ExcludeEmptyDirectories -IncludeReferencedProjects -OutputDirectory  MyOutputDir

现在,我必须在 .NET Framework 项目中的另一个解决方案中安装此软件包。但是由于某些原因,当我启动项目时,出现此错误:

  

无法加载文件或程序集'System.ServiceModel.Primitives,   版本= 4.2.0.3,文化=中性,PublicKeyToken = b03f5f7f11d50a3a'或   其依赖项之一。

dll 4.2.0.3的版本System.ServiceModel.Primitives在软件包版本4.4.4

我以这种方式编辑了.NET Standard项目文件:

<PackageReference Include="System.ServiceModel.Primitives" Version="4.4.4" />
<PackageReference Include="System.ServiceModel.Http" Version="4.4.4" />

但是当我在.NET Project中安装软件包时,仍然收到该错误。我的包裹中没有包含任何外部包裹...我想念什么?

谢谢

编辑

我也希望在安装nuget软件包时出现一个窗口,告诉我“您是否还需要安装软件包A和软件包B。是否继续?”。什么也没有出现。...

1 个答案:

答案 0 :(得分:1)

如果使用的是.net标准项目,则可以使用dotnet CLI代替nuget.exe。我总是发现它更清洁,而且过程更少。您可以在dotnet CLI中使用类似的方法

dotnet pack -c release -o MyOutputDir

这里输出文件夹是可选的,默认情况下config是“ debug”。我已经将其用于多个nuget,而nuget引用从来没有问题。

相关问题