Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add .NET Standard 2.0 build #14

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from 10 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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
Expand Down Expand Up @@ -235,4 +235,4 @@ target
# other files to ignore
old-log4net.snk
src/GeneratedAssemblyInfo.cs

src/log4net.xml
15 changes: 4 additions & 11 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,14 @@ pipeline {
// run docker container
builder.inside {
// compile
sh "nant compile-netstandard"
sh "dotnet build src/log4net.csproj -c Release -f netstandard1.3 -o ../bin/netstandard1.3"
sh "dotnet build src/log4net.csproj -c Release -f netstandard2.0 -o ../bin/netstandard2.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer this to be a separate stage.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just now realized why you had to change this. The docker microsoft/dotnet is now on debian stretch which does no longer include nant (https://packages.debian.org/search?suite=all&section=all&arch=any&searchon=names&keywords=nant). We probably should move away from nant entirely.

stash includes: 'bin/**/*.*', name: 'netstandard-assemblies'

// test
sh 'cd netstandard/log4net.tests && dotnet test'
sh "dotnet test tests/src/log4net.Tests.csproj"
}
}


// compile
// sh 'nant compile-netstandard'
// stash includes: 'bin/**/*.*', name: 'netstandard-assemblies'

// test
// sh 'cd netstandard/log4net.tests && dotnet test'
}
}
stage('build net-3.5') {
Expand Down Expand Up @@ -245,7 +238,7 @@ pipeline {
// unstash site
unstash 'site'
}

// move site
sh 'mv package/target/site/ package/site/'
sh 'rmdir -p --ignore-fail-on-non-empty package/target'
Expand Down
7 changes: 1 addition & 6 deletions buildtools/docker/builder-netstandard/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Name of container: docker-ubuntu-latest-nant
FROM microsoft/dotnet
FROM microsoft/dotnet:2.0.0-sdk-stretch

# define arguments passed in as environment variables
ARG JENKINS_UID
Expand All @@ -17,7 +16,3 @@ RUN mkdir -p /var/workspaces && chmod 0777 /var/workspaces
# add jenkins user that maps to the custom workspace
RUN groupadd -r -g $JENKINS_GID jenkins-slave
RUN useradd --base-dir /var/workspaces --create-home --shell /bin/bash --uid $JENKINS_UID --gid $JENKINS_GID --groups $JENKINS_GID -p -M jenkins

# install dependencies
RUN apt-get update && apt-get install -y nant git

50 changes: 33 additions & 17 deletions log4net.build
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
this work for additional information regarding copyright ownership.
The ASF licenses this file to you under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
Expand Down Expand Up @@ -1748,48 +1748,64 @@ limitations under the License.
</csc>
</if>
</target>
<!-- these targets build lognet assemblies against .NET Core (.net standard 1.0.4)-->
<target name="compile-netstandard" description="Builds .NET Core">
<!-- these targets build lognet assemblies against .NET Standard 1.3 and 2.0 -->
<target name="compile-netstandard" description="Builds .NET Standard">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer this to become the target compile-netstandard-1.3 and a second target should be added named compile-netstandard-2.0. Otherwise too many different targets and builds are done by one target and maintaining it becomes a hard task.

<call target="set-debug-build-configuration"/>
<call target="compile-netstandard-current-configuration"/>
<call target="set-release-build-configuration"/>
<call target="compile-netstandard-current-configuration"/>
</target>
<target name="compile-netstandard-current-configuration">
<echo message="dotnet --version"/>
<exec program="dotnet" workingdir="netstandard" failonerror="false" resultproperty="dotnet.available">
<exec program="dotnet" workingdir="${log4net.basedir}" failonerror="false" resultproperty="dotnet.available">
<arg value="--version"/>
</exec>
<if test="${dotnet.available != '0'}">
<echo message="Skipping build; required framework is not available: netstandard"/>
</if>
<if test="${dotnet.available == '0'}">
<echo message="dotnet restore log4net.netstandard.sln"/>
<exec program="dotnet" workingdir="netstandard">
<arg value="restore"/>
<arg value="log4net.netstandard.sln"/>
</exec>
<if test="${current.build.config.release != '-c'}">
<echo message="dotnet build log4net"/>
<echo message="dotnet build log4net.csproj"/>
</if>
<if test="${current.build.config.release == '-c'}">
<echo message="dotnet build log4net -c Release"/>
<echo message="dotnet build log4net.csproj -c Release"/>
</if>
<exec program="dotnet" workingdir="netstandard">
<exec program="dotnet" workingdir="${log4net.basedir}/src">
<arg value="build"/>
<arg value="log4net"/>
<arg value="log4net.csproj"/>
<arg value="-f"/>
<arg value="netstandard1.3"/>
<arg if="${current.build.config.release}" value="-c"/>
<arg if="${current.build.config.release}" value="Release"/>
</exec>
<mkdir dir="${log4net.basedir}/bin/netstandard/1.3"/>
<if test="${current.build.config.release}">
<move todir="${log4net.basedir}/bin/netstandard/1.3/release">
<fileset basedir="netstandard/log4net/bin/Release/netstandard1.3"/>
<fileset basedir="${log4net.basedir}/src/bin/Release/netstandard1.3"/>
</move>
</if>
<ifnot test="${current.build.config.release}">
<move todir="${log4net.basedir}/bin/netstandard/1.3/debug">
<fileset basedir="netstandard/log4net/bin/Debug/netstandard1.3"/>
<fileset basedir="${log4net.basedir}/src/bin/Debug/netstandard1.3"/>
</move>
</ifnot>
<exec program="dotnet" workingdir="${log4net.basedir}/src">
<arg value="build"/>
<arg value="log4net.csproj"/>
<arg value="-f"/>
<arg value="netstandard2.0"/>
<arg if="${current.build.config.release}" value="-c"/>
<arg if="${current.build.config.release}" value="Release"/>
</exec>
<mkdir dir="${log4net.basedir}/bin/netstandard/2.0"/>
<if test="${current.build.config.release}">
<move todir="${log4net.basedir}/bin/netstandard/2.0/release">
<fileset basedir="${log4net.basedir}/src/bin/Release/netstandard2.0"/>
</move>
</if>
<ifnot test="${current.build.config.release}">
<move todir="${log4net.basedir}/bin/netstandard/2.0/debug">
<fileset basedir="${log4net.basedir}/src/bin/Debug/netstandard2.0"/>
</move>
</ifnot>
</if>
Expand Down
33 changes: 0 additions & 33 deletions netstandard/log4net.netstandard.sln

This file was deleted.

32 changes: 0 additions & 32 deletions netstandard/log4net.tests/log4net.tests.csproj

This file was deleted.

53 changes: 0 additions & 53 deletions netstandard/log4net/CompatibilityExtensions.cs

This file was deleted.

62 changes: 0 additions & 62 deletions netstandard/log4net/log4net.csproj

This file was deleted.

4 changes: 2 additions & 2 deletions src/Appender/AppenderSkeleton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public void DoAppend(LoggingEvent loggingEvent)
{
ErrorHandler.Error("Failed in DoAppend", ex);
}
#if !MONO && !NET_2_0 && !NETSTANDARD1_3
#if !(MONO || NET_2_0 || NETSTANDARD1_3 || NETSTANDARD2_0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see a naming scheme difference here. According to the conventions so far, a underscore has been there before the version of a target. Thus NETSTANDARD1_3 should probably read NETSTANDARD_1_3 and NETSTANDARD2_0 should become NETSTANDARD_2_0. Of course this has slipped through when netstandard-1.3 support was added.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used the FrameworkMajor_Minor convention because it's used by the build system, e.g. NETSTANDARD1_3 is defined when building a netstandard1.3 library (more details in the Target Frameworks doc).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then this is fine by me.

// on .NET 2.0 (and higher) and Mono (all profiles),
// exceptions that do not derive from System.Exception will be
// wrapped in a RuntimeWrappedException by the runtime, and as
Expand Down Expand Up @@ -428,7 +428,7 @@ public void DoAppend(LoggingEvent[] loggingEvents)
{
ErrorHandler.Error("Failed in Bulk DoAppend", ex);
}
#if !MONO && !NET_2_0 && !NETSTANDARD1_3
#if !(MONO || NET_2_0 || NETSTANDARD1_3 || NETSTANDARD2_0)
// on .NET 2.0 (and higher) and Mono (all profiles),
// exceptions that do not derive from System.Exception will be
// wrapped in a RuntimeWrappedException by the runtime, and as
Expand Down
Loading