-
Notifications
You must be signed in to change notification settings - Fork 18
Build & CI
This project contains a build script that shows how to package "dotnet cli"-based NuGet libraries and how to create and deploy ASP.NET Core projects to a Service Fabric cluster.
The build script is psake-based and can easily be integrated into a build server.
The build script consists of the following files:
-
tools/psake
: the psake library -
build-definition.ps1
: contains psake tasks for restoring, building and packaging the projects -
build-helpers.ps1
: helper methods to create the Service Fabric packages -
build.ps1
: can be used to start the build on the local machine -
appveyor.yml
: shows how to call the build script from AppVeyor
the samples use the StatelessHost-project - refer to the documentation for further details. This means that all ServiceManifest.xml files have been modified.
build.ps1
starts the psake based build process. The build script contains the following steps:
- init: validate parameters
- clean: empty/create "artifacts" folder
- dotnet-install: installs the latest ".NET Core SDK" if it is not yet installed (this is required if the build server (e.g. AppVeyor) does not have it installed)
- dotnet-restore: runs
dotnet restore
on on the solution. - dotnet-build: runs
dotnet build
on the solution. - dotnet-test: just a placeholder in case I ever find the time to write some tests :-)
- dotnet-pack: not required for running the Service Fabric samples. We need this to deploy our NuGet-packages. This just shows how you could use this in your own projects. It runs
dotnet pack
-
packageServiceFabric: That's the important one! It creates the folder structure required by Service Fabric to do the deployment. (application folder which contains
ApplicationManifest.xml
, a folder for each service which contains theServiceManifest.xml
and the application in a "Code" folder)- it looks up the service fabric application (GatewaySample in this case) to get all referenced services (HttpGateway, HttpService in this case).
- For every service, it runs
dotnet publish
to move the application to theCode
folder in the service output folder - It's important that the folder name (e.g
Code
) and theCodePackage
name in ServiceManifest.xml are the same!
- It copies everything from the service's
PackageRoot
to the output folder of the service (this copies the ServiceManifest.xml) - it copies all necessary stuff from the Service Fabric application project into the output folder. (including the deploy-script and the publish profiles)
- It appends the build number in all ServiceManifest.xml files and in the ApplicationManifest.xml - this allows for continuous integration/continuous delivery. If the build script is started locally, the build number suffix is "local-". A CI system should overwrite this (see
appveyor.yml
for an example). - The necessary scripts are in
build-helpers.ps1
After the build script succeeded, the Service Fabric application can be deployed to any configured cluster by executing the following commands in a PowerShell window. This example would be the script to build and deploy to your local cluster:
.\build.ps1 # if not yet called
cd .\artifacts\GatewaySample\
. .\Scripts\Deploy-FabricApplication.ps1 `
-ApplicationPackagePath .\ApplicationPackage\ `
-PublishProfileFile .\PublishProfiles\Local.xml `
-OverwriteBehavior Always
Note the dot and space at the beginning of the last line. See this post for details about why this is required.