0

現在、Visual Studio で実行されている C# Web アプリ プロジェクトがあります。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"
  ],


}

これに基づいて、これらのファイルで生成された 3 つの cmd ファイルC:\Users\VmwareX64\Documents\Myapp\src\Myapp\bin\output は、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)

私のプログラムが実行されていない理由について何か提案はありますか?

4

1 に答える 1

1

公開されたアプリが依存関係なしで実行されることを期待する前に、を使用してアプリケーションをローカルで起動できるかどうかをテストする必要がありますdnx web

これを行うと、Pawel が言ったことによる同じエラーが表示されます。以前のバージョンのプロジェクトで別のバージョンの DNX を使用しています。

を使用dnvmしてベータ 6 DNX ランタイムを選択すると、ベータ 6 アプリケーション パッケージを公開できます。

しかし、RC1-update1 が現在サポートされている唯一のリリースであり、以前に存在した多くのバグ修正が含まれているため、より良い解決策は RC1-update1 にアップグレードすることです。ベータ 6 とベータ 7 はどちらも実際には非常に古く、回避したい問題がたくさんありました。

于 2016-02-29T21:26:00.913 に答える