Azure-functions-vs-build-sdk: NuGet.Protocol disappears from bin in version 3.0.4 or greater

Created on 18 Apr 2020  路  2Comments  路  Source: Azure/azure-functions-vs-build-sdk

Repro steps

  1. Open Visual Studio (I have 16.5.3)
  2. Create a new Azure Function project.
  3. Install the latest version of NuGet.Protocol (I have 5.5.1)
  4. Update the Microsoft.NET.Sdk.Functions package to 3.0.4 (My template had 3.0.3)
  5. Add a bit of code to reference the package.
  6. Start the function locally (Ctrl+ F5)

This is the code I used.

using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using NuGet.Protocol;
using NuGet.Protocol.Core.Types;

namespace WhyNoNuGet
{
    public static class Function1
    {
        [FunctionName("Function1")]
        public static async Task<IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req)
        {
            var repository = Repository.Factory.GetCoreV3("https://api.nuget.org/v3/index.json");
            await repository.GetResourceAsync<FindPackageByIdResource>();
            return new OkObjectResult("Done.");
        }
    }
}

Excepted

App should start, and find NuGet.Protocol.

This is what I see when I am using Microsoft.NET.Sdk.Functions 3.0.3:

image

NuGet.Protocol should be in the bin directory.

image

Actual

The app shows error on start-up with 3.0.4, 3.0.5, and 3.0.6 (I tried them all)

image

[4/18/2020 8:51:43 AM] The 'Function1' function is in error: Unable to load one or more of the requested types.
[4/18/2020 8:51:43 AM] Could not load file or assembly 'NuGet.Protocol, Version=5.5.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
[4/18/2020 8:51:43 AM] Microsoft.Azure.WebJobs.Host: Error indexing method 'Function1'. System.Private.CoreLib: Could not load file or assembly 'NuGet.Protocol, Version=5.5.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.

Note that the bin directory is much more empty with 3.0.4 and on (note there is no NuGet.Protocol)
image

Needs Triage (Functions)

Most helpful comment

I had the exact same problem with Microsoft.NET.Sdk.Functions 3.0.9 and NuGet.Protocol 5.8.0.
The workaround suggested in Azure/azure-functions-host#5894 did help:

<PropertyGroup>
    <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
  </PropertyGroup>

Thanks a lot @simonness :+1:

All 2 comments

@joelverhagen I bumped into a very similar issue, see https://github.com/Azure/azure-functions-host/issues/5894 for a temporary workaround.

I had the exact same problem with Microsoft.NET.Sdk.Functions 3.0.9 and NuGet.Protocol 5.8.0.
The workaround suggested in Azure/azure-functions-host#5894 did help:

<PropertyGroup>
    <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
  </PropertyGroup>

Thanks a lot @simonness :+1:

Was this page helpful?
0 / 5 - 0 ratings