C# 如何将文件复制到Azure Function bin文件夹中?

C# 如何将文件复制到Azure Function bin文件夹中?,c#,asp.net-core,azure-functions,system.configuration,netcoreapp3.1,C#,Asp.net Core,Azure Functions,System.configuration,Netcoreapp3.1,背景: '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.' 我有一个Azure Function C#项目运行

背景:

'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.'
我有一个Azure Function C#项目运行在netcoreapp3.1和Azure v3版本中。这是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>
可疑原因:

'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.'
问题是,当通过Visual Studio构建azure功能时,它会创建以下文件夹结构。(请原谅我可怕的说明)

System.Configuration.ConfigurationManager.dll位于Debug/文件夹中,而不是第二级bin文件夹中。当构建和查看相应的dll文件时,我可以看到它正在第二个bin文件夹中填充,但随后在Azure功能项目启动之前被删除

现在,当我关闭本地运行时,将System.Configuration.ConfigurationManager.dll添加回第二个bin文件夹中,一切正常

实际问题(请帮助!)

问题1:有没有一种方法可以明确地告诉VisualStudio将dll输出到第二个bin文件夹中?我已经试过以下方法了

  • GeneratePathProperty=“true”
  • 复制\u PASS0
  • 所有的水都溢出来了
问题2:是否有更好的方法引用此必需的dll?我已经试过nuget控制台,但没有成功


谢谢你们的帮助

由目标运行的任务RemoveUntimeDependencies\u FunctionsBuildCleanOutput是

解决方法是通过设置以下各项完全关闭任务(并接受较大的部署):

<_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
true

跟踪工作项以获得更精确的切换:

此设置应添加到嵌套在
部分的csproj文件中。它解决了与Newtonsoft.Json相关的版本问题