将Visual Studio Web应用程序部署到IIS(甚至可能是Azure连续部署Git)



我正在尝试从VS 2015 RC部署我的MVC 6 Web应用程序。我正在使用IIS 7.5。我浏览了其他用户关于类似部署的问题,但他们的解决方案对我不起作用…

具体来说,我遵循本指南(未成功):http://dotnetspeak.com/2015/03/publish-asp-net-v-next-to-iis

我实际上只是想发布默认的.NET 5/MVC 6 Visual Studio Web应用程序。。。以下是我所做尝试的详细说明。不知道我做错了什么。我承认,我对IIS和.NET非常生疏。所以请记住这一点!


Visual Studio 2015 Web发布

作者告诉你:

右键单击默认网站并选择添加应用程序

所以我在"发布Web"期间使用的值:

  • 配置文件名称:DerekFoulk.com
  • 目标位置:c:\inetpub\wwwroot\DerekFoulk.com
  • 配置:发布
  • 目标DNX版本:默认值(DNX-clr-win-x86.1.0.0-beta4)
  • 发布脚本:使用PowerShell脚本发布

然后我看到:

您的应用程序将发布到:

C: \inetpub\wwwroot\DerekFoulk.com

所以我点击了发布


添加到IIS 7.5

在我这样做之前,我注意到IIS中已经有一个条目的标题与我的项目同名。这可能是因为我一直在使用默认的"开始调试-IIS Express"按钮在浏览器中预览我的应用程序吗?

然后我打开IIS,右键单击默认网站并点击添加应用程序。我使用了以下配置:

  • 别名:DerekFoulk
  • 应用程序池:DefaultAppPool
  • 物理路径:C:\inetpub\wwwroot\DerekFoulk.com\wwwroot
  • 通过身份验证

然后我点击测试设置,得到以下错误消息:

执行此操作时出错。

详细信息:

无效的应用程序路径

作者没有提到检查设置,尽管我知道这意味着事情不会正常进行,但我还是点击了确定

最后,作者说:

转到windows资源管理器中TestApp文件夹下的安全性。添加经过身份验证的用户组帐户,并赋予其读取和执行权限。

所以我右键单击了目录(C:\inetpub\wwwroot\DerekFoulk.com),然后转到属性>安全,没有看到Authenticated Users组。然而,我确实看到IIS_IUSRS具有Read&执行权限。我认为这些是适当的权限,并继续尝试在浏览器中查看我的应用程序。。。

我导航到http://localhost/DerekFoulk/。它在页面上显示以下错误:

<!DOCTYPE html>
<html>
<head>
<title>Could not load file or assembly 'dnx.clr.managed' or one of its dependencies. The system cannot find the file specified.</title>
<meta name="viewport" content="width=device-width" />
<style>
body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} 
p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
pre {font-family:"Consolas","Lucida Console",Monospace;font-size:11pt;margin:0;padding:0.5em;line-height:14pt}
.marker {font-weight: bold; color: black;text-decoration: none;}
.version {color: gray;}
.error {margin-bottom: 10px;}
.expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
@media screen and (max-width: 639px) {
pre { width: 440px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; }
}
@media screen and (max-width: 479px) {
pre { width: 280px; }
}
</style>
</head>
<body bgcolor="white">
<span><H1>Server Error in '/DerekFoulk' Application.<hr width=100% size=1 color=silver></H1>
<h2> <i>Could not load file or assembly 'dnx.clr.managed' or one of its dependencies. The system cannot find the file specified.</i> </h2></span>
<font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">
<b> Description: </b>An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
<br><br>
<b> Exception Details: </b>System.IO.FileNotFoundException: Could not load file or assembly 'dnx.clr.managed' or one of its dependencies. The system cannot find the file specified.<br><br>
<b>Source Error:</b> <br><br>
<table width=100% bgcolor="#ffffcc">
<tr>
<td>
<code>
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.</code>
</td>
</tr>
</table>
<br>
<b>Assembly Load Trace:</b> The following information can be helpful to determine why the assembly 'dnx.clr.managed' could not be loaded.<br><br>
<table width=100% bgcolor="#ffffcc">
<tr>
<td>
<code><pre>
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLMSoftwareMicrosoftFusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLMSoftwareMicrosoftFusion!EnableLog].
</pre></code>
</td>
</tr>
</table>
<br>
<b>Stack Trace:</b> <br><br>
<table width=100% bgcolor="#ffffcc">
<tr>
<td>
<code><pre>
[FileNotFoundException: Could not load file or assembly &#39;dnx.clr.managed&#39; or one of its dependencies. The system cannot find the file specified.]
[TypeLoadException: The domain manager specified by the host could not be instantiated.]
System.Web.HttpRuntime.HostingInit(HostingEnvironmentFlags hostingFlags, PolicyLevel policyLevel, Exception appDomainCreationException) +556
[HttpException (0x80004005): The domain manager specified by the host could not be instantiated.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +579
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +112
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +726
</pre></code>
</td>
</tr>
</table>
<br>
<hr width=100% size=1 color=silver>
<b>Version Information:</b>&nbsp;Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.57.0
</font>
</body>
</html>
<!-- 
[FileNotFoundException]: Could not load file or assembly &#39;dnx.clr.managed&#39; or one of its dependencies. The system cannot find the file specified.
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Activator.CreateInstance(String assemblyString, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(String assemblyName, String typeName)
at System.AppDomain.CreateInstance(String assemblyName, String typeName)
at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName)
at System.AppDomain.CreateAppDomainManager()
[TypeLoadException]: The domain manager specified by the host could not be instantiated.
at System.AppDomain.CreateAppDomainManager()
at System.AppDomain.Setup(Object arg)
at System.AppDomain.nCreateDomain(String friendlyName, AppDomainSetup setup, Evidence providedSecurityInfo, Evidence creatorsSecurityInfo, IntPtr parentSecurityDescriptor)
at System.AppDomain.InternalCreateDomain(String friendlyName, Evidence securityInfo, AppDomainSetup info)
at System.AppDomain.CreateDomain(String friendlyName, Evidence securityInfo, AppDomainSetup info)
at AspNet.Loader.Bootstrapper.LoadApplicationNet45(String appId, String appConfigPath, IProcessHostSupportFunctions supportFunctions, LoadApplicationData* pLoadAppData, Int32 loadAppDataSize, String runtimePackagePath, String appBasePath)
at AspNet.Loader.Bootstrapper.LoadApplication(String appId, String appConfigPath, IProcessHostSupportFunctions supportFunctions, LoadApplicationData* pLoadAppData, Int32 loadAppDataSize)
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at System.Web.Hosting.ProcessHost.System.Web.Hosting.IProcessHostLite.ReportCustomLoaderError(String appId, Int32 hr, AppDomain newlyCreatedAppDomain)
--- End of stack trace from previous location where exception was thrown ---
at System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironment(String appId, IApplicationHost appHost, HostingEnvironmentParameters hostingParameters)   at System.Web.HttpRuntime.HostingInit(HostingEnvironmentFlags hostingFlags, PolicyLevel policyLevel, Exception appDomainCreationException)
[HttpException]: The domain manager specified by the host could not be instantiated.
at System.Web.HttpRuntime.FirstRequestInit(HttpContext context)
at System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context)
at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context)
-->

上面的片段在页面底部有一些关于错误的详细信息,但我无法解释。。。

我不认为出版是问题所在。我认为我在IIS中做错了什么。。。无论如何,任何关于如何将MVC 6应用程序发布到本地IIS的建议都将不胜感激!谢谢


更新

有趣的观察。。。我尝试按照以下说明将Microsoft Azure作为Web应用程序进行部署:https://azure.microsoft.com/en-us/documentation/articles/cloud-services-continuous-delivery-use-vso-git/

该应用程序在我的本地机器上构建得很好,没有任何错误,但当我尝试使用Git/Team Services集成部署到Azure时,我收到了以下错误:

body {
font-family: Verdana, sans-serif;
}
span {
color: #c00;
font-weight: bold;
font-style: italic;
}
Build started 6/25/2015 9:50:58 PM.<br>
&nbsp;&nbsp;&nbsp;&nbsp;1>Project "C:asrcDerekFoulk.sln" on node 1 (default targets).<br>
&nbsp;&nbsp;&nbsp;&nbsp;1>ValidateSolutionConfiguration:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Building solution configuration "Debug|Any CPU".<br>
&nbsp;&nbsp;&nbsp;&nbsp;1>Project "C:asrcDerekFoulk.sln" (1) is building "C:asrcsrcDerekFoulkDerekFoulk.xproj" (2) on node 1 (default targets).<br>
&nbsp;&nbsp;&nbsp;&nbsp;2>PrepareForBuild:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Creating directory "....artifactsobjDerekFoulkDebug".<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PreComputeCompileTypeScript:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;C:Program Files (x86)Microsoft SDKsTypeScript1.4tsc.exe  --noEmitOnError COMPUTE_PATHS_ONLY<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CompileTypeScript:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Skipping target "CompileTypeScript" because it has no outputs.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GetRuntimeToolingPathTarget:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>Cannot find DNX runtime dnx-clr-win-x86.1.0.0-beta4 in the folder: C:Usersbuildguest.dnxruntimes</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;2>C:Program Files (x86)MSBuildMicrosoftVisualStudiov14.0DNXMicrosoft.DNX.targets(117,5): error : The Dnx Runtime package needs to be installed. See output window for more details. [C:asrcsrcDerekFoulkDerekFoulk.xproj]<br>
&nbsp;&nbsp;&nbsp;&nbsp;2>Done Building Project "C:asrcsrcDerekFoulkDerekFoulk.xproj" (default targets) -- FAILED.<br>
&nbsp;&nbsp;&nbsp;&nbsp;1>Done Building Project "C:asrcDerekFoulk.sln" (default targets) -- FAILED.<br>
<br>
Build FAILED.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"C:asrcDerekFoulk.sln" (default target) (1) -><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"C:asrcsrcDerekFoulkDerekFoulk.xproj" (default target) (2) -><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(GetRuntimeToolingPathTarget target) -> <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;C:Program Files (x86)MSBuildMicrosoftVisualStudiov14.0DNXMicrosoft.DNX.targets(117,5): error : The Dnx Runtime package needs to be installed. See output window for more details. [C:asrcsrcDerekFoulkDerekFoulk.xproj]<br>
<br>
&nbsp;&nbsp;0 Warning(s)<br>
&nbsp;&nbsp;1 Error(s)<br>
<br>
Time Elapsed 00:00:10.40<br>

所以我不能用默认的.NET 5/MVC 6 Web应用程序做任何事情?实际上,我只能预览它?


更新

我能够使用构建>发布>Microsoft Azure Web应用程序将该网站作为Web应用程序发布到Azure,但即使删除了所有内容并从头开始,我也无法从源代码管理(Git)/Visual Studio Team Services获得连续部署以进行部署。构建失败,仍在说

Build(-1,0)异常消息:MSBuild错误1已结束此生成。您可以在上述消息中找到有关此错误原因的更具体信息。(类型BuildProcessTerminateException)异常堆栈跟踪:位于System.Activities.Statements.Sthrow.Execute(CodeActivityContext上下文)在系统中。活动。CodeActivity。InternalExecute(ActivityInstance实例、ActivityExecutor执行器、BookmarkManager BookmarkManager)在系统中。活动。运行时。活动执行器。执行ActivityWorkItem。ExecuteBody(ActivityExecutor executor、BookmarkManager BookmarkManager、Location resultLocation)C: \Program Files(x86)\MSBuild\Microsoft\VisualStudio\v14.0\DNX\Microsoft.DNX.targets(117,0)需要安装Dnx运行时包。有关更多详细信息,请参见输出窗口。

是否有人能够通过Git/View Studio团队服务设置连续部署?如果是,怎么办?!


更新(从Git/Team Services持续构建)

因此,当构建失败时,可能会出现以下问题:

现在我们可以构建解决方案了。由于默认web模板的目标都是完整的。NET和。NET核心,我们预计当构建尝试访问环境时会失败。机器名称和环境。HomeController中的OSVersion变量。这种行为在中不起作用。NET核心(目前),所以我们可以对此进行评论。打开project.json并修改"framework"键,如图所示:

"frameworks": {
"dnx451": { }/*,
"dnxcore50": { }*/
},

更新

以下是失败生成的日志文件:OneDrive-日志文件希望有人能看到这一点,并能帮助我解决这个问题,这样我的网站将在我提交时部署到Azure。在开发过程中会很棒!

这有点难说,但可能是由于您的目标发布路径和IIS应用程序物理路径不匹配。。。

目标位置:c:\inetpub\wwwroot\DerekFoulk.com

与。

物理路径:C:\inetpub\wwwroot\DerekFoulk.com\wwwroot

谢谢你的帖子,我希望我的回答能帮助到别人。我遇到了与海报中关于"无法加载文件或程序集'dnx.clr.managed'或其依赖项之一"相同的错误。我没有注意到在我的应用程序池中"启用32位应用程序"设置为"False"。将其设置为"True"解决了我的问题。

这里解释部署过程。花几分钟时间阅读帖子中涉及的托管模型更改的链接。NET应用程序。

在确保我有权利之后。NET版本安装在我的服务器上(我使用了DNVM),我能够在本地IIS机器上启动并运行我的应用程序。

我希望这能帮助到别人!

这将特别有助于解决DnxRuntime问题。

当VS团队服务构建时,它需要我们在开发PC上构建的所有东西。

基本上,您可以创建一个预构建脚本,下载dnvm,安装它,最后为每个project.json文件调用dnu-restore。最好的方法是将所有代码都放在src子目录中,并有一个global.json文件。

我的解决方案基于这篇文章,您可以在其中找到脚本:https://msdn.microsoft.com/en-us/Library/vs/alm/Build/azure/deploy-aspnet5

关于部署到Azure:

正如Danie Sharpe所提到的https://msdn.microsoft.com/Library/vs/alm/Build/azure/deploy-aspnet5我开始工作。我需要做的一个改变是,我在回答这个问题时提到构建ASP。NET 5从Visual Studio Online ERROR_FILE_IN_USE迁移到Azure网站。

略有不同的路由不是使用Visual Studio发布(在VS Team Services上),而是使用DNU发布命令。我在一篇博客文章中详细介绍了这一点,你可以在这里找到:http://devonburriss.me/aspnet-vsonline-ci/

让我们知道你的进展。看起来你已经在这方面花了很多时间了。

最新更新