简体   繁体   English

Package .NET 框架 DLL 并在 .NET 标准项目中使用

[英]Package .NET framework DLL and use it in .NET standard project

I have a vendor provided DLL which is based on .NET Framework.我有一个供应商提供了基于 .NET 框架的 DLL。 I do not have access to code and I only have the DLL.我无权访问代码,我只有 DLL。 I have packaged this DLL into a nuget package and now I am trying to refer this into a .NET standard project.我已将此 DLL 打包到 nuget package 中,现在我正在尝试将其引用到 Z3061BB0EF9EDB285D902AZ 项目中。 But I am getting warning as - Package 'MyPackage 0.0.1' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'.但我收到警告 - Package 'MyPackage 0.0.1' 是使用 '.NETFramework,Version=v4.6.1' 而不是项目目标框架 '.NETStandard,Version=v2.0' 恢复的。 This package may not be fully compatible with your project.此 package 可能与您的项目不完全兼容。 . .

If I refer the DLL directly into a .NET standard project it doesn't show this warning.如果我将 DLL 直接引用到 .NET 标准项目中,则不会显示此警告。 But using it after creating a nuget package shows that.但是在创建 nuget package 之后使用它表明了这一点。

I also tried creating a .NET standard lib project, added DLL reference and then created a nuget package but still it was showing same warning.我还尝试创建一个 .NET 标准库项目,添加了 DLL 参考,然后创建了一个 nuget ZEFE90A8E604A67C840E88 仍然显示相同的警告。

Is there another way of doing it?还有另一种方法吗? Vendor doesn't provide DLLs targeting other frameworks and I have to use it after packaging it into Nuget because of requirements.供应商不提供针对其他框架的 DLL,由于要求,我必须在将其打包到 Nuget 后使用它。

In my side, I test the situation as you described.在我这边,我按照您的描述测试了情况。 Create a net standard lib project called test , then use this node to include into the package.创建一个名为test的网络标准库项目,然后使用此节点将其包含到 package 中。

1) create a net standard lib nuget project called test and only add this node under test.csproj file: 1)创建一个名为test的网络标准库 nuget 项目,并仅在test.csproj文件下添加此节点:

<ItemGroup>
        <None Include="xxx\xxx\xxx.dll"(the whole path of the net framework dll) Pack="true" PackagePath="lib\$(TargetFramework)"></None>
</ItemGroup>

2) right-click on the net standard test project-->click Pack button and you can get the new version of the nuget package. 2)右键net标准测试项目-->点击Pack按钮,即可得到新版nuget package。

在此处输入图像描述

Before you install the nuget package into another main project, you should first clean nuget caches or delete all files under C:\Users\xxx(current user)\.nuget\packages . Before you install the nuget package into another main project, you should first clean nuget caches or delete all files under C:\Users\xxx(current user)\.nuget\packages .

And I did not face the issue in my side with all the above steps.而且我并没有通过上述所有步骤面对我身边的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Visual Studio .NET标准库和.NET Framework项目-NuGet dll清单定义不匹配 - Visual Studio .NET Standard library and .NET Framework project - NuGet dll manifest definition does not match Package 第三方 dll 在多目标框架项目的上下文中,.Net Framework &amp;.Net Core - Package third party dll in context of multi target framework project, .Net Framework & .Net Core .Net Standard项目中的资源未添加到DLL - Resource in .Net Standard project is not added to DLL 当我将.NET Standard 2.0 DLL库与.NET Framework控制台应用程序一起使用时,如何设置依赖关系? - How to set dependencies when I use .NET Standard 2.0 DLL libraries with a .NET Framework console application? MSBuild在其他.NET Framework项目的解决方案中找不到.NET Standard项目的包 - MSBuild can't find package for .NET Standard project in solution with other .NET Framework projects 如何将DLL从.Net Framework迁移到.Net Standard? - How to migrate DLL from .Net Framework to .Net Standard? 在面向 .NET Framework 的 .NET 标准项目中未加载调试符号 - Debugging symbols not loading in .NET standard project targeting .NET Framework 如何在Visual Studio项目中打包.Net框架? - How to package .Net framework in Visual Studio project? 我的项目是否使用.NET Core或.NET Standard - Does my project use .NET Core or .NET Standard GalaSoft.MvvmLight Package 参考错误与 .net 标准 2.0 项目 - GalaSoft.MvvmLight Package reference error with .net Standard 2.0 project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM