2016-01-22 59 views
2

我目前正在开发一个ASP.NET Core 1.0项目。我想同时留在dnxcore50dnx451上。这使我现在遇到以下问题:解压在.Net中的归档核心1.0

如何将zip文件从文件系统解压缩到目录?

"System.IO.FileSystem.Primitives": "4.0.0-beta-22816", 
"System.IO.FileSystem": "4.0.0-beta-22816" 

"frameworks": { 
    "dnx451": { 
     "frameworkAssemblies": { 
     "System.IO": "" 
     } 
    }, 
    "dnxcore50": { 
     "dependencies": { 
     "System.IO": "4.0.10-beta-*" 
     } 
    } 
    } 

随着在project.json该配置现在我能得到一个GZipStream,但我不知道如何在流存储到一个目录。不幸的是,System.IO.Compression.ZipFile.ExtractToDirectory()方法中的ZipFile对象在核心框架中不存在:/。

UPDATE:

我现在包括它的方式,并从整体上依赖删除它:

"frameworks": { 
"dnx451": { 
    "dependencies": { 
    "System.IO.Compression.ZipFile": "4.0.1-beta-23516" 
    } 
}, 
"dnxcore50": { 
    "dependencies": { 
    "System.IO.Compression.ZipFile": "4.0.1-beta-23516" 
    } 
} 

当我使用的核心它能正常工作,但随着运行它运行应用程序.net framework 4.6我在运行时遇到以下情况:

n处理请求时发生未处理的异常。

An unhandled exception occurred while processing the request. 
FileNotFoundException: Could not load file or assembly 'System.IO.Compression.ZipFile, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified. 
+1

嗯发现,[你确定](https://github.com/dotnet/corefx/blob/master/src/System.IO.Compression。的ZipFile/REF/System.IO.Compression.ZipFile.cs /#L15)? –

+1

thx为您的答案。我发现我的错误。我使用System.IO.Compression.ZipFile 4.0.0的最后一个稳定版本,但它似乎已添加到4.0.1-beta-23516 @JoachimIsaksson –

+0

更新了我的问题。你能再帮我一次吗? @JoachimIsaksson –

回答

1

您在project.json中需要的依赖关系如下。

"frameworks": { 
    "net451": { 
     "frameworkAssemblies": { 
     "System.IO.Compression": "4.0.0.0", 
     "System.IO.Compression.FileSystem": "4.0.0.0" 
     } 
    }, 
    "dnxcore50": { 
     "dependencies": { 
     "System.IO.Compression.ZipFile": "4.0.1-beta-23516" 
     } 
    } 
    }, 

project.json根目录中的依赖项适用于所有使用所有运行时的包。

.net运行库中的frameworkAssemblies与您在基于csproj的普通项目中添加的引用相同。如果你不确定要添加什么,你可以在这里找到装配。 https://msdn.microsoft.com/en-us/library/mt472912(v=vs.110).aspx。您可以在这里使用依赖关系部分来获取任何网络特定的引用。

说到dnxcore50,依赖关系引用直接来自nuget,但您可以使用intellisense来查找这些引用。

有关project.json更多信息可以在这里https://github.com/aspnet/Home/wiki/Project.json-file

+0

thx,现在它按预期工作,但我在哪里知道我必须添加哪些框架?我不知道这是如何工作的。是否有一些project.json的文档? –

+1

我已经更新了我的答案,并提供了一些更多的信息,如果您不确定任何东西 –

+0

Thx,为什么它命名为frameworkAssemblies和其他时间依赖项? –