gpt4 book ai didi

c# - Visual Studio 在发布时将 .dll 复制到 Bin 文件夹

转载 作者:行者123 更新时间:2023-12-03 03:49:34 31 4
gpt4 key购买 nike

我遇到以下问题。

我创建了一个 Azure 函数,并希望运行存储在 {ProjectFile}/AlCompiler 中的编译器文件夹。

该文件夹包含.dllalc.exe文件。 exe 文件需要这些 .dll 才能运行,否则会产生错误。

我尝试将 AlCompiler 文件夹的文件发布到 wwwroot 目录将以下内容添加到 .csproj 项目文件中:

<ItemGroup>
<Content Include="AlCompiler/**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

我也尝试了这个标记:

<ItemGroup>
<ContentWithTargetPath Include="AlCompiler/**">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<TargetPath>AlCompiler\%(Filename)%(Extension)</TargetPath>
</ContentWithTargetPath>
</ItemGroup>

并尝试使用<Link>属性:

<ItemGroup>
<Content Include="AlCompiler/**">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<Link>AlCompiler\%(Filename)%(Extension)</Link>
</Content>
</ItemGroup>

所有这些都会导致 AlCompiler 目录的文件在发布时被分割:

  • exe 和其他一些文件转到 wwwroot/AlCompiler 文件夹
  • 所有 .dll 均位于 wwwroot/bin/AlCompiler 文件夹

我没有找到任何方法将它们保留在一个地方。

由于 .dll 丢失,我无法运行 alc.exe 文件。

我非常高兴您能提供帮助!

最佳答案

您应该在 .csproj 中使用以下代码。

<ItemGroup>
<ResolvedFileToPublish Include="your_folder/yourfile">
<RelativePath>your_folder/yourfile</RelativePath>
</ResolvedFileToPublish>
<ResolvedFileToPublish Include="azure-functions-host/appsettings.prod.json">
<RelativePath>azure-functions-host/appsettings.prod.json</RelativePath>
</ResolvedFileToPublish>
<ResolvedFileToPublish Include="azure-functions-host/appsettings.dev.json">
<RelativePath>azure-functions-host/appsettings.dev.json</RelativePath>
</ResolvedFileToPublish>
</ItemGroup>

有关更多详细信息,您可以在下面的帖子中查看我的回答。

1. Azure Functions don't publish appsettings.prod.json file

2. Unable to find files located in my root project folder when hosted on Azure

关于c# - Visual Studio 在发布时将 .dll 复制到 Bin 文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67303491/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com