繁体   English   中英

如何使用 xmldocument 安装 nuget package

[英]How can i install a nuget package with xmldocument

我的项目依赖于一些模块(nuget 包),我在包中打包了 xml 文档。

当我将它们安装打包时,模块的 xmldocument 文件不在我的文件夹中。 I renamed a .nupkg file to .zip , unzip it,.xml (xmldocument) is in the zip package.

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

更新:

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

现在,我的方法是使用构建后事件将.xml文件更新到一个文件夹。它可以解决我的问题,但我想看看一个想法,可以通过参考包直接使用它。

如何使用 xmldocument 安装 nuget package

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

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文件。

因此,我建议您可以使用适合将此 xml 文档文件设置到所有类型的项目中的Content 和 ContentFiles节点。

请在您的网络标准 class 库项目的 xxx.csproj 文件中添加这些节点:

<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>

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.

暂无
暂无

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

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