Cake build aliases for manipulating HOSTS file.

#addin nuget:?package=Cake.Hosts&version=1.5.1

<package id="Cake.Hosts" version="1.5.1" />

dotnet add package Cake.Hosts --version 1.5.1

<PackageReference Include="Cake.Hosts" Version="1.5.1" />


Functionalty to operate hosts-file. Requres admin permissions and will probably fail on your general CI server.

Mostly aimed on automation scripts rather than actual project builds.

Install via:
#addin "nuget:?package=Cake.Hosts"


AddHostsRecord(ICakeContext, string, string) Appends a record to the end of hosts file. If this value already exist, no modifications applied
HostsRecordExists(ICakeContext, string, string) Checks if a record already exists in hosts file
RemoveHostsRecord(ICakeContext, string, string) Removes a line with given IP address and domain name. If given pair does not exist in hosts file, no modifications applied