Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code missing after packaging SF stateless ASP.NET Core web application

I created a Service Fabric application with a normal stateless service and a stateless ASP.NET Core web application. Without changing any of the default code I tried to deploy the application. During deployment an error occured:

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

After inspecting my package I noticed that the package did not include the code but only the service manifest file and the configuration package:

enter image description here

My web application service manifest:

<?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>

After trying for many hours I noticed that the code package is published to a different folder: C:\Users\username\AppData\Local\Temp\PublishTemp\TenantWebServer118

How do I package the web application correctly so the code package is included?

like image 263
Wouter B Avatar asked Aug 11 '17 07:08

Wouter B


Video Answer


1 Answers

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.

As stated in 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)

Updated:

Question: Why the code package is published to a different folder?

Answer: Example (Powershell) Register an application type

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

Copy-ServiceFabricApplicationPackage copies the application package found in the "c:\work\PersistentToDoListService" folder to the image store. The package is copied at the relative path "PersistentToDoListService" in image store.

Register-ServiceFabricApplicationType command registers the application type found in the relative path "PersistentToDoListService".

like image 101
youpilat13 Avatar answered Oct 12 '22 23:10

youpilat13