-1

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.

Lennart
  • 9,657
  • 16
  • 68
  • 84
menxin
  • 2,044
  • 1
  • 17
  • 15
  • Sorry, but what does _modules (dlls) xml document_ mean? – Pavel Anikhouski Jul 13 '20 at 15:52
  • @PavelAnikhouski it means moduleA.dll ,moduleA.xml – menxin Jul 13 '20 at 15:56
  • https://stackoverflow.com/questions/52891727 – menxin Jul 13 '20 at 16:11
  • https://github.com/dotnet/sdk/issues/9498 – menxin Jul 13 '20 at 17:22
  • Is your class library a net standard project or net framework project? – Mr Qian Jul 14 '20 at 02:16
  • @PavelAnikhouski,Yes,it is a .netstandard2.0 project. – menxin Jul 14 '20 at 02:22
  • @menxin, what did you mean? Did you want to use a post-build event to copy all the indeed xml documents into a folder and then pack them into the nuget package? – Mr Qian Jul 14 '20 at 09:41
  • And when you use my function, it is actually as content in the solution explorer of the project. – Mr Qian Jul 14 '20 at 09:42
  • Are you sure you mean `XmlDocument` (https://learn.microsoft.com/en-us/dotnet/api/system.xml.xmldocument?view=netcore-3.1)? Because thats a class structure to deal with XML-files and makes little sense to me in context of the question. – Lennart Jul 14 '20 at 09:45
  • @menxin ,When you install that package, the related xml document exists under the outputpath of the main project. Then you can use `XmlDocument` to load the file from the outputpath of your main project.And for net core projects, we cannot use the `xxx.xml` file directly and shoud import them in the main project. I think you could have a try on my answer. Also,more detailed points should be explained if I misunderstand your issue. Look forward to hearing from you. – Mr Qian Jul 14 '20 at 10:08
  • @Lennart , it is xml documentation comments, sorry , hhaha ,my english..... – menxin Jul 14 '20 at 13:34

1 Answers1

2

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="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.

Mr Qian
  • 21,064
  • 1
  • 31
  • 41