This project shows an example on how to integrate Dotnet Affected with Nuke Build.
- Use dotnet-affected to trigger specific build tasks
- Seperate build files for different projects
- Pulumi deployment to Azure using Pulumi Automation
- Clone repository
git clone https://github.com/jwdb/Try.Dotnet.Affected/
- Install Nuke
dotnet tool install Nuke.GlobalTool --global
- Nuke ☢️ it from orbit 🚀
nuke
The project consists of multiple example projects and a build project. Example projects:
/Try.Dotnet.Affected/
This is a plain console app with a dependency to/Try.Dotnet.Affected.Dependency/
/Try.Dotnet.Affected.Sidestory/
Another plain console app with no dependencies./Try.Dotnet.Affected.Tests/
This has a reference to/Try.Dotnet.Affected/
and serves as a test-project for it./Try.Dotnet.Affected.StoryApi/
A simple WebApi with no external dependencies/Try.Dotnet.Affected.ProxyStoryApi/
This project has a implicit dependenc on the StoryApi through a app setting.
All these projects have their own Companion *.build.cs
under /build/Components/
. These files describe how the project should be Compiled, Tested, Published and Deployed.
The description on how this is done is contained into individual targets.
Every *.Build.cs
file has a Compile target that defines on how the project is built. This target has a dependency on The DotnetAffected Target.
This target is TriggeredBy the CompileSolution Target but only ran if the project is included in the ProjectsToBuild array .
When a project has Tests, a Test target can be added. Yet again this has a dependency on the DotnetAffected Target but also on the Compile Target.
This target is TriggeredBy the RunTestsSolution Target but only ran if the project is included in the ProjectsToBuild array.
If a project can be Published. a Publish target can be added. In the same way as the previous targt, this has a dependency on DotnetAffected and the Compile Target.
This target is TriggeredBy the RunTestsSolution Target but only ran if the project is included in the ProjectsToBuild array.
The most complicated step. The step is divided into two parts: DeployStack and PublishStack.
This target is to setup the infrastructure using Pulumi. This function makes it possible to add extra items to the Pulumi stack:
IPulumiTargets.Stack.With(() => { })
This function either has a Action
as parameter or a Func<{[name] = Output<T>}>
where each property of the anonymous type of the type Output<T>
can be used in other Deploy targets using: IPulumiTargets.Stack.GetOutput<string>("ResourceGroupName")
.
This Target has a DependentFor constraint on IPulumiTargets.ProvisionPulumi. Using this constraint this Target will be ran before Provisioning has happened.
Using a combination of After and Before this Target can be placed on a certain place in the pulumi stack.
With this target the published project is deployed to the provisioned stack. This target yet again dependent on DotnetAffected but also on IPulumiTargets.ProvisionPulumi.
This target is TriggeredBy the PublishSoltuin Target but only ran if the project is included in the ProjectsToBuild array.