question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Building version 4.0.3971 no longer works without patch

See original GitHub issue

When attempting to build version 4.0.3971 with build.sh, an error occurs:

/root/azure-functions-cli-source/azure-functions-core-tools-4.0.3971/test/Azure.Functions.Cli.Tests/Azure.Functions.Cli.Tests.csproj : warning NU1701: Package 'FSharp.Core 3.1.2.5' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework 'net6.0'. This package may not be fully compatible with your project. [/root/azure-functions-cli-source/azure-functions-core-tools-4.0.3971/Azure.Functions.Cli.sln]
/root/azure-functions-cli-source/azure-functions-core-tools-4.0.3971/test/Azure.Functions.Cli.Tests/Azure.Functions.Cli.Tests.csproj : warning NU1701: Package 'Suave 1.1.3' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework 'net6.0'. This package may not be fully compatible with your project. [/root/azure-functions-cli-source/azure-functions-core-tools-4.0.3971/Azure.Functions.Cli.sln]
/root/azure-functions-cli-source/azure-functions-core-tools-4.0.3971/test/Azure.Functions.Cli.Tests/Azure.Functions.Cli.Tests.csproj : warning NU1701: Package 'SuaveServerWrapper 0.0.3' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework 'net6.0'. This package may not be fully compatible with your project. [/root/azure-functions-cli-source/azure-functions-core-tools-4.0.3971/Azure.Functions.Cli.sln]
/root/azure-functions-cli-source/azure-functions-core-tools-4.0.3971/test/Azure.Functions.Cli.Tests/Azure.Functions.Cli.Tests.csproj : error NU1605: Detected package downgrade: Microsoft.ApplicationInsights from 2.20.0 to 2.18.0. Reference the package directly from the project to select a different version.  [/root/azure-functions-cli-source/azure-functions-core-tools-4.0.3971/Azure.Functions.Cli.sln]
/root/azure-functions-cli-source/azure-functions-core-tools-4.0.3971/test/Azure.Functions.Cli.Tests/Azure.Functions.Cli.Tests.csproj : error NU1605:  Azure.Functions.Cli.Tests -> Microsoft.Azure.Functions.CoreTools -> Microsoft.Azure.WebJobs.Script.WebHost 4.0.1 -> Microsoft.Azure.WebJobs.Script 4.0.1 -> Microsoft.Azure.WebJobs.Script.Abstractions 1.0.3-preview -> Microsoft.ApplicationInsights (>= 2.20.0)  [/root/azure-functions-cli-source/azure-functions-core-tools-4.0.3971/Azure.Functions.Cli.sln]
/root/azure-functions-cli-source/azure-functions-core-tools-4.0.3971/test/Azure.Functions.Cli.Tests/Azure.Functions.Cli.Tests.csproj : error NU1605:  Azure.Functions.Cli.Tests -> Microsoft.Azure.Functions.CoreTools -> Microsoft.ApplicationInsights (>= 2.18.0) [/root/azure-functions-cli-source/azure-functions-core-tools-4.0.3971/Azure.Functions.Cli.sln]
/root/azure-functions-cli-source/azure-functions-core-tools-4.0.3971/src/Azure.Functions.Cli/Azure.Functions.Cli.csproj : error NU1605: Detected package downgrade: Microsoft.ApplicationInsights from 2.20.0 to 2.18.0. Reference the package directly from the project to select a different version.  [/root/azure-functions-cli-source/azure-functions-core-tools-4.0.3971/Azure.Functions.Cli.sln]
/root/azure-functions-cli-source/azure-functions-core-tools-4.0.3971/src/Azure.Functions.Cli/Azure.Functions.Cli.csproj : error NU1605:  Microsoft.Azure.Functions.CoreTools -> Microsoft.Azure.WebJobs.Script.WebHost 4.0.1 -> Microsoft.Azure.WebJobs.Script 4.0.1 -> Microsoft.Azure.WebJobs.Script.Abstractions 1.0.3-preview -> Microsoft.ApplicationInsights (>= 2.20.0)  [/root/azure-functions-cli-source/azure-functions-core-tools-4.0.3971/Azure.Functions.Cli.sln]
/root/azure-functions-cli-source/azure-functions-core-tools-4.0.3971/src/Azure.Functions.Cli/Azure.Functions.Cli.csproj : error NU1605:  Microsoft.Azure.Functions.CoreTools -> Microsoft.ApplicationInsights (>= 2.18.0) [/root/azure-functions-cli-source/azure-functions-core-tools-4.0.3971/Azure.Functions.Cli.sln]
    3 Warning(s)
    2 Error(s)

It appears that the culprit is Microsoft.Azure.WebJobs.Script.WebHost, version 4.0.1, which has somehow been updated to use Microsoft.ApplicationInsights version 2.20.0 instead of 2.18.0. The major concern here is that this used to not be the case, and version 4.0.1 may have been overriden with a force-push to the NuGet package repository.

To me, this is very dangerous and concerning. Not only does it break this build, it goes against fundamental best practices that Nuget package versions should really be immutable.

Repro steps

Provide the steps required to reproduce the problem:

You may easily reproduce this issue with the following Dockerfile:

# syntax=docker/dockerfile:1
FROM mcr.microsoft.com/dotnet/sdk:6.0.100

# Install .NET Core 6.0 SDK
RUN apt-get update && \
    apt-get -y install wget unzip && \
    wget -q https://github.com/Azure/azure-functions-core-tools/archive/refs/tags/4.0.3971.zip -O azfunctions.zip && \
    unzip -d /root/azure-functions-cli-source azfunctions.zip

WORKDIR "/root/azure-functions-cli-source/azure-functions-core-tools-4.0.3971"

RUN dotnet build Azure.Functions.Cli.sln && \
    dotnet publish src/Azure.Functions.Cli/Azure.Functions.Cli.csproj --output /root/azure-functions-cli

Workaround

Create a patch file named 0001-app-insights-2.20.0.diff with the following contents:

From 62151049dca39ee44bd45eb1b511d7a14e8cb5d5 Mon Sep 17 00:00:00 2001
From: Anthony Iacono <anthonyiacono@gmail.com>
Date: Fri, 11 Mar 2022 12:25:43 -0500
Subject: [PATCH] Patch: Upgrade Microsoft.ApplicationInsights from 2.18.0 to
 2.20.0

---
 src/Azure.Functions.Cli/Azure.Functions.Cli.csproj | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Azure.Functions.Cli/Azure.Functions.Cli.csproj b/src/Azure.Functions.Cli/Azure.Functions.Cli.csproj
index 426bdc3..32077c5 100644
--- a/src/Azure.Functions.Cli/Azure.Functions.Cli.csproj
+++ b/src/Azure.Functions.Cli/Azure.Functions.Cli.csproj
@@ -149,7 +149,7 @@
     <PackageReference Include="Colors.Net" Version="1.1.0" />
     <PackageReference Include="AccentedCommandLineParser" Version="2.0.0" />
     <PackageReference Include="DotNetZip" Version="1.13.3" />
-    <PackageReference Include="Microsoft.ApplicationInsights" Version="2.18.0" />
+    <PackageReference Include="Microsoft.ApplicationInsights" Version="2.20.0" />
     <PackageReference Include="Microsoft.AspNetCore.DataProtection" Version="2.2.0" />
     <PackageReference Include="Microsoft.Azure.DurableTask.AzureStorage.Internal" Version="1.4.0" />
     <PackageReference Include="Microsoft.Azure.WebJobs.Script.WebHost" Version="4.0.1" />
-- 
2.31.0

Update the Dockerfile:

# syntax=docker/dockerfile:1
FROM mcr.microsoft.com/dotnet/sdk:6.0.100

# Install .NET Core 6.0 SDK
RUN apt-get update && \
    apt-get -y install wget unzip && \
    wget -q https://github.com/Azure/azure-functions-core-tools/archive/refs/tags/4.0.3971.zip -O azfunctions.zip && \
    unzip -d /root/azure-functions-cli-source azfunctions.zip

WORKDIR "/root/azure-functions-cli-source/azure-functions-core-tools-4.0.3971"

COPY 0001-app-insights-2.20.0.diff .

RUN git apply 0001-app-insights-2.20.0.diff

RUN dotnet build Azure.Functions.Cli.sln && \
    dotnet publish src/Azure.Functions.Cli/Azure.Functions.Cli.csproj --output /root/azure-functions-cli

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
pragnagopacommented, Mar 14, 2022

@TsuyoshiUshio - can you take a look at this?

cc @CooperLink

0reactions
RealGoodAnthonycommented, Jun 5, 2022

Sorry to bug everyone, but I wanted to bump this @fabiocav @brettsam @madelinegordon @pragnagopa

Read more comments on GitHub >

github_iconTop Results From Across the Web

Building version 4.0.3971 no longer works without patch
It appears that the culprit is Microsoft.Azure.WebJobs.Script.WebHost , version 4.0.1 , which has somehow been updated to use Microsoft.
Read more >
Unable to upgrade Azure Functions Core Tools, Exception ...
The solution was: Close Visual Studio; Delete folder C:\Users\***\AppData\Local\AzureFunctionsTools; Restart Visual Studio.
Read more >
Debugger does not work with Azure Functions .net5.0+ on ...
Azure Function Core Tools Version: 4.0.3971 ... NET Core 5.0, 6.0 - Debugger does not start, app is immediately closed. Functions worker is...
Read more >
How to send SMS with C# .NET and Azure Functions using ...
Make sure the new shell is not opened inside the Azurite folder. Create an Azure Function. It's time to start developing your Azure...
Read more >
What is this error? PermissionError: [Errno 1] Operation not ...
I am working on the Mac OS with VS code. I have written a init.py file but I am getting an error For...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found