dotnet restore on linux does not include XML file from nuget package

1.4k Views Asked by At

I have a Visual Studio solution and am trying to build to run on a Linux installation of Docker. As part of the process I need to copy the XML documentation from one of the nuget packages for my Swagger documentation. On my windows development box, I am able to do this, but on Linux it is not working. The problem seems to be when I look at the lib folder for the nuget package on linux I see only a .dll while on Windows I see both .dll and .xml. Below is my restore command

RUN dotnet restore "src/Management/Management.csproj"

Why is the XML file not being extracted on linux?

On another note it seems like linux creates the directories using all lower case. So if I am extracting nuget package Test.MyPackage-3.4.3 it will be located on linux at /root/.nuget/.../test.mypackage/3.4.3. In my csproj file I am referencing the package using %(PackageReference.Identity) which returns the camel-case capitalization. Is there a work-around for this as well?

1

There are 1 best solutions below

0
On

Not sure if it's still a relevant question.

There is an Env variable NUGET_XMLDOC_MODE which is set to skip in Docker image provided by Microsoft.

If you change it to ENV NUGET_XMLDOC_MODE=none in your Dockerfile it will fix the issue. However image build time will definitely increase so you can consider having dotnet restore as a separate step to enable caching.

More info can be found here https://learn.microsoft.com/en-us/nuget/reference/cli-reference/cli-ref-environment-variables