程序问答   发布时间:2022-06-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Visual Studio 在发布时将 .dll 复制到 Bin 文件夹大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决Visual studio 在发布时将 .dll 复制到 Bin 文件夹?

开发过程中遇到Visual studio 在发布时将 .dll 复制到 Bin 文件夹的问题如何解决?下面主要结合日常开发的经验,给出你关于Visual studio 在发布时将 .dll 复制到 Bin 文件夹的解决方法建议,希望对你解决Visual studio 在发布时将 .dll 复制到 Bin 文件夹有所启发或帮助;

@H_502_1@我有以下问题。

我创建了一个 @H_502_1@Azure 函数,并且想要运行存储在 {ProjectfilE}/AlCompiler 文件夹中的编译器。

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

我尝试将@H_502_1@AlCompiler文件夹的文件发布到@H_502_1@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>

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

  • @H_502_1@exe 和其他一些文件转到 wwwroot/AlCompiler 文件夹
  • @H_502_1@所有 .dll 都转到 wwwroot/bin/AlCompiler 文件夹

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

@H_502_1@所以我无法运行 alc.exe 文件,因为缺少 .dll。

我很高兴能得到您的帮助!

解决方法

您应该在 .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>

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

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

,

我遇到了解决方案,反之亦然。

我没有尝试将 .dll's@H_489_61@ 添加到 Compiler 文件夹(存储 .exe@H_489_61@ 的位置),而是将 .exe's@H_489_61@ 添加到 bin 文件夹( .dll 的@H_489_61@ 存储在哪里)。

不知道这是否是最好的解决方案,但它有效:

<ItemGroup>
    <ContentWithTargetPath Include="AlCompiler/**">
      <CopyToOutputDirectory>PreserveNeWest</CopyToOutputDirectory>
      <CopyToPublishDirectory>PreserveNeWest</CopyToPublishDirectory>
      <TargetPath>bin\AlCompiler\%(RecursiveDir)%(FileName)%(Extension)</TargetPath>
    </ContentWithTargetPath>
</ItemGroup>

大佬总结

以上是大佬教程为你收集整理的Visual Studio 在发布时将 .dll 复制到 Bin 文件夹全部内容,希望文章能够帮你解决Visual Studio 在发布时将 .dll 复制到 Bin 文件夹所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。