为什么CoreRT编译的程序无法使用ZIP文件?

时间:2018-06-22 05:25:50

标签: .net-core system.io.compression corert

我编写了以下简单程序进行测试:

s3 = boto3.client('s3')
s3r = boto3.resource('s3')
Bucket=s3r.Bucket('bucketname')

for obj in Bucket.objects.filter(Prefix='<timestamp>/'):  # add prefix only if you want objects of a particular subfolder
    filename=obj.key
    key=str(filename)
    local="C://path_to_save-file"
    s3.download_file('bucketname',key, local)
    #your code goes here to use downloaded file

对于每个this page,我从HelloZip项目目录运行using System; using System.IO; using System.IO.Compression; namespace HelloZip { class Program { static void Main(string[] args) { string path = Path.Combine(AppContext.BaseDirectory, "test.zip"); using (ZipArchive z = ZipFile.Open(path, ZipArchiveMode.Create)) { var f = z.CreateEntry("hello.txt"); using (StreamWriter writer = new StreamWriter(f.Open())) { writer.Write("Hello World!"); } } } } } ,在nuget.config中添加了推荐的软件包源,然后运行了以下命令:

dotnet new nuget

我遇到以下错误:

dotnet add package Microsoft.DotNet.ILCompiler -v 1.0.0-alpha-*
dotnet publish -r win-x64 -c release -o out
out\HelloZip.exe

我犯错了吗,还是AOT编译器还不能正确支持System.IO.Compression?

1 个答案:

答案 0 :(得分:1)

您正在使用已知的未实现功能。解决方法是暂时将clrcompression.dll手动复制到已编译的可执行文件旁边。在此处查看详细信息:https://github.com/dotnet/corert/issues/5496