c# - 服务 MyServicePkg 缺少代码

标签 c# .net visual-studio-2017 azure-service-fabric

我正在尝试像这样升级我的应用程序:

enter image description here

失败并出现以下错误:

enter image description here

错误详情:

2>Test-ServiceFabricApplicationPackage : The BuildLayout of the application in
2>C:\Users\me\AppData\Local\Temp\TestApplicationPackage_2205895293421\4myc2vpp.bdq\Debug is invalid. Code is
2>missing for service MyServicePkg.
2>At C:\Program Files\Microsoft SDKs\Service
2>Fabric\Tools\PSModule\ServiceFabricSDK\Publish-UpgradedServiceFabricApplication.ps1:135 char:38
2>+ ... nSuccess = (Test-ServiceFabricApplicationPackage $AppPkgPathToUse -Im ...
2>+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2> + CategoryInfo : InvalidOperation: (:) [Test-ServiceFabricApplicationPackage], FabricImageBuilderValidati
2> onException
2> + FullyQualifiedErrorId : TestApplicationPackageErrorId,Microsoft.ServiceFabric.Powershell.TestApplicationPackage 2>
2>Finished executing script 'Deploy-FabricApplication.ps1'.
2>Time elapsed: 00:00:40.4035177
2>The PowerShell script failed to execute.
========== Build: 1 succeeded, 0 failed, 46 up-to-date, 0 skipped ==========
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========

这是我为该特定项目设置的属性:

enter image description here

我做错了什么?这个异常是什么意思?

最佳答案

我同意 Hans Passant 的评论:

The most basic mishap is that the name you used in the ServiceManifest.xml file does not match the name of the .exe that your project generates

它在您的调试输出中也可见,因为构建成功但发布失败。

========== Build: 1 succeeded, 0 failed, 46 up-to-date, 0 skipped ========== ========== Publish: 0 succeeded, 1 failed, 0 skipped ==========

它可能以多种方式发生,很可能是由于重命名项目或重命名程序集名称。如果您重命名项目或项目的 Assembly Name,您的构建可执行文件将根据该名称。考虑以下情况。

Application Properties

我将 Assembly Name 从“MyService”重命名为“MyRenamedService”。因此构建可执行文件将是 MyRenamedService.exe。因此,您必须在 ServiceManifest.xml 中进行设置。

<CodePackage Name="Code" Version="1.0.0">
    <EntryPoint>
      <ExeHost>
        <Program>MyRenamedService.exe</Program>
        <WorkingFolder>CodePackage</WorkingFolder>
      </ExeHost>
    </EntryPoint>
</CodePackage>

确定构建可执行路径的最佳方法是构建解决方案。它将在输出窗口中显示可执行文件的完整路径。

1>------ Build started: Project: Web1, Configuration: Debug Any CPU ------
1>Web1 -> C:\.....\Application2\Web1\bin\Debug\net461\win7-x64\MyRenamedService.exe
2>------ Build started: Project: Application2, Configuration: Debug x64 ------
========== Build: 2 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

这里的Web1是我开始的Project Name,MyRenamedService.exe是build executable name(因为我重命名了Assembly Name),应该在ServiceManifest.xml 如上所示。

关于c# - 服务 MyServicePkg 缺少代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48772069/

相关文章:

c# - 使用 Microsoft.Bcl.Async 的 .NET 4.0 程序集的 RegAsm 失败

c# - DataSource 改变前的 DataGridView 事件

c# - 缺少 Novacode 命名空间

c# - 串行端口 Port.Write() 命令

c# - WPF框架如何处理MVVM中属性的循环更新?

c# - Entity Framework DbContext 未使用依赖注入(inject)进行处理

c# - 在托管 C++ 中使用 C# DLL(命令行)

routes - 如何在一个解决方案中为两个单独的项目在 asp.net core 中设置路由?

git - Visual Studio 2017 - Git 因 fatal error 而失败

c# - .NET Core 发布的应用程序因 FileNotFoundException 而失败