按照https://github.com/aspnet/Home的指示在OSX上安装DNVM和DNX。
我使用generator-aspnet创建一个带有一个源文件Program.cs:
的控制台应用程序using System;
namespace HelloWorldConsole
{
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Hello World");
Console.ReadLine();
}
}
}
和package.json:
{
"version": "1.0.0-*",
"dependencies": {},
"commands": {
"run": "run"
},
"frameworks": {
"dnx451": {},
"dnxcore50": {
"dependencies": {
"System.Console": "4.0.0-beta-*"
}
}
}
}
当我使用dnu . run
运行它时,它按预期工作并打印" Hello World!"。
但是当我尝试通过运行dnu build
从中生成程序集时,我收到以下错误:
System.IO.EndOfStreamException:无法读取流的结尾。
在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 诊断)[0x00000] in:0 at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.SetupWin32Resources (Microsoft.CodeAnalysis.CSharp.Emit.PEModuleBuilder moduleBeingBuilt, System.IO.Stream win32Resources,Microsoft.CodeAnalysis.DiagnosticBag 诊断)[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 诊断,System.Predicate1 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,IEnumerable1 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,IEnumerable1 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,IEnumerable1 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
1诊断)[0x00000] in:0 at Microsoft.Framework.PackageManager.BuildManager.Build ()[0x00000] in:0 at Microsoft.Framework.PackageManager.Program + LT;&GT; 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(包装器托管到原生) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object [],System.Exception&amp;)at System.Reflection.MonoMethod.Invoke(System.Object obj,BindingFlags invokeAttr,System.Reflection.Binder binder,System.Object [] 参数,System.Globalization.CultureInfo文化)[0x00000] in :0
at Microsoft.Framework.PackageManager.BuildContext.Build (System.Collections.Generic.List
任何想法为什么dnx。运行有效但dnu构建不起作用吗?核心库似乎被引用和加载,因此运行正常。 dnu build命令缺少什么?
答案 0 :(得分:4)
这是一个已知的单声道错误:https://bugzilla.xamarin.com/show_bug.cgi?id=29499
答案 1 :(得分:4)
问题似乎是brew指向的单声道版本似乎与最新版本的aspnet / dnx不兼容。这是一种让它指向可行版本的方法。
将第4行和第5行更改为
url“http://download.mono-project.com/sources/mono/mono-4.0.1.44.tar.bz2” sha256“eaf5bd9d19818cb89483b3c9cae2ee3569643fd621560da036f6a49f6b3e3a6f”
brew upgrade mono
您应该能够在项目上正确运行dnu构建
关于单声道错误 - Running first ASP.NET 5 application using VSCode, DNX and kestrel results in IOException
如果您遇到酿造问题,请使用brew doctor