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

时间:2017-08-11 07:27:09

标签: c# asp.net azure-service-fabric service-fabric-stateless

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

  

Register-ServiceFabricApplicationType:应用程序的BuildLayout   C:\ SfDevCluster \ Data \ ImageBuilderProxy \ AppType \ AadMockApplicationType无效。服务缺少代码
  TenantWebServerPkg。

检查我的包后,我注意到包中没有包含代码,只包含服务清单文件和配置包:

enter image description here

我的网络应用程序服务清单:

<?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应用程序,以便包含代码包?

1 个答案:

答案 0 :(得分:2)

  

注意:   Visual Studio 2015的.NET Core工具不再更新,但如果您仍在使用Visual Studio 2015,则需要安装.NET Core VS 2015 Tooling Preview 2

Microsoft docs中所述:

  

要开发ASP.NET Core Service Fabric应用程序,您应该安装以下工作负载:

     
      
  • Azure开发(在 Web&amp; Cloud 下)
  •   
  • ASP.NET和网站开发(在 Web&amp; Cloud 下)
  •   
  • .NET Core跨平台开发(在其他工具集下)
  •   

更新

问题:为什么代码包会发布到其他文件夹?

答案: 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”文件夹中的应用程序包复制到映像存储中。该软件包将复制到映像存储中的 relative 路径“PersistentToDoListService”

Register-ServiceFabricApplicationType命令注册 relative 路径“PersistentToDoListService”中的应用程序类型。