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

Support .NET Standard 2.0 class libraries #1792

Closed
lindydonna opened this issue Aug 16, 2017 · 57 comments
Closed

Support .NET Standard 2.0 class libraries #1792

lindydonna opened this issue Aug 16, 2017 · 57 comments
Assignees
Milestone

Comments

@lindydonna
Copy link
Contributor

Now that .NET Standard 2.0 is RTM, we should include the facades that enable support on full framework. This is especially important once we port to .NET Core.

@solvingj
Copy link

The current impact seems to be that you actually cannot have any .NET Standard 2.0 library projects referenced in an Azure Function Project (which are framework v4.6.1) at this time. The act of simply referencing an empty Netstandard2.0 project causes a runtime failure of the functions. I don't know what the scope of scenarios are where this will/won't throw an exception.

@davidebbo
Copy link
Contributor

Yes, this is pretty bad and leads to very puzzling situations. We'll need to address it.

@solvingj
Copy link

Maybe just start by warning people the exciting new update of Netstandard 2.0 is currently strictly incompatible with azure functions since they won't get Nuget or Compiler warnings and will have to find out via obscure debugging like I did.

@solvingj
Copy link

David or Lindy, can you confirm that this would be an effective workaround for the HttpClient issue?
https://codopia.wordpress.com/2017/07/21/how-to-fix-the-assembly-binding-redirect-problem-in-azure-functions/

@fabiocav
Copy link
Member

@solvingj the above will not be effective. There would also be other issues you'd run into. We'll have an update, with hopefully a better ETA on the proper support, after this week's triage process (which is happening tomorrow).

@solvingj
Copy link

That's an outstanding update already, thank you so much for the feedback. Will look forward to tomorrow.

@solvingj
Copy link

@fabiocav any updates?

@fabiocav
Copy link
Member

Sorry, due to some conflicts this week, the triage process was pushed to tomorrow. We'll have an update then.

@gongdo
Copy link

gongdo commented Aug 30, 2017

I'm not sure is this a same problem, but I'm piling up my problem related with .NET Standard 2.0.
It seems that some .NET Standard 2.0 libraries break Web Jobs process somehow.
https://github.com/gongdo/ReproduceFunctionAppFailure

@fabiocav
Copy link
Member

@gongdo I just want to confirm, this happens when loading the LoggingLibraryDummyCore project/assemblies, correct? When referencing .NET Standard 2.0 assemblies, you'll run into those kinds of problems (they manifest differently depending on the scenario). We'll have that addressed this sprint and will update this issue when that is done.

@gongdo
Copy link

gongdo commented Aug 30, 2017

@fabiocav You can break down the problem to reproduce it like this:

  1. When LoggingFunctionApp have package reference to Microsoft.Extensions.Logging.Abstraction
  2. When LoggingFunctionApp have project reference to LoggingLibraryDummyCore which have package reference to Microsoft.Extensions.Logging.Abstraction

But To reference .NET 461 project works fine.

@dasMulli
Copy link

dasMulli commented Aug 30, 2017

Ad binding redirects: When a project targets .net framework and does not have <OutputType>Library</…>, automatic binding redirects generation is disabled in msbuild and needs to be enabled manually in the project file (the second property is important):

<PropertyGroup>
  <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
  <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>

@solvingj
Copy link

solvingj commented Aug 30, 2017

@dasMulli I'm hoping you've tested and this actually works. If so, i can re-try it. But if you've not tested yet, please read this thread and draw your own conclusions (and share it here). Mine was that I don't believe binding redirects work normally in the managed Azure App Service runtimes of webjobs and functions.

@dasMulli
Copy link

dasMulli commented Aug 30, 2017

Didn't work out that well for me 😬 thanks @solvingj for reminding me to keep my mouth shut until I actually confirm it works. Been looking at sort of similar issues at the moment (dotnet/msbuild#2481)

@solvingj
Copy link

I hope it didn't come off negatively, I didn't mean it that way, all suggestions should be welcome! I was actually hoping because I wanted something to work. TBH, I'm glad to see you're looking tbh. I feel like you might find a workaround while we wait :)

@solvingj
Copy link

solvingj commented Sep 6, 2017

FYI i just downloaded and installed an update to azure functions and webjobs tools. i still get the following at runtime when hitting my function (during local debug):

mscorlib: Exception while executing function: AgentsPost. API.Routing: Method not found: 'System.Net.Http.HttpResponseMessage System.Net.Http.HttpRequestMessageExtensions.CreateErrorResponse(System.Net.Http.HttpRequestMessage, System.Net.HttpStatusCode, System.String)'.

I'm not even positive that this error was one of the many targeted to be addressed in this sprint, but it's the error @davidebbo associated back to this ticket. Perhaps someone can confirm that this error is related to this ticket.

@fabiocav
Copy link
Member

fabiocav commented Sep 6, 2017

@solvingj this will be addressed in this sprint, with the same set of changes.

@fabiocav
Copy link
Member

Addressed by #1863

@solvingj
Copy link

Any ETA on release and availability?

@davidebbo
Copy link
Contributor

Hopefully today in one region, and then propagating over the next few days. If you have cycles to help us verify in the initial region by deploying a test site, that would help us validate.

@solvingj
Copy link

appany-testapp-01

@davidebbo
Copy link
Contributor

And to be clear, is that the app where you saw the issue, or the indirect app used to give me the other app's name?

@solvingj
Copy link

That's just the test app i created for this exercise. It's got the real code from my function app behind it.

@solvingj
Copy link

Also, important point... Kudu was able to pull in the latest commit to the original function-app deployed in Central US.

@davidebbo
Copy link
Contributor

Ok, I see that's the app where you deployed. Take a look at D:\home\LogFiles\kudu\trace in Kudu console, specifically the file that has Background_POST in its name. Seems something caused it to suddenly die.

I'm not sure what happened there, but it is most likely unrelated to this issue. Can you try just pushing again?

@solvingj
Copy link

Sure, just did "sync" again on the test app (project uses Github deploy).
As for the deployment in central region, looks like we're currently in good shape, reproducing the expected error:

"message": "Exception while executing function: ReposGet -> Method not found: 'System.Net.Http.HttpResponseMessage System.Net.Http.HttpRequestMessageExtensions.CreateErrorResponse(System.Net.Http.HttpRequestMessage, System.Net.HttpStatusCode, System.String)'."

@davidebbo
Copy link
Contributor

FYI, the deployment is now looking more like it'll start tomorrow and not today.

@davidebbo
Copy link
Contributor

Forgot to follow up yesterday, but the change is now live in West US 2 if you want to give it a try!

@dieterhowest
Copy link

Is there a SDK update because i have a Azure Function project that references a .NET Standard 2.0 library but i get the following message (see screenshot attached)

capture

@dersia
Copy link

dersia commented Sep 19, 2017

@dieterhowest your issue has nothing todo with netstandard2.0 support. Your issue basically comes from using a higher version of System.Runtime than is available on the host. You cloud try referencing version 4.2.0 in your project.json or change your assembly to use 4.1.2

@davidebbo
Copy link
Contributor

Note that the Azure App Service deploy I mentioned above is now complete.

@solvingj
Copy link

All regions or just West US 2?

@davidebbo
Copy link
Contributor

@solvingj All regions as of this morning. West US 2 was 4 days ago.

@joelhulen
Copy link

@davidebbo Great news! Have you guys released a new version of the SDK to address this issue while testing locally, yet?

@davidebbo
Copy link
Contributor

The npm core tools are out, but the VS extension is due soon. You can work around using https://stackoverflow.com/questions/46269046/azure-function-structure/46289792#46289792

@solvingj
Copy link

Can you clarify if it's weeks or months?

@davidebbo
Copy link
Contributor

@solvingj for the VS extension, days. Should be this week.

@dersia
Copy link

dersia commented Sep 25, 2017

I just tried to add a .netstandard 2.0 package to my function. Seems not to work, or did I miss anything?

{
  "frameworks": {
    "net46":{
      "dependencies": {
        "My.NetStandard20.Shared": "1.0.0-alpha-128",
        "Microsoft.Extensions.DependencyInjection": "2.0.0",
        "Microsoft.Extensions.Configuration": "2.0.0",
        "Microsoft.Extensions.Configuration.EnvironmentVariables": "2.0.0",
        "System.Diagnostics.TraceSource": "4.0.0.0",
        "System.Reflection.TypeExtensions": "4.0.0.0",
        "Microsoft.Extensions.Logging": "2.0.0",
        "Microsoft.Extensions.Logging.Console": "2.0.0"
      }
    }
   }
}

here is the log:

2017-09-25T17:38:30.061 Errors in D:\home\site\wwwroot\myfunction\project.json
2017-09-25T17:38:30.061 Package My.NetStandard20.Shared 1.0.0-alpha-128 is not compatible with net46 (.NETFramework,Version=v4.6). Package My.NetStandard20.Shared 1.0.0-alpha-128 supports: netstandard2.0 (.NETStandard,Version=v2.0)
2017-09-25T17:38:30.061 Package Microsoft.Extensions.DependencyInjection 2.0.0 is not compatible with net46 (.NETFramework,Version=v4.6). Package Microsoft.Extensions.DependencyInjection 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0)
2017-09-25T17:38:30.061 Package Microsoft.Extensions.Configuration 2.0.0 is not compatible with net46 (.NETFramework,Version=v4.6). Package Microsoft.Extensions.Configuration 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0)
2017-09-25T17:38:30.061 Package Microsoft.Extensions.Configuration.EnvironmentVariables 2.0.0 is not compatible with net46 (.NETFramework,Version=v4.6). Package Microsoft.Extensions.Configuration.EnvironmentVariables 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0)
2017-09-25T17:38:30.061 Package Microsoft.Extensions.Logging 2.0.0 is not compatible with net46 (.NETFramework,Version=v4.6). Package Microsoft.Extensions.Logging 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0)
2017-09-25T17:38:30.061 Package Microsoft.Extensions.Logging.Console 2.0.0 is not compatible with net46 (.NETFramework,Version=v4.6). Package Microsoft.Extensions.Logging.Console 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0)
2017-09-25T17:38:30.061 One or more packages are incompatible with .NETFramework,Version=v4.6.

@fabiocav
Copy link
Member

@dersia that is a known issue. We'll be addressing that as part of the move from project.json to the MSBuild format. You can track this here.

We're maintaining a list of known issues here.

@dersia
Copy link

dersia commented Sep 25, 2017

@fabiocav ok, great is there any workaround?

@fabiocav
Copy link
Member

No great workarounds at this point, but this shouldn't take long.

@aolear
Copy link

aolear commented Sep 25, 2017

we're running into the same thing on our team - thanks in advance for the fix!

@dersia
Copy link

dersia commented Sep 28, 2017

@fabiocav just to make sure, so loading netstandard2.0 from nuget is a problem, but uploading those to let's say the bin and then referencing with #r "../bin/mypackage.dll" should work?

@fabiocav
Copy link
Member

@dersia yes, that should work as expected.

@dersia
Copy link

dersia commented Sep 28, 2017

unfortunately it doesn't:

Function ($readmodeljob-service) Error: Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.

image

I'm referencing my own netstandard2.0 package in the script

@fabiocav
Copy link
Member

This could also be caused by a failed dependency. If you have a simple repro and could open a separate issue with the details so it's tracked, I'll take a look at this.

@dersia
Copy link

dersia commented Sep 28, 2017

ok, repro is in #1972

@jmevel
Copy link

jmevel commented Sep 11, 2018

I think this is still not fixed.

I have an Azure Functions project referencing a .NET Standard 2.0 project. My .NET Standard project references Microsoft.Extensions.Logging.Abstractions 2.1.1.

When I debug the project in Visual Studio I get the error

Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The system cannot find the file specified.

Notice the version number 2.0.1.0 different from version 2.1.1 I'm referencing in the .NET Standard Nuget package
I have no idea why it is looking for this version, I've zero result for the string 2.0.1 in my entire solution

I thought I was again in one of these binding redirects issues. So I changed the target Framework version of my Azure Functions project to 4.7.2 which is supposed to be the version fixing all the binding redirects issue when referencing a .NET Standard project.

But this didn't solve the problem. So I also tried to install the Microsoft.Extensions.Logging.Abstractions Nuget package version 2.0.1 in a separate .NET Framework Console Application.

I copied the Microsoft.Extensions.Logging.Abstractions.dll (I verified with ildasm.exe it's version 2.0.1) to the bin folder of my Azure Functions project but still the same error.

And this is actually not the only DLL causing problems. My Azure Functions project also references another .NET Standard project which has a dependency to System.Data.SqlClient and I get the same issue.

So I'm confused on why this issue has been closed and supposed to be fixed. On my side it's clearly not fixed.
Anyone has a workaround?

Thank you

@ghost ghost locked as resolved and limited conversation to collaborators Jan 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests