Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
286 views
in Technique[技术] by (71.8m points)

.net - How can i install a nuget package with xmldocument

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

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.

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

Update:

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.

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

How can i install a nuget package with xmldocument

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.

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.

So I assume your main project is a net core project.

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

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

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="contentanyany;contentFilesanyany;;">
      <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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...