Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Failed to load assembly 'Microsoft.Extensions.Configuration'

beatriz.magalhaes
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 14, 2024

I have a pipeline for deployment in bitbucket. The last step of my pipeline is:          

 

dotnet lambda deploy-function --region eu-west-1 -pl ./Indexor/Lambdas/Provisioning/src/ --aws-access-key-id "${AWS_ACCESS_KEY_ID}" --aws-secret-key "${AWS_SECRET_ACCESS_KEY}" -fd "Deploy for commit ${BITBUCKET_COMMIT}" -frun provided.al2 -frole arn:aws:iam::476477924141:role/lambda_exec_Provision-0 -ft 30 -fms 4096 -fh "Prov::Prov.Function::FunctionHandler" -farch x86_64 --fn provisioning.

 

However, I am getting the following error: Failed to load assembly 'Microsoft.Extensions.Configuration'.

I do have this package on my project. Here is the .csproj:

 

 

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <AWSProjectType>Lambda</AWSProjectType>
    <AssemblyName>bootstrap</AssemblyName>
    <!-- This property makes the build directory similar to a publish directory and helps the AWS .NET Lambda Mock Test Tool find project dependencies. -->
    <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
    <!-- Generate Native AOT image during publishing to improve cold start time. -->
    <PublishAot>true</PublishAot>
    <!-- StripSymbols tells the compiler to strip debugging symbols from the final executable if we're on Linux and put them into their own file.
    This will greatly reduce the final executable's size.-->
    <StripSymbols>true</StripSymbols>
    <!-- TrimMode partial will only trim assemblies marked as trimmable. To reduce package size make all assemblies trimmable and set TrimMode to full.
    If there are trim warnings during build, you can hit errors at runtime.-->
    <TrimMode>partial</TrimMode>
  </PropertyGroup>
  <!--
  When publishing Lambda functions for ARM64 to the provided.al2 runtime a newer version of libicu needs to be included
  in the deployment bundle because .NET requires a newer version of libicu then is preinstalled with Amazon Linux 2.
  -->
  <ItemGroup Condition="'$(RuntimeIdentifier)' == 'linux-arm64'">
    <RuntimeHostConfigurationOption Include="System.Globalization.AppLocalIcu" Value="68.2.0.9" />
    <PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="68.2.0.9" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Amazon.Lambda.APIGatewayEvents" Version="2.7.1" />
    <PackageReference Include="Amazon.Lambda.RuntimeSupport" Version="1.10.0" />
    <PackageReference Include="Amazon.Lambda.Core" Version="2.2.0" />
    <PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.4.3" />
    <PackageReference Include="AWSSDK.Core" Version="3.7.400.5" />
    <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
    <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
    <PackageReference Include="Microsoft.Extensions.Options" Version="8.0.0" />
    <PackageReference Include="Microsoft.Extensions.Primitives" Version="8.0.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\..\..\Shared\QuickPlatform\src\QuickPlatform.csproj" />
  </ItemGroup>
  <ItemGroup>
    <RdXmlFile Include="rd.xml" />
  </ItemGroup>
</Project>
I am using .net8 and the Microsoft.Extensions.Configuration package is also referenced in other projects in the same version. I don't undestand what could be the issue and how can I fix it, so would appreciate some input.

1 answer

1 vote
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 15, 2024

Hello @beatriz.magalhaes ,

and welcome to the Community!

Based on the error message you shared, it seems the error is related to the framework/code rather than with Bitbucket Pipelines specifically.

Unfortunately I don't have much expertise in the .Net configuration, but I would recommend troubleshooting this issue locally following the steps outlined in the below article:

This would enable you to try different changes/solutions and once it works locally, you can update your pipelines YAML to match.

Additionally, I also noticed you're using .Net version 8. After a quick research I've found some other users reporting similar issue with that version in the below Github thread:

This thread contains some possible workaround/fixes that may be also applicable for the issue you're facing.

Thank you, @beatriz.magalhaes !

Patrik S

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events