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

Azure Functions netcore3.1 adding Assemblies Nuget.Packaging not found exception #10915

Closed
nehio opened this issue Jun 4, 2021 · 2 comments
Closed
Labels
Functionality:SDK The NuGet client packages published to nuget.org Resolution:External This issue appears to be External to nuget

Comments

@nehio
Copy link

nehio commented Jun 4, 2021

Nuget.Protocol 4.8.0.6 | Visual Studio 2019 16.9.5 | dotnet 3.1.15

Worked before NuGet version: Nuget.Protocol 4.7.3

I don't know if this issue is related to Azure Functions or Nuget itself but i'm trying to add some assemblies to the Azure Functions DLL library (Dependent on framework netcore3.1) :

            var assemblyParts = new List<AssemblyPart>();
            var assemblyNames = new[]
            {
                "netstandard",
                "Microsoft.AspNetCore.Html.Abstractions",
                "Microsoft.AspNetCore.Mvc.Abstractions",
                "Microsoft.AspNetCore.Mvc.Razor",
                "Microsoft.AspNetCore.Mvc.TagHelpers",
                "Microsoft.AspNetCore.Mvc.ViewFeatures",
                "Microsoft.AspNetCore.Razor",
                "Microsoft.AspNetCore.Razor.Runtime",
                "Microsoft.CSharp",
                "Microsoft.Extensions.Localization",
                "Microsoft.Extensions.Localization.Abstractions",
                "System.Collections",
                "System.Core",
                "System.Dynamic.Runtime",
                "System.Linq",
                "System.Linq.Expressions",
                "System.Private.CoreLib",
                "System.Runtime",
                "System.Text.Encodings.Web",
            };

            foreach (var assemblyName in assemblyNames)
            {
                var assemblyPart = new AssemblyPart(Assembly.Load(new AssemblyName(assemblyName)));
                assemblyParts.Add(assemblyPart);
            }

            Assembly assemblyViews;
            if (isDevelopment)
                assemblyViews = AssemblyLoadContext.Default.LoadFromAssemblyPath($"{Directory.GetCurrentDirectory()}\\Project.Views.dll");
            else
                assemblyViews = Assembly.Load(new AssemblyName("Project.Views"));
services.AddMvc()
                .ConfigureApplicationPartManager(apm =>
                {
                    // Assemblies System
                    apm.ApplicationParts.AddRange(assemblyParts);

                    // Assemblies
                    apm.ApplicationParts.Add(new AssemblyPart(MyAssembly));

                    var a = new CompiledRazorAssemblyApplicationPartFactory();

                    foreach (var b in a.GetApplicationParts(assemblyViews))
                        apm.ApplicationParts.Add(b);
                })
                .AddMvcLocalization()
                .AddDataAnnotationsLocalization();

This code fails with the following error on the services.AddMvc() call when adding everything :
image

I've also tried adding the dependency into the project for Nuget.Packaging without any success. Everything before 4.8 works like a charm, everything after crashes with the same error.

Thank you for any help on this and have a good day

@nkolev92
Copy link
Member

Hey @nehio,

Unfortunately I'm not sure I have enough context to offer any advice here.

I don't see anything of note that could cause this failure that changed between 4.7 and 4.8 of https://www.fuget.org/packages/NuGet.Protocol/4.8.0/lib/netstandard1.6/diff/4.7.3/.

Are you loading the assemblies directly yourself?
I'd recommend enabling fuslogvw and inspecting the logs.

@nkolev92 nkolev92 added Resolution:External This issue appears to be External to nuget Functionality:SDK The NuGet client packages published to nuget.org labels Jun 16, 2021
@zivkan
Copy link
Member

zivkan commented Jun 16, 2021

This is happening because of the Azure Functions SDK. See also:
#10118
Azure/azure-functions-host#6650
Azure/azure-functions-host#5894

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Functionality:SDK The NuGet client packages published to nuget.org Resolution:External This issue appears to be External to nuget
Projects
None yet
Development

No branches or pull requests

3 participants