VS2015 中的 Azure 调试环境在启动时崩溃

Azure Debugging Environment in VS2015 crashes on start

这最近才突然发生。我尝试了在 Stack 和其他论坛上可以找到的所有解决方案,但到目前为止没有任何效果。

当我尝试开始调试 Azure 工作者角色时,据我所知:

调试 window 显示:The program '[2208] WaIISHost.exe' has exited with code 0 (0x0).

我 运行 Visual Studios 处于管理模式,正确的项目设置为 start-up 并使用 IIS Express 作为开发服务器。

我已尝试使用相同的基础项目创建新的 Azure 辅助角色,但没有成功。系统事件日志没有任何信息。我试过重新安装 VS2015 并单独安装 Azure SDK (v.2.7.1),没有任何变化。当我查看计算模拟器时,在它消失之前它说:

[fabric] Role Instance: deployment27(250).Web.0
[fabric] Role state Unhealthy
[fabric] Role state Stopped

然而,我能够在解决方案中启动其他工作者角色项目,这让我相信项目中一定有某些东西以某种方式与损坏的工作者角色相关联。我在这个阶段没有想法,所以非常感谢任何帮助。

更新

查看 C:\Users\<UserAccount>\AppData\Local\dftmp\Resources\<GUID>\directory\DiagnosticStore 中的 WallSHost.log 文件给我一个 Invalid name 错误:

WaIISHost Information: 0 : [00003568:00000001, 2015-10-06 20:02:05.472, INFO ] Attempt Deploy with RoleInstanceId=deployment27(252).Web_IN_0 RoleRoot=C:\Web\csx\Debug\roles\Web\ optional SitesDestination=
WaIISHost Information: 0 : [00003568:00000001, 2015-10-06 20:02:08.153, ERROR] Exception:System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: Invalid name.
Parameter name: name (Fault Detail is equal to An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.ArgumentException: Invalid name.
Parameter name: name
   at System.Security.AccessControl.NativeObjectSecurity.CreateInternal(ResourceType resourceType, Boolean isContainer, String name, SafeHandle handle, AccessControlSections includeSections, Boolean createByName, ExceptionFromErrorCode exceptionFromErrorCode, Object exceptionContext)
   at System.Security.AccessControl.FileSystemSecurity..ctor(Boolean isContainer, String name, AccessControlSections includeSections, Boolean isDirectory)
   at System.Security.AccessControl.DirectorySecurity..ctor(String name, AccessControlSections includeSections)
   at System.IO.DirectoryInfo.GetAccessControl(AccessControlSections includeSections)
   at Microsoft.WindowsAzure.ServiceRuntime.IISConfigurator.FileManager.AddAllowAceIterative(DirectoryInfo dir, FileSystemRights rights, IdentityReference[] accounts)
   at Microsoft.WindowsAzure.ServiceRuntime.IISConfigurato...).


WaIISHost Information: 0 : [00003568:00000001, 2015-10-06 20:02:08.157, ERROR] Exception:System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: Invalid name.
Parameter name: name (Fault Detail is equal to An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.ArgumentException: Invalid name.
Parameter name: name
   at System.Security.AccessControl.NativeObjectSecurity.CreateInternal(ResourceType resourceType, Boolean isContainer, String name, SafeHandle handle, AccessControlSections includeSections, Boolean createByName, ExceptionFromErrorCode exceptionFromErrorCode, Object exceptionContext)
   at System.Security.AccessControl.FileSystemSecurity..ctor(Boolean isContainer, String name, AccessControlSections includeSections, Boolean isDirectory)
   at System.Security.AccessControl.DirectorySecurity..ctor(String name, AccessControlSections includeSections)
   at System.IO.DirectoryInfo.GetAccessControl(AccessControlSections includeSections)
   at Microsoft.WindowsAzure.ServiceRuntime.IISConfigurator.FileManager.AddAllowAceIterative(DirectoryInfo dir, FileSystemRights rights, IdentityReference[] accounts)
   at Microsoft.WindowsAzure.ServiceRuntime.IISConfigurato...).

在重新安装 Visual Studios、Azure SDK、IIS 并查看日志文件后,我终于找到了问题所在:Web 项目中与我的辅助角色关联的 node_modules 文件夹。

我一删除文件夹,调试马上就开始了;尽管它不是 Visual Studios 解决方案的一部分。

从那以后,我在 Stack 上搜索了这个特定问题并找到了这个 post:

rmdir /s /q "$(ProjectDir)node_modules\" 添加到与辅助角色关联的项目属性内的 post-build 事件,将在 Azure 调试器启动之前删除 node_modules 文件夹。这不是一个完美的修复,但它会解决这个 Windows 无法处理长文件名的荒谬问题。

更新

刚刚找到更好的解决方案。使用 Microsoft 开发团队的 npm-windows-upgrade 模块将 npm 更新为 >= 3.x:

https://www.npmjs.com/package/npm-windows-upgrade

npm3.x中,node_modules文件夹中的模块以扁平结构存储。这应该有助于避免导致 Azure 调试器崩溃的路径的 256 个字符限制(前提是解决方案根目录的路径还不太长)。

默认情况下,在 Windows 上安装 Node 时,npm 版本 2 会预先捆绑(截至 2015 年 9 月 8 日)。使用常规 npm 更新命令 npm -g install npm@<version> 将不起作用,因为 Node 将始终查看安装附带的 npm 版本;这就是 npm-windows-upgrade 的用武之地。

使用管理员权限打开 Windows PowerShell 并运行执行以下任务以选择要安装的 npm 版本。

  1. Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
  2. npm install -g npm-windows-upgrade
  3. npm-windows-upgrade

补充阅读:

https://github.com/npm/npm/wiki/Troubleshooting#upgrading-on-windows https://github.com/npm/npm/issues/3697#issuecomment-114665926