能否匹配.nuget\packages中的部分文件
Closed this issue · 5 comments
magian1127 commented
很多项目的microsoft.aspnetcore.xxx
经常引用 C:\Users\xxx\.nuget\packages
里面的文件 却不用 C:\Program Files\dotnet\packs\Microsoft.AspNetCore.App.Ref
比如 C:\Users\xxx\.nuget\packages\microsoft.aspnetcore.components
能不能自动匹配一部分,每次我都是发现英文的再自己手动复制过去,但是经常要重复手动复制..
magian1127 commented
用AI辅助写了个PY先凑合用着了
# 导入os模块
import os
import shutil
# 定义A目录和B目录的路径
A_path = r"C:\Program Files\dotnet\packs\Microsoft.AspNetCore.App.Ref\7.0.5\ref\net7.0\zh-cn"
B_path = r"C:\Users\xxx\.nuget\packages"
# 遍历A目录下的所有xml文件
for xml_file in os.listdir(A_path):
# 获取xml文件的文件名(不含扩展名)
xml_name = os.path.splitext(xml_file)[0]
# 拼接B目录下对应的文件夹路径
B_folder = os.path.join(B_path, xml_name)
# 判断B目录下是否存在对应的文件夹
if os.path.exists(B_folder):
# 遍历B目录下对应文件夹的所有子文件夹
for sub_folder in os.listdir(B_folder):
# 判断子文件夹是否以7.开头(表示7.X版本)
if sub_folder.startswith("7."):
# 拼接子文件夹下的xml文件路径
sub_xml = os.path.join(B_folder, sub_folder,r"lib\net7.0", xml_file)
# 判断子文件夹下是否存在xml文件
if os.path.exists(sub_xml):
# 拼接A目录下的xml文件路径
A_xml = os.path.join(A_path, xml_file)
# 用A目录下的xml文件替换子文件夹下的xml文件
shutil.copy(A_xml, sub_xml)
# 打印替换成功的信息
print(f"替换成功:{sub_xml}")
magian1127 commented
还有,能不能获取 微软其他部分的文档,比如
https://learn.microsoft.com/zh-cn/dotnet/api/microsoft.entityframeworkcore?view=efcore-7.0
stratosblue commented
都可以做,不过要等我空了再看看具体的原因,细节怎么实现比较好
stratosblue commented
@magian1127
复制到nuget缓存的功能做了,更新工具
dotnet tool update -g islocalizer
在install时使用参数 -ctn true
试试
nuget包的翻译需要再等等了。。。
magian1127 commented
测试下 功能正常