Skip to content

Commit

Permalink
Add .NET Standard 2.0 target; closes #343
Browse files Browse the repository at this point in the history
  • Loading branch information
atifaziz authored Aug 28, 2017
1 parent 6812469 commit 51db754
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 43 deletions.
37 changes: 8 additions & 29 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,17 @@ language: csharp
os:
- linux
- osx
osx_image: xcode8.3
solution: MoreLinq.sln
mono: 4.8.0
mono: 5.0.1
dist: trusty
sudo: required
dotnet: 1.0.1
dotnet: 2.0.0
env:
- CONFIGURATION=Debug
- CONFIGURATION=Release

# Ensure MSBuild is installed
before_install:
- |
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
sudo apt-get -qq update
sudo apt-get install msbuild
fi
- |
# This is a temporary fix to workaround a problem where Travis picks up a build of Mono on OSX that
# includes a broken version of MSBuild.
#
# See https://github.com/mono/msbuild/commit/cff4013ba3a69f82dc0ae96b3e15af700d8f74ef
# for the fix this is replicating.
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
MSBUILD_BIN=/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/msbuild/15.0/bin
if [ ! -d $MSBUILD_BIN ] || [ -f $MSBUILD_BIN/System.Reflection.Metadata.dll ]; then
echo "WORKAROUND: Time to remove System.Reflection.Metadata.dll workaround"
else
echo "WORKAROUND: Copying System.Reflection.Metadata.dll to Mono MSBuild"
sudo cp $MSBUILD_BIN/Roslyn/System.Reflection.Metadata.dll $MSBUILD_BIN/System.Reflection.Metadata.dll
fi
fi
- msbuild /version
- |
# Handle too many files on OS X
Expand All @@ -50,5 +25,9 @@ install:

script:
- ./msbuild.sh /v:m /p:Configuration=$CONFIGURATION
- dotnet exec MoreLinq.Test/bin/$CONFIGURATION/netcoreapp1.0/MoreLinq.Test.dll
# TODO Enable testing as a .NET Core App 1.0
# Currently, this is failing with the following error:
# assembly specified in the dependencies manifest was not found -- package: 'NUnit', version: '3.6.1', path: 'lib/netstandard1.6/nunit.framework.dll'
# - dotnet exec MoreLinq.Test/bin/$CONFIGURATION/netcoreapp1.0/MoreLinq.Test.dll
- dotnet exec MoreLinq.Test/bin/$CONFIGURATION/netcoreapp2.0/MoreLinq.Test.dll
- sh ./travis-mono-test.sh
2 changes: 1 addition & 1 deletion MoreLinq.Test/MoreLinq.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<AssemblyTitle>MoreLinq.Test</AssemblyTitle>
<TargetFrameworks>netcoreapp1.0;net451</TargetFrameworks>
<TargetFrameworks>netcoreapp1.0;netcoreapp2.0;net451</TargetFrameworks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DebugType>portable</DebugType>
<AssemblyName>MoreLinq.Test</AssemblyName>
Expand Down
2 changes: 1 addition & 1 deletion MoreLinq.Test/NullArgumentTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ static bool CanBeNull(ParameterInfo parameter)
nameof(MoreEnumerable.From) + ".function1",
nameof(MoreEnumerable.From) + ".function2",
nameof(MoreEnumerable.From) + ".function3",
#if NET451
#if NET451 || NETCOREAPP2_0
nameof(MoreEnumerable.ToDataTable) + ".expressions",
#endif
nameof(MoreEnumerable.ToDelimitedString) + ".delimiter",
Expand Down
2 changes: 1 addition & 1 deletion MoreLinq.Test/ToDataTableTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public void ToDataTableWithSchema()
vars.Select(e => new { Name = e.Key.ToString(), Value = e.Value.ToString() })
.ToDataTable(dt, e => e.Name, e => e.Value);

var rows = dt.AsEnumerable().ToArray();
var rows = dt.Rows.Cast<DataRow>().ToArray();
Assert.That(rows.Length, Is.EqualTo(vars.Length));
Assert.That(rows.Select(r => r["Name"]).ToArray(), Is.EqualTo(vars.Select(e => e.Key).ToArray()));
Assert.That(rows.Select(r => r["Value"]).ToArray(), Is.EqualTo(vars.Select(e => e.Value).ToArray()));
Expand Down
4 changes: 2 additions & 2 deletions MoreLinq/MoreLinq.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<NeutralLanguage>en-US</NeutralLanguage>
<VersionPrefix>2.7.0</VersionPrefix>
<Authors>MoreLINQ Developers.</Authors>
<TargetFrameworks>net40;net35;netstandard1.0</TargetFrameworks>
<TargetFrameworks>net40;net35;netstandard1.0;netstandard2.0</TargetFrameworks>
<LangVersion>7</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DebugType>portable</DebugType>
Expand Down Expand Up @@ -61,7 +61,7 @@
<DefineConstants>$(DefineConstants);MORELINQ;NO_VALUE_TUPLES</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net40' ">
<PropertyGroup Condition=" '$(TargetFramework)' == 'net40' Or '$(TargetFramework)' == 'netstandard2.0' ">
<DefineConstants>$(DefineConstants);MORELINQ;FUNC16</DefineConstants>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"MoreLinq.Test"
],
"sdk": {
"version": "1.0.0"
"version": "2.0.0"
}
}
2 changes: 1 addition & 1 deletion msbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ which msbuild 2>/dev/null || {
}

for d in local/share share; do
SDK_DIR=/usr/$d/dotnet/sdk/1.0.1
SDK_DIR=/usr/$d/dotnet/sdk/2.0.0
if [ -d $SDK_DIR ]; then break; fi
done

Expand Down
12 changes: 7 additions & 5 deletions test.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@ goto :EOF
:main
setlocal
call build ^
&& call :test netcore10 Debug ^
&& call :test netcore10 Release ^
&& call :test netcoreapp1.0 Debug ^
&& call :test netcoreapp1.0 Release ^
&& call :test netcoreapp2.0 Debug ^
&& call :test netcoreapp2.0 Release ^
&& call :test net451 Debug ^
&& call :test net451 Release
goto :EOF

:test
setlocal
echo Testing %1 (%2)...
if %1==netcore10 (
dotnet exec MoreLinq.Test\bin\%2\netcoreapp1.0\MoreLinq.Test.dll
) else (
if %1==net451 (
MoreLinq.Test\bin\%2\net451\MoreLinq.Test.exe
) else (
dotnet exec MoreLinq.Test\bin\%2\%1\MoreLinq.Test.dll
)
goto :EOF
7 changes: 5 additions & 2 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
[[ -e test.sh ]] || { echo >&2 "Please cd into the script location before running it."; exit 1; }
set -e
./build.sh
dotnet exec MoreLinq.Test/bin/Debug/netcoreapp1.0/MoreLinq.Test.dll
dotnet exec MoreLinq.Test/bin/Release/netcoreapp1.0/MoreLinq.Test.dll
for v in 1 2; do
for c in Debug Release; do
dotnet exec MoreLinq.Test/bin/$c/netcoreapp$v.0/MoreLinq.Test.dll
done
done
if [[ -z `which mono 2>/dev/null` ]]; then
echo>&2 NOTE! Mono does not appear to be installed so unit tests
echo>&2 against the Mono runtime will be skipped.
Expand Down

0 comments on commit 51db754

Please sign in to comment.