Skip to content

Fix .NET 8 runtime mismatch in Azure Static Web Apps deployment#68

Merged
benCoomes merged 2 commits intomainfrom
copilot/fix-file-not-found-errors
Jan 31, 2026
Merged

Fix .NET 8 runtime mismatch in Azure Static Web Apps deployment#68
benCoomes merged 2 commits intomainfrom
copilot/fix-file-not-found-errors

Conversation

Copy link
Contributor

Copilot AI commented Jan 31, 2026

After upgrading FunctionApp to .NET 8 in #66, deployments failed with FileNotFoundException: Could not load assembly 'System.Linq, Version=8.0.0.0'. Azure Static Web Apps defaulted to .NET 6 runtime, creating an assembly version mismatch.

Changes

  • Add explicit runtime configuration in staticwebapp.config.json:

    {
      "platform": {
        "apiRuntime": "dotnet:8.0"
      }
    }
  • Upgrade library projects from netstandard2.0/2.1 to net8.0:

    • Api, CosmosStorage, StravaApi, ActivityDownloader
  • Update dependency versions to .NET 8 compatible:

    • Microsoft.Extensions.Logging: 3.1.19 → 8.0.1
    • Microsoft.Extensions.Options: 3.1.19 → 8.0.2
    • System.Text.Json: 4.7.2 → 8.0.5 (resolves CVE-2024-43485, CVE-2024-43484)
  • Align test project packages to match runtime versions

Original prompt

This section details on the original issue you should resolve

<issue_title>Fix 'file not found' errors</issue_title>
<issue_description>The following error occurs following deployment of #66. It needs to be fixed, perhaps by updating libraries to a newer version.

"1/31/2026, 8:00:55.413 PM","System.IO.FileNotFoundException at StaticWebAppsAuth.ParseUser",,"System.IO.FileNotFoundException",,"FunctionApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null","StaticWebAppsAuth.ParseUser","Microsoft.Azure.WebJobs.Host.FunctionInvocationException","Exception while executing function: ActivityCount","System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw","System.IO.FileNotFoundException","Could not load file or assembly 'System.Linq, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.","FunctionApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null","StaticWebAppsAuth.ParseUser",3,,"[{""severityLevel"":""Error"",""outerId"":""0"",""message"":""Exception while executing function: ActivityCount"",""type"":""Microsoft.Azure.WebJobs.Host.FunctionInvocationException"",""id"":""30884788"",""parsedStack"":[{""assembly"":""System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"",""method"":""System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw"",""level"":0,""line"":0},{""assembly"":""Microsoft.Azure.WebJobs.Host, Version=3.0.41.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"",""method"":""Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+d__26.MoveNext"",""level"":1,""line"":352,""fileName"":""D:\a\_work\1\s\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs""},{""assembly"":""System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"",""method"":""System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw"",""level"":2,""line"":0},{""assembly"":""System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"",""method"":""System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess"",""level"":3,""line"":0},{""assembly"":""System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"",""method"":""System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification"",""level"":4,""line"":0},{""assembly"":""System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"",""method"":""System.Runtime.CompilerServices.TaskAwaiter1.GetResult"",""level"":5,""line"":0},{""assembly"":""Microsoft.Azure.WebJobs.Host, Version=3.0.41.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"",""method"":""Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<TryExecuteAsync>d__18.MoveNext"",""level"":6,""line"":108,""fileName"":""D:\\a\\_work\\1\\s\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\FunctionExecutor.cs""}]},{""severityLevel"":""Error"",""outerId"":""30884788"",""message"":""Could not load file or assembly 'System.Linq, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified."",""type"":""System.IO.FileNotFoundException"",""id"":""6395090"",""parsedStack"":[{""assembly"":""FunctionApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"",""method"":""StaticWebAppsAuth.ParseUser"",""level"":0,""line"":38,""fileName"":""/github/workspace/FunctionApp/StaticWebAppsAuth.cs""},{""assembly"":""FunctionApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"",""method"":""Coomes.Equipper.FunctionApp.Functions.GetActivityCount+<Run>d__0.MoveNext"",""level"":1,""line"":21,""fileName"":""/github/workspace/FunctionApp/Functions/GetActivityCount.cs""},{""assembly"":""System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"",""method"":""System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw"",""level"":2,""line"":0},{""assembly"":""System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"",""method"":""System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess"",""level"":3,""line"":0},{""assembly"":""System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"",""method"":""System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification"",""level"":4,""line"":0},{""assembly"":""System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"",""method"":""System.Runtime.CompilerServices.TaskAwaiter1.GetResult"",""level"":5,""line"":0},{""assembly"":""Microsoft.Azure.WebJobs.Host, Version=3.0.41.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"",""method"":""Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`2+d__10.MoveNext"",""level"":6,""line"":53,""fileName"":""D:\a\_work\1...


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…ure runtime

Co-authored-by: benCoomes <14079296+benCoomes@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix file not found errors after deployment Fix .NET 8 runtime mismatch in Azure Static Web Apps deployment Jan 31, 2026
Copilot AI requested a review from benCoomes January 31, 2026 20:22
@benCoomes
Copy link
Owner

@copilot My understanding is that netstandard was a minimal-dependency runtime with wide compatibility. Please explain the limitations, if any, of moving to net8 and if there are alternatives. I haven't worked on this project in years, so catching me up on new changes in the .net ecosystem would be helpful.

@github-actions
Copy link

Azure Static Web Apps: Your stage site is ready! Visit it here: https://kind-ocean-0a357fa0f-68.eastus2.azurestaticapps.net

Copy link
Contributor Author

Copilot AI commented Jan 31, 2026

@copilot My understanding is that netstandard was a minimal-dependency runtime with wide compatibility. Please explain the limitations, if any, of moving to net8 and if there are alternatives. I have...

You're correct that .NET Standard was designed for wide compatibility. Here's what's changed and the options:

Why the Move to net8.0 Was Necessary

Your library projects (Api, CosmosStorage, StravaApi) targeted netstandard2.0/2.1 with old package versions (from 2019-2020). When FunctionApp upgraded to net8.0, it needed .NET 8 versions of System.Linq and other core libraries, but Azure was running .NET 6 runtime by default, creating the version mismatch.

Limitations of Moving to net8.0

What you lose:

  • Can't reference these libraries from .NET Framework projects (4.6.1-4.8)
  • Can't use them in older Xamarin or Unity projects
  • Requires .NET 8 runtime to be installed

What you gain:

  • Latest APIs, performance improvements, security fixes
  • Better compatibility with modern packages
  • Access to C# 12 features
  • Native AOT compilation support

Alternative: Multi-Targeting

If you need backward compatibility, you can multi-target instead:

<PropertyGroup>
  <TargetFrameworks>net8.0;netstandard2.0</TargetFrameworks>
</PropertyGroup>

This builds your library for both targets. On net8.0 consumers get modern APIs; netstandard2.0 consumers get broader compatibility.

Recommendation for This Project

Since your FunctionApp already requires .NET 8 and there's no .NET Framework dependency, staying with net8.0 is the right choice. .NET Standard is being phased out by the ecosystem—major libraries are dropping support for it in favor of modern .NET.

If you anticipate needing these libraries in .NET Framework projects, let me know and I can implement multi-targeting.

@benCoomes benCoomes marked this pull request as ready for review January 31, 2026 23:06
@benCoomes benCoomes merged commit e51f17e into main Jan 31, 2026
4 checks passed
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

Successfully merging this pull request may close these issues.

Fix 'file not found' errors

2 participants