脚本宝典收集整理的这篇文章主要介绍了将.NETCore 3.1依赖dll放入additionalProbingPaths,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
runtimeconfig.json
添加runtimeconfig.template.json
依赖dll放入的文件夹名称
{
"addITionalPRobingPaths": [
"lib"
]
}
deps.json
移动dll的位置使用python脚本
moveDeps.py
import json
import os
target_dir = ""
target_dlls = []
def loadRuntimeConfigJson():
with oPEn("runtimeconfig.template.json") as f:
temp = json.load(f)
global target_dir
if type(temp["additionalProbingPaths"]) == list:
target_dir = temp["additionalProbingPaths"][0]
if type(temp["additionalProbingPaths"]) == str:
target_dir = temp["additionalProbingPaths"]
def loadDepJson():
dep_name = None
for file in os.listdir():
if file.endswith(".deps.json"):
dep_name = file
dep={}
if dep_name is not None:
with open(dep_name) as f:
dep = json.load(f)
targets = dict(dict(dep["targets"]).popitem()[1])
libraries = dict(dict(dep["libraries"]))
global target_dlls
for k, v in targets.items():
if not v.get("compileOnly") and libraries[k].get("type") == "package":
try:
t = targets[k]["runtime"].popitem()
target_path = os.path.join(
os.path.join(target_dir, libraries[k]["path"]),
t[0])
target_dlls.append((os.path.split(t[0])[-1], target_path))
except:
pass
def MoveDlls():
global target_dlls
for i, j in target_dlls:
dir = os.path.dirname(j)
if not os.path.exists(dir):
os.makedirs(dir)
os.rename(i, j)
if __name__ == '__main__':
loadRuntimeConfigJson()
loadDepJson()
MoveDlls()
发布完成后将py文件放入发布后的文件夹使用python3 moveDeps.py
就会根据dep.json文件将配置移动到lib文件中
相关资料 https://stackoverflow.COM/questions/48650348/additionalprobingpaths-not-respected-after-dotnet-publish
以上是脚本宝典为你收集整理的将.NETCore 3.1依赖dll放入additionalProbingPaths全部内容,希望文章能够帮你解决将.NETCore 3.1依赖dll放入additionalProbingPaths所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。