我可以将本机依赖项放在子文件夹中吗 [英] Can i place native dependencies in a subfolder

查看:26
本文介绍了我可以将本机依赖项放在子文件夹中吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我发布一个 dotnet 核心项目时,它生成了一个文件夹,其中包含数百个框架和本机运行时文件.

When i publish a dotnet core project, it generated a single folder with hundreds of framework and native runtime files in it.

我知道这些文件是使一切正常运行所必需的,但是我可以将它们移到子文件夹中并仍然让我的应用程序运行吗?

I understand that these files are required to make everything work, but can i move them into a subfolder and still get my app to run?

例如

MYAppFolder
    MyApp.exe
    MyApp.exe.config
    native
       hostfxr.dll
       netstandard.dll
       ...

是否有某种探测路径配置可以做到这一点?

Is there some sort of probing path configuration that can do this?

推荐答案

据我所知,你有一个 Standalone (SCD) 应用程序.

As far as I can see you have a Standalone (SCD) app.

对于这种类型的部署,hostfxr.dll 应始终存在于应用程序目录中.

For that type of deployment hostfxr.dll should always exist in the app directory by convention.

对于其他 deps,您可以将它们移动到任何位置,但是您需要为每个构建编辑 [AppName].deps.json 并指定附加探测路径.此外,如果您确定不使用它们,您可以自由地删除所有冗余依赖项(从 deps.json 和文件本身).

As to other deps, you are able to move them to any locations, however you'll need to edit [AppName].deps.json for every build and also specify Additional probing paths. Besides, you are free to remove all the redundant dependencies (from deps.json and the file itself) if you are sure that you don't use them.

检查这个演示,其中我已经放置了Standalone 可以移动到其他位置到 lib 子目录的应用.

Check this demo where I've put all the dependencies of a Standalone app that could be moved to other location to a lib subdirectory.

请注意以下事项:

  • 附加探测路径在 HelloWorld.runtimeconfig.json 但你也可以使用 --additionalprobingpath [path] 参数或环境变量
  • 我已经删除了 deps.json 文件中的相对路径,否则我会将文件放在这些相对路径子目录中 - 附加探测路径被认为是 NuGet 包缓存 因此在里面有一个包布局.
  • Additional probing path is set in HelloWorld.runtimeconfig.json but you can also use --additionalprobingpath [path] argument or Environment varibable
  • I've removed relative paths in deps.json file because otherwise I would have put the files to those relative paths sub directories - Additional probing path is considered to be a NuGet package cache thus have a package layout inside.

另外,考虑使用 Portable (FDD) 类型.您将有更少的占用空间和更大的灵活性来安排文件.

Also, consider having a Portable (FDD) type. You'll have a much less footprint and more flexibility arranging the files.

这篇关于我可以将本机依赖项放在子文件夹中吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆