【问题标题】:Deploy Visual Studio Web App to IIS (Maybe Even Azure Continuous Deployment Git)?将 Visual Studio Web App 部署到 IIS(甚至可能是 Azure 持续部署 Git)?
【发布时间】:2015-06-25 20:29:36
【问题描述】:

我正在尝试从 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 网络发布

作者告诉你:

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

所以我在“发布网络”期间使用的值:

  • 个人资料名称:DerekFoulk.com
  • 目标位置:c:\inetpub\wwwroot\DerekFoulk.com
  • 配置:发布
  • 目标 DNX 版本:默认 (dnx-clr-win-x86.1.0.0-beta4)​​em>
  • 发布脚本:使用 PowerShell 脚本发布

然后我看到了:

您的应用程序将发布到:

C:\inetpub\wwwroot\DerekFoulk.com

所以我点击了发布


添加到 IIS 7.5

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

然后我打开 IIS 并右键单击 Default Web Site 并点击 Add Application。我使用了以下配置:

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

然后我点击 Test Settings 并收到以下错误消息:

执行此操作时出错。

详情:

应用路径无效

作者没有提到检查设置,即使我知道这意味着事情不会正常,我还是点击了OK

最后,作者说:

转到 TestApp 文件夹下的 Windows 资源管理器中的安全性。添加Authenticated Users组帐号并赋予其读取和执行权限。

所以我右键单击目录 (C:\inetpub\wwwroot\DerekFoulk.com) 并转到 Properties > Security 并没有看到 Authenticated Users 组.但是,我确实看到 IIS_IUSRS 具有 读取和执行 权限。我认为这些是适当的权限,并继续尝试在浏览器中查看我的应用程序...

我导航到 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 [HKLM\Software\Microsoft\Fusion!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 [HKLM\Software\Microsoft\Fusion!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)
-->

上面的sn-p在页面底部有一些关于错误的详细信息,但我无法解释它们......

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


更新

有趣的观察...我尝试按照以下说明将其作为 Web 应用程序部署到 Microsoft Azure: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:\a\src\DerekFoulk.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:\a\src\DerekFoulk.sln" (1) is building "C:\a\src\src\DerekFoulk\DerekFoulk.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 "..\..\artifacts\obj\DerekFoulk\Debug\".<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PreComputeCompileTypeScript:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.4\tsc.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:\Users\buildguest\.dnx\runtimes</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;2>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DNX\Microsoft.DNX.targets(117,5): error : The Dnx Runtime package needs to be installed. See output window for more details. [C:\a\src\src\DerekFoulk\DerekFoulk.xproj]<br>
&nbsp;&nbsp;&nbsp;&nbsp;2>Done Building Project "C:\a\src\src\DerekFoulk\DerekFoulk.xproj" (default targets) -- FAILED.<br>
&nbsp;&nbsp;&nbsp;&nbsp;1>Done Building Project "C:\a\src\DerekFoulk.sln" (default targets) -- FAILED.<br>
<br>
Build FAILED.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"C:\a\src\DerekFoulk.sln" (default target) (1) -><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"C:\a\src\src\DerekFoulk\DerekFoulk.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)\MSBuild\Microsoft\VisualStudio\v14.0\DNX\Microsoft.DNX.targets(117,5): error : The Dnx Runtime package needs to be installed. See output window for more details. [C:\a\src\src\DerekFoulk\DerekFoulk.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 应用程序做任何事情?从字面上看,我只能预览吗?


更新

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

构建 (-1, 0) 异常消息:MSBuild 错误 1 ​​已结束此构建。您可以在上述消息中找到有关此错误原因的更多具体信息。 (类型 BuildProcessTerminateException) 异常堆栈跟踪:在 System.Activities.Statements.Throw.Execute(CodeActivityContext 上下文) 在 System.Activities.CodeActivity.InternalExecute(ActivityInstance 实例,ActivityExecutor 执行器,BookmarkManager 书签管理器) 在 System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor 执行器,BookmarkManager 书签管理器,位置结果位置) C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DNX\Microsoft.DNX.targets (117, 0) 需要安装 Dnx 运行时包。有关详细信息,请参阅输出窗口。

是否有人能够通过 Git/Visual Studio Team Services 设置持续部署?如果有,怎么做?!


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

所以构建失败时可能会出现以下问题:

现在我们可以构建解决方案了。由于默认 Web 模板同时针对完整的 .NET 和 .NET Core,因此我们预计构建会在尝试访问 HomeController 中的 Environment.MachineName 和 Environment.OSVersion 变量时失败。此行为在 .NET Core(当前)中不起作用,因此我们可以将其注释掉。打开project.json,修改“frameworks”键,如图:

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

更新

以下是失败构建的日志文件: OneDrive - Log Files 希望有人看到这一点并可以帮助我解决问题,以便在我推送提交时我的站点将部署到 Azure。在开发过程中会很棒!

【问题讨论】:

    标签: asp.net iis visual-studio-2015 asp.net-core-mvc azure-devops


    【解决方案1】:

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

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

    对比

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

    【讨论】:

    • 是的,我不确定。编写教程的人专门引用了这个目录,并评论说确保使用这个路径。我了解到现在对“网站”和“网络应用程序”有不同的要求。过去,您将站点目录复制到 inetpub 并在 IIS 中创建了一个新站点(直截了当)并确保有一个“index.*”或“Default.*”文件。木已成舟。不过,这些新应用程序并非如此(我认为)。我会在那个位置多玩一些,看看会发生什么。谢谢!
    【解决方案2】:

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

    【讨论】:

      【解决方案3】:

      部署过程解释here。花几分钟时间阅读文章中的链接,这些链接涉及 IIS 上 .NET 应用程序托管模型的更改。

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

      我希望这对某人有帮助!

      【讨论】:

        【解决方案4】:

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

        当 VS Team Services 构建时,它需要我们用于在开发 PC 上构建的所有东西。

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

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

        【讨论】:

        • 按照上面的链接,我已经成功地为 Azure 上的 Asp.Net 5 站点进行了持续构建。在我几乎遵循这封信的链接(有效)之前,我花了很多时间失败和搞砸。我仍然在部署期间锁定文件,因此可能必须在部署期间停止/启动服务。不过现在不在乎:-)
        • 感谢您的资源!我会看看这是否能解决我的问题。如果是这样,我会将其标记为答案:) 谢谢
        【解决方案5】:

        关于部署到 Azure:

        正如 Danie Sharpe 所说,我正在使用 https://msdn.microsoft.com/Library/vs/alm/Build/azure/deploy-aspnet5。我需要在回答这个问题Build ASP.NET 5 to Azure websites from Visual Studio Online ERROR_FILE_IN_USE 时提到一个更改。

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

        让我们知道您的进展情况。看来您已经在这方面花费了很多时间。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2011-05-07
          • 1970-01-01
          • 1970-01-01
          • 2016-03-25
          • 1970-01-01
          • 2014-11-16
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多