我目前有一個在Visual Studio中運行的C#web應用程序項目。 我讀了this文章,指出它可能在沒有安裝visual studio或dnx的乾淨maachine上運行您的web應用程序。 以下是我與我的項目dnu發佈 - 輸出
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文件被web.cmd,ef.cmd,kestrel.cmd基礎上, project.json中的命令。
現在,當我嘗試運行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)
爲什麼我的程序沒有運行什麼建議嗎?
您正在嘗試發佈使用beta6軟件包的應用程序的beta7運行時。確保運行時匹配軟件包的版本並移到更新/最新版本(rc1-update1) - 即使beta6/beta7中存在一個錯誤,代碼可能已經改變了10次以上 – Pawel