如何使用 xmldocument 安装 nuget 包 [英] How can i install a nuget package with xmldocument

查看:30
本文介绍了如何使用 xmldocument 安装 nuget 包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目依赖于一些模块(nuget 包),并且我在包中有打包 xml 文档.

My project depends on some modules(nuget packages), and I have pack xml document in the packages.

当我将它们安装打包到 .我将一个 .nupkg 文件重命名为 .zip,解压它,.xml (xmldocument) 在 zip 包中.

When I install-package them in , xmldocument files of modules are not in my folder. I renamed a .nupkg file to .zip, unzip it ,.xml (xmldocument) is in the zip package.

如何在我的主项目文件夹中安装 .xml 文档?

How can I install the .xml documentation in my main project folder?

更新:

我的项目基于Abp(abp.io),我已经完成了主要模块,并构建了一个aspnet核心项目来引用这些模块.因为该项目包含一个WebApi,所以我想得到一些模块的xmlDocument,然后swagger 信息因为项目包含一个 WebApi,我想获取一些模块的 xmlDocument ,然后 swagger 信息将是完美的.

My project is based on Abp (abp.io), I have finished main modules,and build a aspnet core project to reference the modules.because the project contains a WebApi, I want get some module 's xmlDocument ,then the swagger info cause the project contains a WebApi, I want get some module 's xmlDocument ,then the swagger info will be perfect.

现在,我的方法是使用 post build event 将 .xml 文件更新到一个文件夹.它可以解决我的问题,但我想看看一个想法,可以直接通过引用包来使用它.

Now , My way is use post build event update the .xml files to a folder.It can solve my problem, but I want to see an idea , can use it by reference packages directly.

推荐答案

如何使用 xmldocument 安装 nuget 包

How can i install a nuget package with xmldocument

实际上,xml 文档可能位于 nuget.nupkg 文件夹中的 lib 文件夹中.但是,它只能导入到带有 的网络框架项目的输出文件夹中package.config nuget 管理格式.

Actually, the xml docuement could be in the lib folder in the nuget.nupkg folder. However, it is only be imported into output folder of a net framework project with packages.config nuget manage format.

如果您使用 PackageReference 在 net framework 项目中或安装到新的 sdk 项目(Net CoreNet Standard)中,xml 文档文件不会输出到项目的 bin 文件夹.

If you install your nuget package with PackageReference in a net framework project or install it into new sdk project(Net Core or Net Standard), the xml document file will not output to the project's bin folder.

所以我假设你的主要项目是一个网络核心项目.

另外,还有一个开放的github问题这反映了这种奇怪的行为 xxx.pdbxxx.xml 文件.

Also, there is an open github issue which reflects this strange behavior xxx.pdb and xxx.xml file.

所以我建议你可以使用 Content 和 ContentFiles 适合将此xml文档文件设置为所有类型项目的节点.

So I suggest you could use Content and ContentFiles node which is suitable for setting this xml document file into all types of projects.

请将这些节点添加到你的net标准类库项目的xxx.csproj文件中:

Please add these node in your xxx.csproj file of the net standard class library project:

<ItemGroup>
      <Content Include="xxxx\<project_name>.xml" (the path of the xml document file) Pack="true" PackagePath="content\any\any;contentFiles\any\any\;;">
      <PackageCopyToOutput>true</PackageCopyToOutput>         
      </Content>
  </ItemGroup>

然后你可以打包这个nuget项目(右键点击项目-->打包),当你在一个新项目中安装这个包时,它会在构建过程中将文档文件输出到主项目的输出文件夹中.

Then you can pack this nuget project(right-click on the projecy-->Pack) and when you install this package in a new project, it will output the document file in the output folder of the main project during build process.

这篇关于如何使用 xmldocument 安装 nuget 包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆