【问题标题】:Azure cspack.exe throws System.Runtime.Remoting.RemotingExceptionAzure cspack.exe 引发 System.Runtime.Remoting.RemotingException
【发布时间】:2023-10-03 06:26:01
【问题描述】:

我已安装 Azure SDK 2.5。当我运行命令时:

"C:\Program Files\Microsoft SDKs\Azure\.NET SDK\v2.5\bin\cspack.exe" .\ServiceDefinition.csdef "/out:Package.cspkg" 

我遇到了一个异常:

Unhandled Exception: System.Runtime.Remoting.RemotingException: Object '/8ba37d11_3239_4c7c_9f1a_aa967b1dc5e9/eocq0iwbskmwhdjkfth7xtqy_4.rem' has been disconnected or does not exist at the server.
at System.IO.FileStream.get_CanRead()
at MS.Internal.IO.Zip.ZipIOLocalFileBlock.CheckFileAccessParameter(Stream stream, FileAccess access)
at MS.Internal.IO.Zip.ZipIOLocalFileBlock.GetStream(FileMode mode, FileAccess access)
at System.IO.Packaging.ZipPackagePart.GetStreamCore(FileMode mode, FileAccess access)
at System.IO.Packaging.PackagePart.GetStream(FileMode mode, FileAccess access)
at Microsoft.ServiceHosting.Tools.Packaging.Utils.CopyFullStreamToPart(Stream source, PackagePart part, PackageManifest manifest)
at Microsoft.ServiceHosting.Tools.Packaging.PackageCreator.CreateRolePackages(ModelProcessor modelProcessor, PackageManifest applicationManifest, Package applicationPackage)
at Microsoft.ServiceHosting.Tools.Packaging.PackageCreator.CreatePackage(Stream outputStream, Action`1 postProcess, PackageRestrictions restrictions)
at Microsoft.ServiceHosting.Tools.Packaging.ServiceApplicationPackage.CreateServiceApplicationPackage(String serviceModelFileName, String serviceDescriptionFile, Stream output, IPackageSecurity encrypt, Dictionary`2 namedStreamCollection, String userInfo, EventHandler`1 rolePackagePartAddedHandler)
at Microsoft.ServiceHosting.Tools.MSBuildTasks.PackageCreator.CreateServiceApplicationPackage(String serviceRdFilePath, String processedServiceDefinitionFile, FileStream packageStream, Dictionary`2 namedStreams, Dictionary`2 rolesDictionary)
at Microsoft.ServiceHosting.Tools.MSBuildTasks.PackageCreator.CreateServiceApplicationPackage(String serviceRdFilePath, String processedServiceDefinitionFile, FileStream packageStream, Dictionary`2 namedStreams, Dictionary`2 rolesDictionary)
at Microsoft.ServiceHosting.Tools.MSBuildTasks.CSPack.TryCreatePackage(ServiceDefinitionModel sm)
at Microsoft.ServiceHosting.Tools.MSBuildTasks.CSPack.Execute()
at Microsoft.ServiceHosting.Tools.Packaging.Program.Main(String[] args)

同时这个包在其他机器上构建成功。

有人遇到过这个问题吗?

【问题讨论】:

    标签: azure remoting azure-sdk-.net cspack


    【解决方案1】:

    这是 SDK 2.5 中针对长时间运行的 CSPack 进程引入的一个错误。在即将发布的 2.6 版本中对此进行了修复。

    【讨论】:

    • 是的,Microsoft 支持人员表示他们希望 SDK 2.6 中的 CsPack.exe 的稳定性得到改进。所以,我正在等待 SDK 2.6 发布。
    • *.com/questions/30119422/… 有什么解决办法吗?\
    • 这在 SDK 2.6 中没有修复
    【解决方案2】:

    在我们的例子中,它只发生在我们用于自动部署到我们的测试环境的一台机器(Win Server 2008R2)上,我们可以使用 CSPack 解决方法。

    解决方法包括两个步骤:

    1. MSBuild 失败,但在创建包的最后一步失败,因此应打包到包中的所有文件都在文件夹“AzureProject\obj\Release\WebRoleName”中。
    2. 手动运行 CSPack:

      $releaseWebAppPath = "$tempPath\AzureProject\obj\Release\WebRoleName"
      & $cspackPath "$slnRootPath\AzureProject\ServiceDefinition.csdef" /role:"WebRoleName;$releaseWebAppPath" /sitePhysicalDirectories:"WebRoleName;Web;$releaseWebAppPath" /out:"$packagePath"
      

    这将创建一个您应该能够部署的包。

    【讨论】:

    • 从我使用 CSPack 的主题描述中可以看出。对于 CSPack 和 MSBuild,该问题是可重现的。