Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ macos-14, ubuntu-22.04, windows-latest ]
os: [ macos-latest, ubuntu-latest, windows-latest ]

env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
Expand All @@ -47,7 +47,7 @@ jobs:
- name: Set up dotnet
uses: actions/setup-dotnet@6bd8b7f7774af54e05809fcc5431931b3eb1ddee # 4.0.1
with:
dotnet-version: 8
dotnet-version: 10
dotnet-quality: ga

- name: Build
Expand Down
33 changes: 9 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,19 @@

# MAINTAINER Jan Friedrich

FROM ubuntu:20.04
ENV DEBIAN_FRONTEND=noninteractive \
TZ=Etc/UTC
# Ubuntu 24.04 (noble) with the .NET 10 SDK already installed - noble is the only Ubuntu
# variant published for .NET 10. The reference is fully qualified, so it needs no registry
# configuration and no login, unlike the short name it replaces.
FROM mcr.microsoft.com/dotnet/sdk:10.0-noble
ENV TZ=Etc/UTC

# Install Mono SDK (compiler, msbuild, runtime, etc.)
RUN apt-get update && \
apt-get install -y gnupg ca-certificates && \
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF && \
echo "deb https://download.mono-project.com/repo/ubuntu stable-focal main" | tee /etc/apt/sources.list.d/mono-official-stable.list && \
apt-get update && \
apt-get install -y mono-complete && \
rm -rf /var/lib/apt/lists/*
# Mono is not required: the net4x targets are compiled against the
# Microsoft.NETFramework.ReferenceAssemblies packages that the .NET SDK references implicitly.
# Mono would only be needed to *execute* net4x assemblies, which this image does not do.

# Check Mono version
RUN mono --version

RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y wget \
&& apt-get install -y tree \
&& wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh \
&& chmod +x ./dotnet-install.sh \
&& ./dotnet-install.sh --channel 8.0
ENV DOTNET_NOLOGO=true
ENV DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true
ENV DOTNET_ROOT=/root/.dotnet
ENV PATH="$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools"


ADD . /logging-log4net
RUN dotnet restore /logging-log4net/src/log4net.sln
RUN dotnet build -c Release /logging-log4net/src/log4net.sln
Expand Down
63 changes: 28 additions & 35 deletions doc/BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ Log4net provides support for the following targets

TL;DR (Windows):
- install Visual Studio Build Tools (at least VS2019)
- install nodejs (at least v16)
- install dotnet (v8+) and the .NET SDK (current latest)
- install the .NET SDK (v10 or better - the sources use C# 14 language features)
- in the project folder:
- `npm i`
- `npm run build`
- `dotnet build src/log4net.sln`
- `dotnet test src/log4net.sln`

TL;DR (Docker):
- install docker (if you haven't already)
Expand All @@ -25,49 +24,43 @@ TL;DR (Docker):
- `dotnet test /logging-log4net/src/log4net.sln`

TL;DR (!Windows):
- install the dotnet SDK - v8 or better
- install Mono (you're going to need it to target certain versions of .NET)
- install nodejs 16+
- in the project folder:
- `npm i`
- `export DOTNET_CORE=1 npm run build`
- we force using `dotnet` on non-windows targets for now. At some point,
this should become automatic
- install the dotnet SDK - v10 or better (the sources use C# 14 language features)
- in the project folder:
- `dotnet build src/log4net.sln`
- `dotnet test src/log4net.sln`
- Mono is *not* required. The `net462` / `net472` targets are compiled against the
`Microsoft.NETFramework.ReferenceAssemblies` packages that the .NET SDK references
implicitly. Mono would only be needed to *execute* net4x assemblies.
- the `log4net.Tests` project skips `net462` on non-Windows platforms: VSTest hosts net4x tests
through `TestHostNetFramework/testhost.exe`, which needs a .NET Framework runtime - Mono, off
Windows. The Ubuntu 24.04 and macOS 26 runner images no longer ship Mono, so the run would
abort with `TESTRUNABORT`. The `net462` tests run only on the Windows job in CI.

## The full story

Options:
- build locally. Suggested environment:
- Pre-requisites:
- Visual Studio 2019 Build Tools
- include desktop targets at least
- include dotnet core targets or download and install
the latest dotnet sdk (you will need at least v8)
- the .NET SDK, at least v10 (the sources use C# 14 language features)
- on Windows: Visual Studio 2019 Build Tools or later, including desktop targets
- only Windows can *run* the `net462` tests; elsewhere that target is skipped
- Binaries can be built with a Visual Studio or Rider installation
- Binaries, packages and a release zip can be built via commandline
- Ensure that you have a reasonably modern NodeJS installed (at least version 8+)
- `npm ci`
- `npm run build`
- optionally `npm test` to run all tests
- optionally `npm run release` to generate release artifacts
- build locally (CLI edition)
- install nodejs (at least v16)
- `npm i`
- `npm run build`
- build via docker for windows, using the `build-with-docker-for-windows.bat` script
- build via the vs2019 Windows AppVeyor image. There is an appveyor.yml file
included which (should) build if you set up AppVeyer to track
your fork. AppVeyer is free for open-source projects.
(TODO: should have a link to the official AppVeyor build)
- `dotnet build src/log4net.sln`
- optionally `dotnet test src/log4net.sln` to run all tests
- release artifacts are generated by the scripts under `scripts/`:
- `scripts/build-preview.ps1` for a preview package
- `scripts/build-release.ps1` for a full release
- build via docker, see the Docker section above

## Updating the site

Log4Net uses Maven to build the site. Source artifacts can be found under `src/site`.
Building the site can be accomplished with `npm run build-site`. You should have maven
installed:
- Windows: get it from Scoop
- OSX: get it from Homebrew
- Linux: use your package manager
Building the site can be accomplished with `./mvnw site` (`.\mvnw.cmd site` on Windows) - the
committed Maven wrapper fetches the pinned Maven version, so only a JDK is required. This is
also what `scripts/build-release.ps1` uses. The `antora` profile inherited from `logging-parent`
activates automatically because `src/site/antora` exists; it installs Antora and runs it against
`antora-playbook.yaml`, so no separate npm step is needed.

The site will be generated in `target/site`, and can be viewed locally. Updates should
be pushed to the `asf-staging` branch of [https://github.com/apache/logging-log4net-site](https://github.com/apache/logging-log4net-site])
Expand Down
12 changes: 10 additions & 2 deletions scripts/build-preview.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@ param(
$Version = '3.4.0',
$Preview = '1'
)

Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
# $ErrorActionPreference alone does not apply to native commands: dotnet, gpg and git only set
# $LASTEXITCODE, so without this a failing build would still be signed and tagged.
# Requires PowerShell 7.3+.
$PSNativeCommandUseErrorActionPreference = $true

'building ...'
dotnet build -c Release "-p:GeneratePackages=true;PackageVersion=$Version-preview.$Preview" $PSScriptRoot/../src/log4net.sln
'signing ...'
gpg --armor --output $PSScriptRoot\..\build\artifacts\log4net.$Version-preview.$Preview.nupkg.asc --detach-sig $PSScriptRoot\..\build\artifacts\log4net.$Version-preview.$Preview.nupkg
gpg --armor --output $PSScriptRoot\..\build\artifacts\log4net.Ext.Mail.$Version-preview.$Preview.nupkg.asc --detach-sig $PSScriptRoot\..\build\artifacts\log4net.Ext.Mail.$Version-preview.$Preview.nupkg
gpg --armor --output $PSScriptRoot/../build/artifacts/log4net.$Version-preview.$Preview.nupkg.asc --detach-sig $PSScriptRoot/../build/artifacts/log4net.$Version-preview.$Preview.nupkg
gpg --armor --output $PSScriptRoot/../build/artifacts/log4net.Ext.Mail.$Version-preview.$Preview.nupkg.asc --detach-sig $PSScriptRoot/../build/artifacts/log4net.Ext.Mail.$Version-preview.$Preview.nupkg
'create tag?'
pause
'creating tag ...'
Expand Down
4 changes: 4 additions & 0 deletions scripts/build-release.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ param(

Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
# $ErrorActionPreference alone does not apply to native commands: dotnet, git, zip, gpg and mvnw
# only set $LASTEXITCODE, so without this a failing build would still be packaged and signed.
# Requires PowerShell 7.3+.
$PSNativeCommandUseErrorActionPreference = $true

function Write-HashAndSignature
{
Expand Down
20 changes: 0 additions & 20 deletions src/MonoForFramework.targets

This file was deleted.

17 changes: 17 additions & 0 deletions src/changelog/3.4.0/305-build-net4x-without-mono.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://logging.apache.org/xml/ns"
xsi:schemaLocation="https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
type="changed">
<issue id="305" link="https://github.com/apache/logging-log4net/pull/305"/>
<description format="asciidoc">
Mono is no longer required to build the `net462` and `net472` targets on Linux and macOS.
`MonoForFramework.targets` and its `FrameworkPathOverride` handling were removed in favour of
the `Microsoft.NETFramework.ReferenceAssemblies` packages that the .NET SDK already references
implicitly. Mono is still needed to *run* .NET Framework assemblies: CI moved to
`ubuntu-latest` (Ubuntu 24.04) and `macos-latest` (macOS 26), which no longer ship Mono, so
the `net462` tests now run only on the Windows job and the Mono guards in the test suite were
dropped. Support for *running* log4net under Mono is unaffected - the runtime check in
`log4net.Util.SystemInfo` is unchanged
</description>
</entry>
13 changes: 13 additions & 0 deletions src/changelog/3.4.0/305-docker-sdk-image.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://logging.apache.org/xml/ns"
xsi:schemaLocation="https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
type="changed">
<issue id="305" link="https://github.com/apache/logging-log4net/pull/305"/>
<description format="asciidoc">
build the container image from `mcr.microsoft.com/dotnet/sdk:10.0-noble` instead of installing
a SDK into `ubuntu:20.04` with `dotnet-install.sh`. This moves off an Ubuntu release that left
standard support in April 2025 and drops the download step, the Mono packages and the
`DOTNET_ROOT` and `PATH` handling
</description>
</entry>
12 changes: 12 additions & 0 deletions src/changelog/3.4.0/305-fix-ext-mail-package-readme.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://logging.apache.org/xml/ns"
xsi:schemaLocation="https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
type="fixed">
<issue id="305" link="https://github.com/apache/logging-log4net/pull/305"/>
<description format="asciidoc">
fix the `log4net.Ext.Mail` package failing to pack with `NU5039` (`The readme file 'README.md'
does not exist in the package`), because the `README.md` item was packed without a
`PackagePath`
</description>
</entry>
15 changes: 15 additions & 0 deletions src/changelog/3.4.0/305-fix-release-scripts.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://logging.apache.org/xml/ns"
xsi:schemaLocation="https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
type="fixed">
<issue id="305" link="https://github.com/apache/logging-log4net/pull/305"/>
<description format="asciidoc">
fix the release scripts continuing after a failed step: `$ErrorActionPreference` does not apply
to native commands, so a failing `dotnet`, `git`, `zip`, `gpg` or `mvnw` went unnoticed and the
artifacts were packaged, signed and tagged anyway. Both `scripts/build-preview.ps1` and
`scripts/build-release.ps1` now set `$PSNativeCommandUseErrorActionPreference`. Also fix
`scripts/build-preview.ps1` outside Windows, where the artifact paths handed to `gpg` were
built with backslashes, which are not path separators on Linux or macOS
</description>
</entry>
13 changes: 13 additions & 0 deletions src/changelog/3.4.0/305-target-dotnet-10.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://logging.apache.org/xml/ns"
xsi:schemaLocation="https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
type="changed">
<issue id="305" link="https://github.com/apache/logging-log4net/pull/305"/>
<description format="asciidoc">
build and test with .NET 10: the test and integration-test projects now target `net10.0`
instead of `net8.0`, and a .NET 10 SDK is required because the sources use C# 14 language
features. The published `log4net` assembly still targets `net462` and `netstandard2.0`, so
nothing changes for consumers
</description>
</entry>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net462;net8.0</TargetFrameworks>
<TargetFrameworks>net462;net10.0</TargetFrameworks>
<RootNamespace>log4net_611_main</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
2 changes: 1 addition & 1 deletion src/integration-testing/log4net-672/log4net-672.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>log4net_672</RootNamespace>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
2 changes: 1 addition & 1 deletion src/integration-testing/log4net-673/log4net-673.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>log4net_673</RootNamespace>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable>
Expand Down
2 changes: 1 addition & 1 deletion src/integration-testing/log4net-681/log4net-681.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>log4net_681</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
2 changes: 1 addition & 1 deletion src/log4net.Ext.Mail.Tests/log4net.Ext.Mail.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<IsTestProject>true</IsTestProject>
<TargetFrameworks>net8.0</TargetFrameworks>
<TargetFrameworks>net10.0</TargetFrameworks>
<NoWarn>NETSDK1138;CS1701</NoWarn>
<OutputType>Library</OutputType>
<OutputPath>bin\$(Configuration)</OutputPath>
Expand Down
2 changes: 1 addition & 1 deletion src/log4net.Ext.Mail/log4net.Ext.Mail.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<Compile Include="..\log4net\Util\Log4NetAssert.cs" Link="Util\Log4NetAssert.cs" />
</ItemGroup>
<ItemGroup>
<None Include="README.md" Pack="true" />
<None Include="README.md" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup Label="Packaging">
<Content Include="..\..\package-icon.png" PackagePath="package-icon.png">
Expand Down
Loading
Loading