简体   繁体   English

我如何将NUnit2XmlResultWriter.dll放入项目以使用它?

[英]How do i get the NUnit2XmlResultWriter.dll into my project to use it?

I want to write that C# code convert-nunit-3-nunit-2-results-xml-file , but despite the added nuget package i'm missing the dll in my project. 我想编写C#代码convert-nunit-3-nunit-2-results-xml-file ,但是尽管添加了nuget包,但我的项目中缺少dll。 I see it in the tool's directory of the package cache, but missing it in my project. 我在程序包缓存的工具目录中看到了它,但是在我的项目中却找不到它。 What do i overlook? 我忽略了什么?

在此处输入图片说明

My project is at present for .Net Core 2.1. 我的项目目前针对.Net Core 2.1。 Is my issue therefore related to this: Add support for net standard ? 因此,我的问题是否与此有关: 添加对网络标准的支持 I'm new to .net and don't understand all the differences so far. 我是.net的新手,目前尚不了解所有差异。

You didn't overlook anything. 你什么都没忽略。 Not all NuGet packages are libraries. 并非所有的Nu​​Get软件包都是库。

NuGet has conventions on how files must be packed in order to use various features. NuGet约定了如何打包文件才能使用各种功能。 For example, files in the content or contentFiles get copied into the project directory, or build output, depending if the project using the package uses packages.config , or PackageReference . 例如, contentcontentFiles中的文件将复制到项目目录中,或生成输出,这取决于使用该软件包的项目是使用packages.config还是PackageReference If the package author wants to give you a library that you can use in your code, they must put the library in the lib directory in the nupkg (technically it could be in ref , but those don't get copied to build/publish output, they're only used at build time). 如果软件包作者希望为您提供一个可在您的代码中使用的库,则他们必须将该库放在nupkg的lib目录中(从技术上讲,它可以在ref ,但是不会被复制到构建/发布输出中) ,它们仅在构建时使用)。 The tools directory is, unsurprisingly, intended for tools packages. 毫无疑问, tools目录用于工具包。 It's often used by unit test runners, or in this case, a report generator. 它通常由单元测试运行者使用,或者在这种情况下,由报告生成器使用。

So, since the package puts the dlls in the tools directory, this means the package author intends the package to be a tool to assist you during development, but not as a library for you to use in your code. 因此,由于软件包将dll放在tools目录中,因此这意味着软件包作者希望该软件包成为开发过程中为您提供帮助的工具,而不是作为您在代码中使用的库。 You could try contacting the package author to see if they have published another package with the same dll, this time in the lib directory, so that you can use it your project. 您可以尝试与软件包作者联系,以查看他们是否这次在lib目录中发布了具有相同dll的另一个软件包,以便您可以在项目中使用它。

Otherwise you'll need to find a solution that doesn't rely on NuGet bringing you this dll as a library. 否则,您将需要找到一个不依赖NuGet的解决方案来将这个dll作为库提供。 One option is to have a packages.config file that extracts the package in a solution packages directory, and then you use a dll reference to the dll. 一种选择是拥有一个packages.config文件,该文件将包解压缩到解决方案packages目录中,然后您使用对该dll的dll引用。 Your build script would then need to first restore the packages.config file before building your project. 然后,在构建项目之前,您的构建脚本将需要首先还原packages.config文件。 Another option is to check in the dll into your source control management tool, if the dll's license allows that, and again have a dll reference to it. 另一个选择是将dll签入您的源代码管理管理工具中(如果dll的许可证允许),然后再次对其进行dll引用。

As zivkan explained, the package is a tool. 正如zivkan解释的那样,该软件包是一种工具。 In fact, it's an extension to another tool, the NUnit engine package. 实际上,它是对另一个工具NUnit引擎软件包的扩展。 The NUnit engine knows how to find and use the extension. NUnit引擎知道如何查找和使用扩展。

NUnit does not publish a package that is intended for use by your code as a library, because we would then have to support it as a library in addition to it's use as an extension to NUnit. NUnit的发布是为使用您的代码作为一个库包,因为我们将不得不支持它除了作为扩展到NUnit的它的使用图书馆。

However, NUnit's MIT license allows you to use the source code, which you can find at https://github.com/nunit/nunit-v2-result-writer 但是,NUnit的MIT许可证允许您使用源代码,您可以在https://github.com/nunit/nunit-v2-result-writer中找到该源代码。

Since the code has not yet been ported to .NET Core, you would have to do that yourself. 由于代码尚未移植到.NET Core,因此您必须自己做。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM