Loading nuget packages at runtime

328 Views Asked by At

i have a problem during test execution. So i have a docker file and inside i´m running "dotnet test". It uses IronPDf and IronPdf needs the package IronPdf.Native.Chrome.Linux/2022.3.5075'. It is alredy defined as a dependency in csproj, still IronPdf tries to load it at runtime. This results in an error because .net is trying to load it from nuget.org. In our environment we need to load it from a private feed. Therefore i´m using a NuGet.Config where that private feed is defined. I´m using the --configFile parameter to point to the correct NuGet.Config file during "dotnet restore" and "dotnet build". Unfortually dotnet test does not allow that parameter.

  1. How can i find out which Nuget.config file is used for runtime package loading and how can i set the correct feed ?

  2. Why the nuget package loaded uring dotnet restore is not used ? Thanks.

  Error Message:
   IronPdf.Exceptions.IronPdfDeploymentException : Failed downloading NuGet package at runtime from 'https://www.nuget.org/api/v2/package/IronPdf.Native.Chrome.Linux/2022.3.5075'.  Please add 'IronPdf.Native.Chrome.Linux version 2022.3.5075' Nuget package to your .NET project.
<PackageReference Include="IronPdf.Linux" Version="2022.3.5084" Condition="$([MSBuild]::IsOsPlatform('Linux'))" />
<PackageReference Include="IronPdf.Native.Chrome.Linux" Version="2022.3.5075" Condition="$([MSBuild]::IsOsPlatform('Linux'))" />

I´m not sure why IronPdf is trying to load the packages on runtime. I already checked the restore command with a verbose flag. The packages are actually restored:

       GET https://.../artifactory/api/nuget/v3/nuget-org/registration-semver2/Download/ironpdf.native.chrome.linux/2022.3.5075
       GET https://.../artifactory/api/nuget/v3/nuget-org/registration-semver2/Download/ironpdf.linux/2022.3.5084
1

There are 1 best solutions below

0
On

Attempting to download dependencies at runtime was a fallback in earlier 2022 versions of IronPdf, triggered when either:

  1. The runtimes folder could not be detected in expected locations
  2. Deployment failed due to a permissions issue.

The error message you're seeing:

IronPdf.Exceptions.IronPdfDeploymentException : Failed downloading NuGet package at runtime

is the last exception displayed in a chain, obscuring the underlying cause. This was common in secured environments, so was changed in later releases.

To resolve, you can:

  • Enable debugging:
IronPdf.Logging.Logger.EnableDebugging = true;
IronPdf.Logging.Logger.LogFilePath = "Default.log"; //May be set to a directory name or full file
IronPdf.Logging.Logger.LoggingMode = IronPdf.Logging.Logger.LoggingModes.All;

The log file will reveal the underlying cause (with the most common reasons being detailed in the linked articles above).