背景:
我有一个在 netcoreapp3.1 和 azure 版本 v3 中运行的 Azure 函数 C# 项目。这是 csproj 的一个片段...
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyName>someproj</AssemblyName>
<RootNamespace>someproj</RootNamespace>
<Product>someproduct</Product>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<RunPublishAfterBuild>true</RunPublishAfterBuild>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.15.0" />
<PackageReference Include="Microsoft.Applications.Telemetry.Server">
<Version>1.1.264</Version>
<NoWarn>NU1701</NoWarn>
</PackageReference>
<PackageReference Include="System.Configuration.ConfigurationManager" Version="5.0.0-preview.8.20407.11">
<NoWarn>NU1701</NoWarn>
</PackageReference>
</ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
运行后异常:
'Could not load file or assembly 'System.Configuration.ConfigurationManager,
Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one
of its dependencies. The system cannot find the file specified.'
Run Code Online (Sandbox Code Playgroud)
怀疑原因:
问题是在通过 Visual Studios 构建 azure 函数时,它会创建以下文件夹结构。(原谅我可怕的插图)
bin/
| - Debug/
| | -bin …Run Code Online (Sandbox Code Playgroud) c# system.configuration asp.net-core azure-functions netcoreapp3.1