How do you copy files into Azure Function bin folder?(如何将文件复制到Azure Function bin文件夹?)
问题描述
背景:
我有一个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 Studios构建azure函数时,它会创建以下文件夹结构。(请原谅我糟糕的插图)
bin/
| - Debug/
| | -bin /
| | | runtimes/
| | - function1/
| | | - ...
...
---
调试位于System.Configuration.ConfigurationManager.dll/文件夹中,而不是二级bin文件夹中。当构建并查看相应的DLL文件时,我可以看到它被填充到第二个bin文件夹中,但后来在Azure Function项目启动之前被删除。
现在,当我关闭本地运行时,将System.Configuration.ConfigurationManager.dll添加回第二个bin文件夹,一切都运行得很好!
实际问题(请帮助!)
问题1:有没有办法显式地告诉Visual Studio将DLL输出到第二个bin文件夹中?我已经尝试了以下方法...- GeneratePathProperty=";true";
- Copy_PASS0
- 所有堆栈溢出
感谢大家的帮助!
推荐答案
任务远程运行依赖项由目标运行_FunctionsBuildCleanOutput为known to purge assemblies too aggressively。
解决方法是完全关闭任务(并接受更大规模的部署),方法是设置:
<_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
跟踪工作项以进行更精细的切换:https://github.com/Azure/azure-functions-host/issues/5894
这篇关于如何将文件复制到Azure Function bin文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何将文件复制到Azure Function bin文件夹?


- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- 输入按键事件处理程序 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01