我目前正在研究ASP.NET Core 1.0项目。我想同时留在 dnxcore50 和 dnx451 上。现在把我带到以下问题:
I'm currently working on an ASP.NET Core 1.0 project. I want to stay on the dnxcore50 and the dnx451 at the same time. Which brings me to the following issue now:
如何将zip压缩文件从文件系统解压缩到目录中?
How can I unzip a zip archive from the filesystem to a directory?
"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对象在核心框架中不存在:/。
With that configuration in the project.json I'm now able to get a GZipStream but I have no idea how to store that stream to a directory. Unfortunately the ZipFile object in System.IO.Compression.ZipFile.ExtractToDirectory() method doesn't exsists in the core framework :/.
更新:
我现在以这种方式包括了它,并将其从整体依赖项中删除:
I now included it that way and removed it from the overall dependencies:
"frameworks": { "dnx451": { "dependencies": { "System.IO.Compression.ZipFile": "4.0.1-beta-23516" } }, "dnxcore50": { "dependencies": { "System.IO.Compression.ZipFile": "4.0.1-beta-23516" } }何时我使用可正常运行的内核运行该应用程序,但使用 framework 4.6运行该应用程序,在运行时因以下错误而崩溃:
When I run the application using core it works as expected, but running it with the framework 4.6 I crashes with the following exeception during runtime:
n处理时发生未处理的异常
n unhandled exception occurred while processing the request.
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.推荐答案
在project.json中需要的依赖项如下
The dependencies you require in your project.json are as follows.
"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根目录中的依赖项适用于与所有您正在使用的运行时。
The dependenices in the root of project.json are for any packages that work with all runtimes you are using.
运行时中的frameworkAssemblies与您在基于csproj的普通项目中添加的引用相同。如果不确定要添加什么,可以在此处找到程序集。 msdn.microsoft/zh-我们/library/mt472912(v=vs.110).aspx 。
The frameworkAssemblies in the runtime are the same references you would add in a normal csproj based project. You can find the assemblies here if you are not sure what to add. msdn.microsoft/en-us/library/mt472912(v=vs.110).aspx. You would use the dependencies section here for any net specific references.
当涉及到dnxcore50时,依赖项引用直接来自nuget,但是您可以使用intellisense来找到它们。
When it comes to dnxcore50 the dependencies references come straight from nuget but you can use the intellisense to find these.
有关project.json的更多信息,请参见 github/aspnet/Home/wiki/Project.json文件
More information about project.json can be found here github/aspnet/Home/wiki/Project.json-file
更多推荐
在.Net CORE 1.0中解压缩存档
发布评论