gpt4 book ai didi

c# - 打包 SF 无状态 ASP.NET Core Web 应用程序后代码丢失

转载 作者:太空狗 更新时间:2023-10-29 20:35:57 25 4
gpt4 key购买 nike

我创建了一个具有普通无状态服务和无状态 ASP.NET Core Web 应用程序的 Service Fabric 应用程序。在不更改任何默认代码的情况下,我尝试部署该应用程序。部署期间发生错误:

Register-ServiceFabricApplicationType : The BuildLayout of the application in
C:\SfDevCluster\Data\ImageBuilderProxy\AppType\AadMockApplicationType is invalid. Code is missing for service
TenantWebServerPkg.

检查我的包后,我发现包中没有代码,只有服务 list 文件和配置包:

enter image description here

我的 Web 应用程序服务 list :

<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest Name="TenantWebServerPkg"
Version="1.0.0"
xmlns="http://schemas.microsoft.com/2011/01/fabric"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ServiceTypes>
<!-- This is the name of your ServiceType.
This name must match the string used in RegisterServiceType call in Program.cs. -->
<StatelessServiceType ServiceTypeName="TenantWebServerType" />
</ServiceTypes>

<!-- Code package is your service executable. -->
<CodePackage Name="Code" Version="1.0.0">
<EntryPoint>
<ExeHost>
<Program>TenantWebServer.exe</Program>
<WorkingFolder>CodePackage</WorkingFolder>
</ExeHost>
</EntryPoint>
</CodePackage>

<!-- Config package is the contents of the Config directoy under PackageRoot that contains an
independently-updateable and versioned set of custom configuration settings for your service. -->
<ConfigPackage Name="Config" Version="1.0.0" />

<Resources>
<Endpoints>
<!-- This endpoint is used by the communication listener to obtain the port on which to
listen. Please note that if your service is partitioned, this port is shared with
replicas of different partitions that are placed in your code. -->
<Endpoint Protocol="http" Name="ServiceEndpoint" Type="Input" Port="8396" />
</Endpoints>
</Resources>
</ServiceManifest>

尝试了好几个小时后,我注意到代码包被发布到了不同的文件夹:C:\Users\username\AppData\Local\Temp\PublishTemp\TenantWebServer118

如何正确打包 Web 应用程序以包含代码包?

最佳答案

Note: The .NET Core tools for Visual Studio 2015 are no longer being updated, however if you are still using Visual Studio 2015, you need to have .NET Core VS 2015 Tooling Preview 2 installed.

Microsoft docs所述:

To develop ASP.NET Core Service Fabric applications, you should have the following workloads installed:

  • Azure development (under Web & Cloud)
  • ASP.NET and web development (under Web & Cloud)
  • .NET Core cross-platform development (under Other Toolsets)

更新:

问题:为什么代码包发布到不同的文件夹?

答案: Example (Powershell)注册一个应用类型

PS C:\> Copy-ServiceFabricApplicationPackage -ApplicationPackagePath "c:\work\PersistentToDoListService" -ImageStoreConnectionString "file:C:\SfDevCluster\Data\ImageStoreShare" -ApplicationPackagePathInImageStore "PersistentToDoListService"
PS C:\> Register-ServiceFabricApplicationType -ApplicationPathInImageStore "PersistentToDoListService"

Copy-ServiceFabricApplicationPackage将在 "c:\work\PersistentToDoListService" 文件夹中找到的应用程序包复制到图像存储区。该包被复制到图像存储中的相对路径“PersistentToDoListService”

Register-ServiceFabricApplicationType命令注册在相对路径“PersistentToDoListService”中找到的应用程序类型。

关于c# - 打包 SF 无状态 ASP.NET Core Web 应用程序后代码丢失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45629347/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com