Package | Release | Pre-release |
---|---|---|
Contoso.Hello.Logic |
||
Contoso.Hello.SuperLogic |
CI | Status | Platform(s) | Framework(s) | Test Framework(s) |
---|---|---|---|---|
AppVeyor | Windows |
netstandard2.0 , net461 |
netcoreapp2.2.0 , net461 |
|
Azure DevOps | Linux |
netstandard2.0 |
netcoreapp2.2.0 |
|
CircleCI | Docker : microsoft/dotnet:2.2.103-sdk-bionic |
netstandard2.0 |
netcoreapp2.2.0 |
|
Travis CI | Linux , OS X |
netstandard2.0 |
netcoreapp2.2.0 |
Demonstrates a basic build of a .NET Core
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 fromLogic
and when packing this project reference will be turned into aNuGet
package reference (handled out of the box bydotnet pack
). - The
Logic
project references aNuGet
package from nuget.org via aPackageReference
,dotnet pack
will turn this into a package reference.
- The
- The projects target both
netstandard2.0
andnet461
so they can be used with the.NET Framework
(net461
and above). - The solution contains a test project.
- Use
SemVer
to version theDLLs
and theNuGet
packages.- Note:
SemVer
is implemented viaGitVersion
.
- Note:
I wrote a detailed blog post about this experiment.
- .NET Core SDK v2.2.103 and higher
.\bootstrap.ps1
./bootstrap.sh
dotnet cake build.cake
- 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 anymore!
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>
- Prevent the project to be added as a package reference by making all assets private.
<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>
Pinning the version of Cake
guarantees you'll be using the same version of Cake
on your machine and in the build server.
Each time a commit is pushed to master
or features/*
; AppVeyor
, Azure DevOps
, CircleCI
and Travis CI
will build the changes.
In case of a successful build AppVeyor
will:
- On
master
- On
features/*
Build status is visible here.
Windows
andLinux
- Can target both
.NET Core
and.NET Framework
when running onWindows
- For this reason we'll publish the
NuGet
packages usingAppVeyor
- For this reason we'll publish the
- Can create a
GitHub
release andtag
therepository
if required - Supports artifacts and test results
- You can modify
AppVeyor
's build number programaticallyCake
integrates withAppVeyor
: publish test results, upload artifacts, update build number...
- Supports files exclusion
Build status is visible here.
Linux
,OS X
andWindows
- Can target both
.NET Core
and.NET Framework
when running onWindows
- Supports artifacts and test results
- Supports files exclusion
Build status is visible here.
Linux
andOS X
- Build in
Docker
containers - Supports artifacts and test results
- Test results have to be in
JUnit
format, you can use the packagedotnet-xunit-to-junit
to do the transformation
- Test results have to be in
- Can't exclude files easily
Build status is visible here.
Travis CI
has a few limitations:
Linux
andOS X
only so you can't build anynet*
Framework
s- For this reason I'm not publishing the
NuGet
packages fromTravis CI
build.cake
has been modified- Targets
netstandard2.0
/netcoreapp2.2.0
only on Travis (search forTravisCI.IsRunningOnTravisCI
)
- Targets
- For this reason I'm not publishing the
- Doesn't parse test result files
- Artifacts have to be uploaded to
S3
- Can't exclude files easily
The master
branch is protected
:
- Force push is disabled on
master
master
cannot be deleted- Non-protected branches (such as
features/*
) cannot be merged intomaster
until they satisfy:- An
AppVeyor
passing build - A
Travis
passing build - A
CircleCI
passing build
- An
After a branch was configured as protected
, GitHub
will suggest available status checks.