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

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

问题描述

当我发布一个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.

对于其他部门,您可以将它们移动到任何位置,但是您需要为每个版本编辑 [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.

检查<一个href = https://github.com/izaruba/StandaloneNetCoreAppSubFolder rel = noreferrer>此演示,我在其中放置了 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天全站免登陆