All Projects → gabrielweyer → cake-build

gabrielweyer / cake-build

Licence: MIT License
Demonstrates a basic build of a .NET NuGet package using https://cakebuild.net/

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to cake-build

demo-ci
Aula prática sobre servidores de Integração Contínua
Stars: ✭ 15 (-31.82%)
Mutual labels:  continuous-integration, github-actions
setup-scheme
Github Actions CI / CD setup for Scheme
Stars: ✭ 13 (-40.91%)
Mutual labels:  continuous-integration, github-actions
googletest-ci
Continuous integration (CI) + Google Test (gtest) + CMake example boilerplate demo
Stars: ✭ 14 (-36.36%)
Mutual labels:  circle-ci, github-actions
xray-action
... a GitHub action to import test results into "Xray" - A complete Test Management tool for Jira.
Stars: ✭ 16 (-27.27%)
Mutual labels:  continuous-integration, github-actions
development-hub
A continuous integration solution for Power Apps.
Stars: ✭ 21 (-4.55%)
Mutual labels:  continuous-integration, azure-devops
bump-everywhere
🚀 Automate versioning, changelog creation, README updates and GitHub releases using GitHub Actions,npm, docker or bash.
Stars: ✭ 24 (+9.09%)
Mutual labels:  continuous-integration, github-actions
github-create-release-action
Github Action that create Github Release automatically
Stars: ✭ 28 (+27.27%)
Mutual labels:  continuous-integration, github-actions
hasura-action
GitHub Action wrapping the Hasura CLI
Stars: ✭ 39 (+77.27%)
Mutual labels:  continuous-integration, github-actions
overview
Automate your workflows with GitHub actions for MATLAB.
Stars: ✭ 40 (+81.82%)
Mutual labels:  continuous-integration, github-actions
lychee-action
Github action to check for broken links in Markdown, HTML, and text files using lychee, a fast link checker written in Rust.
Stars: ✭ 89 (+304.55%)
Mutual labels:  continuous-integration, github-actions
link-snitch
GitHub Action to scan your site for broken links so you can fix them 🔗
Stars: ✭ 50 (+127.27%)
Mutual labels:  continuous-integration, github-actions
qodana-action
⚙️ Scan your Java, Kotlin, PHP, Python, JavaScript, TypeScript projects at GitHub with Qodana
Stars: ✭ 112 (+409.09%)
Mutual labels:  continuous-integration, github-actions
noise-php
A starter-kit for your PHP project.
Stars: ✭ 52 (+136.36%)
Mutual labels:  continuous-integration, github-actions
cpp14-project-template
A simple, cross-platform, and continuously integrated C++14 project template
Stars: ✭ 64 (+190.91%)
Mutual labels:  continuous-integration, appveyor
prettier
🔨 Native, blazingly-fast Prettier CLI on Github Actions
Stars: ✭ 19 (-13.64%)
Mutual labels:  continuous-integration, github-actions
nodejs-postgresql-azure
Repositório responsável pela série de artigos sobre Node.js com PostgreSQL
Stars: ✭ 70 (+218.18%)
Mutual labels:  azure-devops, github-actions
jmeter-aci-terraform
Scalable cloud load/stress testing pipeline solution with Apache JMeter and Terraform to dynamically provision and destroy the required infrastructure on Azure.
Stars: ✭ 114 (+418.18%)
Mutual labels:  azure-devops, azure-devops-pipelines
mojito-admin-starter
此项目主要为了演示如何自动化 Fullstack project 的 Infrastructure。
Stars: ✭ 17 (-22.73%)
Mutual labels:  azure-devops, github-actions
arduino-lint-action
GitHub Actions action to check Arduino projects for problems
Stars: ✭ 20 (-9.09%)
Mutual labels:  continuous-integration, github-actions
drupal9ci
One-line installers for implementing Continuous Integration in Drupal 9
Stars: ✭ 137 (+522.73%)
Mutual labels:  continuous-integration, github-actions

Cake build

Package Release Pre-release
Contoso.Hello.Logic MyGet MyGet
Contoso.Hello.SuperLogic MyGet MyGet
CI Status Platform(s) Framework(s) Test Framework(s)
AppVeyor Build Status Windows netstandard2.0, net461 net6.0, net461
Azure DevOps Build Status Linux netstandard2.0 net6.0
CircleCI Build Status Docker: mcr.microsoft.com/dotnet/sdk:6.0-focal netstandard2.0 net6.0
GitHub Build Status Windows netstandard2.0, net461 net6.0, net461

Demonstrates a basic build of a .NET NuGet package using Cake.

I tried to create a somewhat realistic scenario without writing too much code:

  • The solution contains two projects which will be packed as NuGet packages.
    • The SuperLogic project depends from Logic and when packing this project reference will be turned into a NuGet package reference (handled out of the box by dotnet pack).
    • The Logic project references a NuGet package from nuget.org via a PackageReference, dotnet pack will turn this into a package reference.
  • The projects target both netstandard2.0 and net461 so they can be used with the .NET Framework (net461 and above).
  • The solution contains a test project.
  • Use SemVer to version the DLLs and the NuGet packages.

I wrote a blog post about this experiment.

Table of contents

Pinning the version of Cake

Pinning the version of Cake guarantees you'll be using the same version of Cake on your machine and on the build server.

This is done by using Cake as a .NET local tool. The version is specified in .config\dotnet-tools.json.

Running locally

Pre-requisites

Initial setup on Windows

.\bootstrap.ps1

Initial setup on Linux / OS X

./bootstrap.sh

Run build script

dotnet cake build.cake

Benefits over a nuspec file

  • A single file describing the package and the project instead of two (*.csproj and *.nuspec)
  • References (projects or NuGet packages) are resolved automatically. There is no need to tweak a file manually any more!

Referencing a project without turning it into a package reference

The SuperLogic project depends on the ExtraLogic project but we don't want to ship ExtraLogic as a package. Instead we want to include Contoso.Hello.ExtraLogic.dll in the SuperLogic package directly. Currently this is not supported out of the box but the team is tracking it.

Luckily this issue provides a workaround. All the modifications will take place in SuperLogic.csproj.

  • In the <PropertyGroup> section add the following line:
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);IncludeReferencedProjectInPackage</TargetsForTfmSpecificBuildOutput>
<ProjectReference Include="..\ExtraLogic\ExtraLogic.csproj">
  <PrivateAssets>all</PrivateAssets>
</ProjectReference>
  • Finally add the target responsible of copying the DLL:
<Target Name="IncludeReferencedProjectInPackage">
  <ItemGroup>
    <BuildOutputInPackage Include="$(OutputPath)Contoso.Hello.ExtraLogic.dll" />
  </ItemGroup>
</Target>

CI

Each time a commit is pushed to main or features/*; AppVeyor, Azure DevOps, CircleCI and GitHub will build the changes.

In case of a successful build GitHub will:

  • On main
    • Create a GitHub release
    • Publish the NuGet packages (including symbols) to gabrielweyer feed
  • On features/*
    • Create a GitHub pre-release
    • Publish the NuGet packages (including symbols) to gabrielweyer-pre-release feed

When running on a platform that is not Windows, we can't target the .NET full Framework, hence the build script is calling IsRunningOnLinuxOrDarwin to detect the available capabilities.

AppVeyor

Build status is visible here.

  • Supports Linux, macOS and Windows hosted agents
  • Can create a GitHub release and tag the repository if required
  • Supports artifacts and test results
  • You can modify AppVeyor's build number programatically
    • Cake integrates with AppVeyor: publish test results, upload artifacts, update build number...
  • Partially supports files exclusion (commits are skipped as soon as they contain one file in the excluded list)

Azure DevOps

Azure DevOps does not offer a free an unlimited plan for open-source projects any more.

Build status is visible here.

  • Supports Docker, Linux, macOS and Windows hosted agents
  • Supports artifacts and test results
  • Supports files exclusion

CircleCI

Build status is visible here.

  • Supports Docker, Linux, macOS and Windows hosted agents
  • Supports artifacts

CircleCI has a few limitations:

  • Test results have to be in JUnit format, you can use the package JunitXml.TestLogger for a JUnit logger
  • Can't exclude files easily

GitHub

Build status is visible here.

  • Supports Docker, Linux, macOS and Windows hosted agents
  • Supports artifacts
  • Supports files exclusion

GitHub has a few limitations:

  • A third-party / custom Action is required to report test results
  • A third-party / custom Action is required to create a GitHub release

Status checks

The main branch is protected:

  • Force push is disabled on main
  • main cannot be deleted
  • Non-protected branches (such as features/*) cannot be merged into main until they satisfy:
    • An AppVeyor passing build
    • An Azure DevOps passing build
    • A CircleCI passing build
    • A GitHub passing build

After a branch was configured as protected, GitHub will suggest available status checks.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].