Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Could not load file or assembly" error with Nuget package when using SDK version >3.0.3 #427

Closed
hudec117 opened this issue May 24, 2020 · 12 comments

Comments

@hudec117
Copy link

Description

When attempting to use the System.IO.Abstractions Nuget package with Azure Functions I receive the following error:

System.Private.CoreLib: Exception while executing function: TimerTriggerCSharp1. az-pack-test: Could not load file or assembly 'System.IO.Abstractions, Version=11.0.0.0, Culture=neutral, PublicKeyToken=96bf224d23c43e59'. The system cannot find the file specified.

Steps to reproduce:

  1. Clone sample repo https://github.com/hudec117/az-pack-test
  2. Restore dependencies.
  3. run function app func start --build
  4. Observe "Could not load file or assembly" error.
  5. Observe the System.IO.Abstractions DLL is not copied to build output.

Workaround:

  1. Downgrade Microsoft.NET.Sdk.Functions package to 3.0.3
  2. Restore dependencies.
  3. Run function app.
  4. Observe no error.
  5. Observe the System.IO.Abstraction DLL is copied to build output.

Versions:

  • .NET SDK 3.1.300
  • Azure Functions Core Tools 3.0.2534
  • Function Runtime Version: 3.0.13353.0

Notes:

  • Project was created using the Azure Functions extension in Visual Studio Code.
  • TimerTriggerCSharp1 references System.IO.Abstractions and attempts to use functionality from it. If it this commented out, the function app starts without error.
@HermanCordes
Copy link

We're currently running into the same issue. We also the System.IO.Abstractions NuGet package. However for us it seems that the Microsoft.NET.Sdk.Functions 3.0.3 is working, while 3.0.4 onwards introduces the problem.

@mkallsgard
Copy link

Same issue, but getting the error
"Could not load file or assembly 'System.Interactive.Async, Version=4.1.0.0."

nuget package with the reference will start working when downgrading Microsoft.NET.Sdk.Functions to 3.0.3

@josefblaha
Copy link

Probably the same issue as Azure/azure-functions-host#5894. There is also a workaround.

@LandryDubus
Copy link

LandryDubus commented Jun 22, 2020

I get the same problem.
With Microsoft.NET.Sdk.Functions >= 3.0.4, some dlls from nuget references (direct or indirect) are missing from the bin folder upon build.
This is working just fine with version 3.0.3

@dnl1
Copy link

dnl1 commented Aug 12, 2020

I was facing the same problem, but only when running Azure Function with Container, the function host doesnt even start, I downgraded Microsoft.NET.Sdk.Functions to 3.0.3 version and now is running ok, I'm still getting 500 at function endpoint, only on AZ Function running in a Container gets error (without is ok)

@adamjames
Copy link

I had the same issue with referencing System.IO.Abstractions. For us it was being referenced by a second nuget package on which the function depends. Downgrading fixed the problem.

We thought it may have been related to the dependency possibly being transient with respect to the function, but even directly adding a reference to the package directly didn't resolve it, so it was quite the head-scratcher. Creating a new azure function pulled in the 3.0.3 version of the SDK, which worked without any other changes - then we realised where we'd gone wrong.

@morrisonbrett
Copy link

Is there a way to use Microsoft.NET.Sdk.Functions latest and greatest and do a binding redirect to System.IO.Abstractions?

@morrisonbrett
Copy link

I got past it! THIS fixed it for me. Add this to a <PropertyGroup> in your .csproj.

<_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>

@morrisonbrett
Copy link

Cross Reference: TestableIO/System.IO.Abstractions#761

@liliankasem
Copy link
Member

Should have been resolved with this PR, please reopen if still facing the same issue!

@RenFontes
Copy link

RenFontes commented Sep 6, 2022

<_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>

Thank you so much :))

@RenFontes
Copy link

This is still happening btw, should it be reopened?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants