dnu发布 - 输出

时间:2016-02-29 21:05:28

标签: c# asp.net-core dnu

我目前有一个在Visual Studio中运行的C#Web应用程序项目。 我阅读了this文章,其中指出可以在没有安装visual studio或dnx的干净机器上运行您的Web应用程序。 这是我对我的项目所做的事情

 C:\Users\VmwareX64\Documents\Myapp\src\Myapp> dnu publish --runtime active

这是我得到的输出。

Microsoft .NET Development Utility CLR-x86-1.0.0-beta7-15532

Copying to output path C:\Users\VmwareX64\Documents\Myapp\src\Myapp\bin\output
Using Package dependency EntityFramework.Core 7.0.0-beta6
Using Package dependency EntityFramework.SqlServer 7.0.0-beta6
Using Package dependency EntityFramework.Commands 7.0.0-beta6
Using Package dependency Microsoft.AspNet.Mvc 6.0.0-beta6
Using Package dependency Microsoft.AspNet.Owin 1.0.0-beta6
Using Package dependency Microsoft.AspNet.Server.IIS 1.0.0-beta6
Using Package dependency Microsoft.AspNet.Server.WebListener 1.0.0-beta6
Using Package dependency Microsoft.AspNet.Server.Kestrel 1.0.0-beta6
Using Package dependency Microsoft.AspNet.StaticFiles 1.0.0-beta6
Using Package dependency Microsoft.Framework.Configuration.Json 1.0.0-beta6
Using Package dependency Microsoft.Framework.Configuration.UserSecrets 1.0.0-beta6
Using Package dependency Microsoft.Framework.Logging.Console 1.0.0-beta6
Using Package dependency Microsoft.Net.Http 2.2.29
Using Package dependency Mono.Zeroconf.Providers.Bonjour 0.95
Using Package dependency sharpcompress 0.11.1
Using Package dependency Ix-Async 1.2.4
Using Package dependency Microsoft.Framework.Caching.Abstractions 1.0.0-beta6
Using Package dependency Microsoft.Framework.Caching.Memory 1.0.0-beta6
Using Package dependency Microsoft.Framework.DependencyInjection 1.0.0-beta6
Using Package dependency Microsoft.Framework.DependencyInjection.Abstractions 1.0.
Using Package dependency Microsoft.Framework.Logging 1.0.0-beta6
Using Package dependency Microsoft.Framework.Logging.Abstractions 1.0.0-beta6
Using Package dependency Microsoft.Framework.OptionsModel 1.0.0-beta6
Using Package dependency Remotion.Linq 2.0.0-alpha-004
Using Package dependency System.Collections.Immutable 1.1.37-beta-23109
Using Package dependency EntityFramework.Relational 7.0.0-beta6
Using Package dependency EntityFramework.Relational.Design 7.0.0-beta6
Using Package dependency Microsoft.AspNet.Hosting 1.0.0-beta6
Using Package dependency Microsoft.Framework.Runtime.Abstractions 1.0.0-beta6
Using Package dependency Microsoft.AspNet.Mvc.ApiExplorer 6.0.0-beta6
Using Package dependency Microsoft.AspNet.Mvc.Cors 6.0.0-beta6
Using Package dependency Microsoft.AspNet.Mvc.DataAnnotations 6.0.0-beta6
Using Package dependency Microsoft.AspNet.Mvc.Formatters.Json 6.0.0-beta6
Using Package dependency Microsoft.AspNet.Mvc.Localization 6.0.0-beta6
Using Package dependency Microsoft.AspNet.Mvc.Razor 6.0.0-beta6
Using Package dependency Microsoft.AspNet.Mvc.ViewFeatures 6.0.0-beta6
Using Package dependency Microsoft.AspNet.Http 1.0.0-beta6
Using Package dependency Microsoft.AspNet.Loader.IIS 1.0.0-beta6
Using Package dependency Microsoft.AspNet.Loader.IIS.Interop 1.0.0-beta6
Using Package dependency Microsoft.Net.Http.Headers 1.0.0-beta6
Using Package dependency Microsoft.Net.Http.Server 1.0.0-beta6
Using Package dependency Microsoft.AspNet.FileProviders.Abstractions 1.0.0-beta6
Using Package dependency Microsoft.AspNet.Hosting.Abstractions 1.0.0-beta6
Using Package dependency Microsoft.AspNet.Http.Extensions 1.0.0-beta6
Using Package dependency Microsoft.Framework.WebEncoders 1.0.0-beta6
Using Package dependency Microsoft.Framework.Configuration 1.0.0-beta6
Using Package dependency Newtonsoft.Json 6.0.6
Using Package dependency Microsoft.Bcl 1.1.10
Using Package dependency Microsoft.Bcl.Build 1.0.14
Using Package dependency Mono.Zeroconf 0.95
Using Package dependency Microsoft.Framework.Configuration.Abstractions 1.0.0-beta
Using Package dependency Microsoft.Framework.Configuration.Binder 1.0.0-beta6
Using Package dependency System.Collections 4.0.0-beta-23109
Using Package dependency System.Diagnostics.Debug 4.0.0-beta-23109
Using Package dependency System.Globalization 4.0.0-beta-23109
Using Package dependency System.Linq 4.0.0-beta-23109
Using Package dependency System.Resources.ResourceManager 4.0.0-beta-23109
Using Package dependency System.Runtime 4.0.0-beta-23109
Using Package dependency System.Runtime.Extensions 4.0.0-beta-23109
Using Package dependency System.Threading 4.0.0-beta-23109
Using Package dependency Microsoft.AspNet.Razor 4.0.0-beta6
Using Package dependency Microsoft.CodeAnalysis.CSharp 1.0.0
Using Package dependency Microsoft.Framework.Runtime.Roslyn 1.0.0-beta6
Using Package dependency Microsoft.AspNet.FileProviders.Physical 1.0.0-beta6
Using Package dependency Microsoft.AspNet.Hosting.Server.Abstractions 1.0.0-beta6
Using Package dependency Microsoft.Framework.Configuration.CommandLine 1.0.0-beta6
Using Package dependency Microsoft.Framework.Configuration.EnvironmentVariables 1.
Using Package dependency Microsoft.Framework.Configuration.Ini 1.0.0-beta6
Using Package dependency Microsoft.AspNet.Mvc.Core 6.0.0-beta6
Using Package dependency Microsoft.AspNet.Cors.Core 1.0.0-beta6
Using Package dependency Microsoft.AspNet.JsonPatch 1.0.0-beta6
Using Package dependency Microsoft.AspNet.Localization 1.0.0-beta6
Using Package dependency Microsoft.Framework.Localization 1.0.0-beta6
Using Package dependency Microsoft.AspNet.Mvc.Razor.Host 6.0.0-beta6
Using Package dependency Microsoft.AspNet.PageExecutionInstrumentation.Interfaces
Using Package dependency Microsoft.Framework.Runtime.Roslyn.Abstractions 1.0.0-bet
Using Package dependency Microsoft.Framework.Runtime.Roslyn.Common 1.0.0-beta6
Using Package dependency Microsoft.AspNet.Antiforgery 1.0.0-beta6
Using Package dependency Microsoft.AspNet.Diagnostics.Abstractions 1.0.0-beta6
Using Package dependency Microsoft.AspNet.Html.Abstractions 1.0.0-beta6
Using Package dependency Microsoft.AspNet.FeatureModel 1.0.0-beta6
Using Package dependency Microsoft.AspNet.Http.Abstractions 1.0.0-beta6
Using Package dependency Microsoft.AspNet.WebUtilities 1.0.0-beta6
Using Package dependency Microsoft.AspNet.DataProtection.Abstractions 1.0.0-beta6
Using Package dependency Microsoft.Framework.WebEncoders.Core 1.0.0-beta6
Using Package dependency Microsoft.Net.WebSockets 1.0.0-beta6
Using Package dependency Microsoft.CodeAnalysis.Common 1.0.0
Using Package dependency Microsoft.Framework.Runtime.Caching 1.0.0-beta6
Using Package dependency Microsoft.AspNet.Authorization 1.0.0-beta6
Using Package dependency Microsoft.AspNet.Mvc.Abstractions 6.0.0-beta6
Using Package dependency Microsoft.Framework.Notification 1.0.0-beta6
Using Package dependency Microsoft.Framework.Globalization.CultureInfoCache 1.0.0-
Using Package dependency Microsoft.Framework.Localization.Abstractions 1.0.0-beta6
Using Package dependency Microsoft.AspNet.Razor.Runtime 4.0.0-beta6
Using Package dependency Microsoft.AspNet.DataProtection 1.0.0-beta6
Using Package dependency Microsoft.AspNet.Http.Features 1.0.0-beta6
Using Package dependency Microsoft.CodeAnalysis.Analyzers 1.0.0
Using Package dependency System.Reflection.Metadata 1.0.21
Using Package dependency Microsoft.AspNet.Routing 1.0.0-beta6
Using Package dependency Microsoft.AspNet.Cryptography.Internal 1.0.0-beta6
Using Project dependency Myapp 1.0.0 for DNX,Version=v4.5.1
  Copying source code from Project dependency Myapp
    Source C:\Users\VmwareX64\Documents\Myapp\src\Myapp\project.json
    Target C:\Users\VmwareX64\Documents\Myapp\src\Myapp\bin\output\approot\s

Bundling runtime dnx-clr-win-x86.1.0.0-beta7
  C:\Users\VmwareX64\Documents\Myapp\src\Myapp\bin\output\approot\runtimes\d
sts.
Copying contents of Project dependency Myapp to C:\Users\VmwareX64\Documents\Ma

  Source C:\Users\VmwareX64\Documents\Myapp\src\Myapp\wwwroot
  Target C:\Users\VmwareX64\Documents\Myapp\src\Myapp\bin\output\wwwroot

我的project.json看起来像这样

{
  "webroot": "wwwroot",
  "version": "1.0.0-*",

  "dependencies": {
    "EntityFramework.Core": "7.0.0-beta6",
    "EntityFramework.SqlServer": "7.0.0-beta6",
    "EntityFramework.Commands": "7.0.0-beta6",
    "Microsoft.AspNet.Mvc": "6.0.0-beta6",
    "Microsoft.AspNet.Owin": "1.0.0-beta6",
    "Microsoft.AspNet.Server.IIS": "1.0.0-beta6",
    "Microsoft.AspNet.Server.WebListener": "1.0.0-beta6",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-beta6",
    "Microsoft.AspNet.StaticFiles": "1.0.0-beta6",
    "Microsoft.Framework.Configuration.Json": "1.0.0-beta6",
    "Microsoft.Framework.Configuration.UserSecrets": "1.0.0-beta6",
    "Microsoft.Framework.Logging.Console": "1.0.0-beta6",
    "Microsoft.Net.Http": "2.2.29",
    "Mono.Zeroconf.Providers.Bonjour": "0.95",
    "sharpcompress": "0.11.1"
  },

  "commands": {
    "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://+:5000",
    "kestrel": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:5004",
    "ef": "EntityFramework.Commands"
  },

  "frameworks": {
    "dnx451": { }
  },

  "exclude": [
    "wwwroot",
    "node_modules",
    "bower_components"
  ],
  "publishExclude": [
    "node_modules",
    "bower_components",
    "**.xproj",
    "**.user",
    "**.vspscc"
  ],


}

基于此,我在C:\Users\VmwareX64\Documents\Myapp\src\Myapp\bin\output中生成了3 cmd文件 根据project.json中的命令,这些文件是web.cmd,ef.cmd,kestrel.cmd。

现在,当我尝试运行web.cmd时,这就是我得到的

PS C:\Users\VmwareX64\Documents\Mandarin\src\mandarin\bin\output> .\web.cmd
System.InvalidOperationException: No service for type 'Microsoft.Framework.Runtime.IApplicationEnvironment' has been reg
istered.
   at Microsoft.Framework.DependencyInjection.ServiceProviderExtensions.GetRequiredService(IServiceProvider provider, Ty
pe serviceType)
   at Microsoft.Framework.DependencyInjection.ServiceProviderExtensions.GetRequiredService[T](IServiceProvider provider)

   at Microsoft.AspNet.Hosting.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider service
Provider)
   at Microsoft.Dnx.ApplicationHost.Program.ExecuteMain(DefaultHost host, String applicationName, String[] args)
   at Microsoft.Dnx.ApplicationHost.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider service
Provider)
   at Microsoft.Dnx.Host.Bootstrapper.RunAsync(List`1 args, IRuntimeEnvironment env, FrameworkName targetFramework)
   at Microsoft.Dnx.Host.RuntimeBootstrapper.ExecuteAsync(String[] args, FrameworkName targetFramework)

有关为什么我的程序没有运行的任何建议?

1 个答案:

答案 0 :(得分:1)

在您预期已发布的应用程序无任何依赖关系运行之前,您应该测试是否可以使用dnx web在本地启动应用程序。

这样做会告诉你同样的错误,这是由Pawel说的:你在较低版本的项目中使用不同版本的DNX。

您应该使用dnvm选择测试版6 DNX运行时,然后您可以发布测试版6应用程序包。

但更好的解决方案是升级到RC1-update1,因为这是目前唯一受支持的版本,并且包含了之前存在的大量错误修复。 beta 6和beta 7实际上都非常古老,并且有很多你想要避免的问题。