简体   繁体   English

为什么ASP.NET vNext“dnu build”无法在OSX上运行

[英]Why is ASP.NET vNext 'dnu build' not working on OSX

Installed DNVM and DNX on OSX as instructed via https://github.com/aspnet/Home . 按照https://github.com/aspnet/Home的指示在OSX上安装DNVM和DNX。

I used generator-aspnet to create a console application with one source file, Program.cs: 我使用generator-aspnet创建一个带有一个源文件Program.cs的控制台应用程序:

using System;

namespace HelloWorldConsole
{
    public class Program
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello World");
            Console.ReadLine();
        }
    }
}

and a package.json: 和package.json:

{
    "version": "1.0.0-*",
    "dependencies": {},
    "commands": {
        "run": "run"
    },
    "frameworks": {
        "dnx451": {},
        "dnxcore50": {
            "dependencies": {
                "System.Console": "4.0.0-beta-*"
            }
        }
    }
}

When I run it using dnu . run 当我使用dnu . run运行它dnu . run dnu . run , it works as expected and prints "Hello World!". dnu . run ,它按预期工作并打印“Hello World!”。

However when I try to generate assemblies from it by running dnu build I get the following error: 但是当我尝试通过运行dnu build从它生成程序集时,我收到以下错误:

System.IO.EndOfStreamException: Failed to read past end of stream. System.IO.EndOfStreamException:无法读取流的末尾。
at System.IO.BinaryReader.ReadChar () [0x00000] in :0 at Microsoft.CodeAnalysis.CvtResFile.ReadStringOrID (System.IO.BinaryReader fhIn) [0x00000] in :0 at Microsoft.CodeAnalysis.CvtResFile.ReadResFile (System.IO.Stream stream) [0x00000] in :0 at Microsoft.CodeAnalysis.Compilation.MakeWin32ResourceList (System.IO.Stream win32Resources, Microsoft.CodeAnalysis.DiagnosticBag diagnostics) [0x00000] in :0 at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.SetupWin32Resources (Microsoft.CodeAnalysis.CSharp.Emit.PEModuleBuilder moduleBeingBuilt, System.IO.Stream win32Resources, Microsoft.CodeAnalysis.DiagnosticBag diagnostics) [0x00000] in :0 at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.CompileImpl (Microsoft.CodeAnalysis.Emit.CommonPEModuleBuilder moduleBuilder, System.IO.Stream win32Resources, System.IO.Stream xmlDocStream, Boolean generateDebugInfo, Microsoft.CodeAnalysis.DiagnosticBag diagnostics, System.Predicate 1 filterOpt, CancellationToken cancellationToken) [0x00000] in <filename unknown>:0 at Microsoft.CodeAnalysis.Compilation.Compile (Microsoft.CodeAnalysis.Emit.CommonPEModuleBuilder moduleBuilder, System.IO.Stream win32Resources, System.IO.Stream xmlDocStream, Boolean generateDebugInfo, Microsoft.CodeAnalysis.DiagnosticBag diagnostics, System.Predicate 在System.IO.BinaryReader.ReadChar()[0x00000] in:0 at Microsoft.CodeAnalysis.CvtResFile.ReadStringOrID(System.IO.BinaryReader fhIn)[0x00000] in:0 at Microsoft.CodeAnalysis.CvtResFile.ReadResFile(System.IO) .Stream stream)[0x00000] in:0 at Microsoft.CodeAnalysis.Compilation.MakeWin32ResourceList(System.IO.Stream win32Resources,Microsoft.CodeAnalysis.DiagnosticBag diagnostics)[0x00000] in:0 at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.SetupWin32Resources( Microsoft.CodeAnalysis.CSharp.Emit.PEModuleBuilder moduleBeingBuilt,System.IO.Stream win32Resources,Microsoft.CodeAnalysis.DiagnosticBag diagnostics)[0x00000] in:0 at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.CompileImpl(Microsoft.CodeAnalysis.Emit.CommonPEModuleBuilder moduleBuilder ,System.IO.Stream win32Resources,System.IO.Stream xmlDocStream,Boolean generateDebugInfo,Microsoft.CodeAnalysis.DiagnosticBag diagnostics,System.Predicate 1 filterOpt, CancellationToken cancellationToken) [0x00000] in <filename unknown>:0 at Microsoft.CodeAnalysis.Compilation.Compile (Microsoft.CodeAnalysis.Emit.CommonPEModuleBuilder moduleBuilder, System.IO.Stream win32Resources, System.IO.Stream xmlDocStream, Boolean generateDebugInfo, Microsoft.CodeAnalysis.DiagnosticBag diagnostics, System.Predicate 1 filterOpt, CancellationToken cancellationToken) [0x00000] in <filename unknown>:0 at Microsoft.CodeAnalysis.Compilation.Compile (Microsoft.CodeAnalysis.Emit.CommonPEModuleBuilder moduleBuilder, System.IO.Stream win32Resources, System.IO.Stream xmlDocStream, Boolean generateDebugInfo, Microsoft.CodeAnalysis.DiagnosticBag diagnostics, System.Predicate 1 filterOpt, CancellationToken cancellationToken) [0x00000] in :0 at Microsoft.CodeAnalysis.Compilation.Emit (Microsoft.CodeAnalysis.EmitStreamProvider peStreamProvider, Microsoft.CodeAnalysis.EmitStreamProvider pdbStreamProvider, Microsoft.CodeAnalysis.EmitStreamProvider xmlDocumentationStreamProvider, Microsoft.CodeAnalysis.EmitStreamProvider win32ResourcesStreamProvider, IEnumerable 1 manifestResources, Microsoft.CodeAnalysis.Emit.EmitOptions options, Microsoft.CodeAnalysis.CodeGen.CompilationTestData testData, System.Func 1 getHostDiagnostics, CancellationToken cancellationToken) [0x00000] in :0 at Microsoft.CodeAnalysis.Compilation.Emit (System.IO.Stream peStream, System.IO.Stream pdbStream, System.IO. 1 filterOpt, CancellationToken cancellationToken) [0x00000] in <filename unknown>:0 at Microsoft.CodeAnalysis.Compilation.Compile (Microsoft.CodeAnalysis.Emit.CommonPEModuleBuilder moduleBuilder, System.IO.Stream win32Resources, System.IO.Stream xmlDocStream, Boolean generateDebugInfo, Microsoft.CodeAnalysis.DiagnosticBag diagnostics, System.Predicate 1 filterOpt,CancellationToken cancellationToken)[0x00000] in:0 at Microsoft.CodeAnalysis.Compilation.Emit(Microsoft.CodeAnalysis.EmitStreamProvider peStreamProvider,Microsoft.CodeAnalysis.EmitStreamProvider pdbStreamProvider,Microsoft.CodeAnalysis.EmitStreamProvider xmlDocumentationStreamProvider,Microsoft.CodeAnalysis.EmitStreamProvider win32ResourcesStreamProvider,IEnumerable 1 manifestResources, Microsoft.CodeAnalysis.Emit.EmitOptions options, Microsoft.CodeAnalysis.CodeGen.CompilationTestData testData, System.Func 1 getHostDiagnostics,CancellationToken cancellationToken)[0x00000] in:0 at Microsoft.CodeAnalysis.Compilation.Emit(System.IO.Stream) peStream,System.IO.Stream pdbStream,System.IO。 Stream xmlDocumentationStream, System.IO.Stream win32Resources, IEnumerable 1 manifestResources, Microsoft.CodeAnalysis.Emit.EmitOptions options, Microsoft.CodeAnalysis.CodeGen.CompilationTestData testData, System.Func 1 getHostDiagnostics, CancellationToken cancellationToken) [0x00000] in :0 at Microsoft.CodeAnalysis.Compilation.Emit (System.IO.Stream peStream, System.IO.Stream pdbStream, System.IO.Stream xmlDocumentationStream, System.IO.Stream win32Resources, IEnumerable 1 manifestResources, Microsoft.CodeAnalysis.Emit.EmitOptions options, CancellationToken cancellationToken) [0x00000] in <filename unknown>:0 at Microsoft.Framework.Runtime.Roslyn.RoslynProjectReference.EmitAssembly (System.String outputPath) [0x00000] in <filename unknown>:0 at Microsoft.Framework.PackageManager.ProjectBuilder.Build (System.String name, System.String outputPath) [0x00000] in <filename unknown>:0
at Microsoft.Framework.PackageManager.BuildContext.Build (System.Collections.Generic.List
流xmlDocumentationStream,System.IO.Stream win32Resources,IEnumerable 1 manifestResources, Microsoft.CodeAnalysis.Emit.EmitOptions options, Microsoft.CodeAnalysis.CodeGen.CompilationTestData testData, System.Func 1 getHostDiagnostics,CancellationToken cancellationToken)[0x00000] in:0 at Microsoft。 CodeAnalysis.Compilation.Emit(System.IO.Stream peStream,System.IO.Stream pdbStream,System.IO.Stream xmlDocumentationStream,System.IO.Stream win32Resources,IEnumerable 1 manifestResources, Microsoft.CodeAnalysis.Emit.EmitOptions options, CancellationToken cancellationToken) [0x00000] in <filename unknown>:0 at Microsoft.Framework.Runtime.Roslyn.RoslynProjectReference.EmitAssembly (System.String outputPath) [0x00000] in <filename unknown>:0 at Microsoft.Framework.PackageManager.ProjectBuilder.Build (System.String name, System.String outputPath) [0x00000] in <filename unknown>:0
at Microsoft.Framework.PackageManager.BuildContext.Build (System.Collections.Generic.List
1 manifestResources, Microsoft.CodeAnalysis.Emit.EmitOptions options, CancellationToken cancellationToken) [0x00000] in <filename unknown>:0 at Microsoft.Framework.Runtime.Roslyn.RoslynProjectReference.EmitAssembly (System.String outputPath) [0x00000] in <filename unknown>:0 at Microsoft.Framework.PackageManager.ProjectBuilder.Build (System.String name, System.String outputPath) [0x00000] in <filename unknown>:0
at Microsoft.Framework.PackageManager.BuildContext.Build (System.Collections.Generic.List
1 manifestResources, Microsoft.CodeAnalysis.Emit.EmitOptions options, CancellationToken cancellationToken) [0x00000] in <filename unknown>:0 at Microsoft.Framework.Runtime.Roslyn.RoslynProjectReference.EmitAssembly (System.String outputPath) [0x00000] in <filename unknown>:0 at Microsoft.Framework.PackageManager.ProjectBuilder.Build (System.String name, System.String outputPath) [0x00000] in <filename unknown>:0
at Microsoft.Framework.PackageManager.BuildContext.Build (System.Collections.Generic.List
1 diagnostics) [0x00000] in :0 at Microsoft.Framework.PackageManager.BuildManager.Build () [0x00000] in :0 at Microsoft.Framework.PackageManager.Program+<>c__DisplayClass3_4.b__8 () [0x00000] in :0 at Microsoft.Framework.Runtime.Common.CommandLine.CommandLineApplication.Execute (System.String[] args) [0x00000] in :0 at Microsoft.Framework.PackageManager.Program.Main (System.String[] args) [0x00000] in :0 at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&) at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0
1 manifestResources, Microsoft.CodeAnalysis.Emit.EmitOptions options, CancellationToken cancellationToken) [0x00000] in <filename unknown>:0 at Microsoft.Framework.Runtime.Roslyn.RoslynProjectReference.EmitAssembly (System.String outputPath) [0x00000] in <filename unknown>:0 at Microsoft.Framework.PackageManager.ProjectBuilder.Build (System.String name, System.String outputPath) [0x00000] in <filename unknown>:0
at Microsoft.Framework.PackageManager.BuildContext.Build (System.Collections.Generic.List
1 diagnostics)[0x00000] in:0 at Microsoft.Framework.PackageManager.BuildManager.Build()[0x00000] in:0 at Microsoft.Framework。 PackageManager.Program + <> c__DisplayClass3_4.b__8()[0x00000] in:0 at Microsoft.Framework.Runtime.Common.CommandLine.CommandLineApplication.Execute(System.String [] args)[0x00000] in:0 at Microsoft.Framework.PackageManager .Program.Main(System.String [] args)[0x00000] in:0 at(wrapper managed-to-native)System.Reflection.MonoMethod:InternalInvoke(System.Reflection.MonoMethod,object,object [],System.Exception& )在System.Reflection.MonoMethod.Invoke(System.Object obj,BindingFlags invokeAttr,System.Reflection.Binder binder,System.Object [] parameters,System.Globalization.CultureInfo culture)[0x00000] in:0

Any ideas why dnx . 任何想法为什么dnx。 run works but dnu build doesn't? 运行工程,但dnu构建不? The core libs seem to be getting referenced and loaded hence the run working. 核心库似乎被引用和加载,因此运行正常。 What's missing with the dnu build command? dnu build命令缺少什么?

What I did is this: 我做的是这样的:

  1. clone the mono repository, compile and install it following the directions here http://www.mono-project.com/docs/compiling-mono/ (make sure to follow the directions for compiling from git source) 克隆单声道存储库,按照http://www.mono-project.com/docs/compiling-mono/中的说明编译并安装它(确保遵循从git源编译的说明)
  2. brew tap aspnet/dnx brew tap aspnet / dnx
  3. brew upgrade 酿造升级
  4. brew install dnvm --without-mono brew install dnvm --without-mono

After doing this I was able to run dnu build successfully. 这样做后,我能够成功运行dnu构建。

The issue seems to be brew is pointing at a version of mono that doesn't seem to work well with the latest build of aspnet/dnx. 问题似乎是brew指向的单声道版本似乎与最新版本的aspnet / dnx不兼容。 Here is a way to get it pointing to a workable version. 这是一种让它指向可行版本的方法。

  1. nano /usr/local/Library/Formula/mono.rb nano /usr/local/Library/Formula/mono.rb
  2. changed line 4 and 5 to 将第4行和第5行更改为

    url " http://download.mono-project.com/sources/mono/mono-4.0.1.44.tar.bz2 " sha256 "eaf5bd9d19818cb89483b3c9cae2ee3569643fd621560da036f6a49f6b3e3a6f" url“ http://download.mono-project.com/sources/mono/mono-4.0.1.44.tar.bz2 ”sha256“eaf5bd9d19818cb89483b3c9cae2ee3569643fd621560da036f6a49f6b3e3a6f”

  3. brew upgrade mono brew升级单声道

  4. You should be able to properly run dnu build on the project 您应该能够在项目上正确运行dnu构建

    • source dnvm.sh 来源dnvm.sh
    • cd projectdir cd projectdir
    • dnu restore dnu恢复
    • dnu build dnu build
    • export MONO_MANAGED_WATCHER=false (for mono bug, see link below) export MONO_MANAGED_WATCHER = false(对于mono bug,请参阅下面的链接)
    • dnx . dnx。 kestrel 红隼
    • open http://localhost:5001 打开http:// localhost:5001

about mono bug - Running first ASP.NET 5 application using VSCode, DNX and kestrel results in IOException 关于mono bug - 使用VSCode,DNX和kestrel运行第一个ASP.NET 5应用程序会导致IOException

If you have problems with brew, use brew doctor 如果您有酿造问题,请使用brew doctor

Thanks to salerth https://github.com/aspnet/Home/issues/498 感谢salerth https://github.com/aspnet/Home/issues/498

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM