Skip to content

Commit 9976b28

Browse files
authored
Fix builds for all packages on Linux (#1316)
Note that we're only building `StackExchange.Redis` and `NRediSearch` in the CI build so this wasn't apparent as an issue, but it's also easily remedied. Cleaning up the xUnit MyGet feed as well since it was an intermittent issue earlier in testing this...and turns out we don't use any betas or need them anymore, so why not simplify anyhow. Overall, this is a simpler alternative to #1313 and more build simplification/cleanup: Total changes: - Moves to 3.x build SDK (just to update) - Moves to `Visual Studio 2019` AppVeyor build image, for 3.x support (removes need to install SDK) - Rolls forward to latest version - Moves to `Build.csproj` for building - Simplifies `build.ps1` - Adds `NRediSearch` to the test suite (on Linux in CI, since Windows is against 3.x) - Adds `RedisFeatures.Module` (against v 4.0.0) to guard tests against - Makes `NRediSearch.Tests` reference `StackExchange.Redis.Tests` and support test skipping - Makes copyright year range dynamic for the library - Moves `LangVersion` to latest and in one place (root `Directory.Build.props`) - Uses `Microsoft.NETFramework.ReferenceAssemblies` to build `net4x` on Linux - Uses `IsPackable` to default to excluded then reverses to `true` only for the `src/` directory - Removes `xUnit` MyGet feed, since we're on stable builds now - Adds new files (and corrects old) in `.sln` - Removes `LibTargetFrameworks` to simplify since it's less complex given the above changes cc @mgravell for eyes - this should be all set now!
1 parent 6d0df19 commit 9976b28

23 files changed

+77
-77
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ StackExchange.Redis.Tests/*Config.json
2626
t8.shakespeare.txt
2727
launchSettings.json
2828
*.vsp
29-
*.diagsession
29+
*.diagsession
30+
TestResults/

Build.csproj

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Project Sdk="Microsoft.Build.Traversal/2.0.24">
2+
<ItemGroup>
3+
<ProjectReference Include="src\**\*.csproj" />
4+
<ProjectReference Include="tests\**\*.csproj" />
5+
<ProjectReference Include="toys\**\*.csproj" />
6+
</ItemGroup>
7+
</Project>

Directory.Build.props

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
<Project>
22
<PropertyGroup>
33
<VersionPrefix>2.0.0</VersionPrefix>
4-
<Copyright>2017 Stack Exchange, Inc.</Copyright>
4+
<Copyright>2014 - $([System.DateTime]::Now.Year) Stack Exchange, Inc.</Copyright>
55
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
6-
<GenerateDocumentationFile>true</GenerateDocumentationFile>
7-
<LibTargetFrameworks>netstandard2.0</LibTargetFrameworks>
86
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)StackExchange.Redis.snk</AssemblyOriginatorKeyFile>
97
<PackageId>$(AssemblyName)</PackageId>
108
<Features>strict</Features>
@@ -17,6 +15,7 @@
1715
<PackageProjectUrl>https://github.com/StackExchange/StackExchange.Redis/</PackageProjectUrl>
1816
<PackageLicenseUrl>https://raw.github.com/StackExchange/StackExchange.Redis/master/LICENSE</PackageLicenseUrl>
1917

18+
<LangVersion>8.0</LangVersion>
2019
<RepositoryType>git</RepositoryType>
2120
<RepositoryUrl>https://github.com/StackExchange/StackExchange.Redis/</RepositoryUrl>
2221

@@ -25,9 +24,11 @@
2524
<DefaultLanguage>en-US</DefaultLanguage>
2625
<IncludeSymbols>false</IncludeSymbols>
2726
<PublishRepositoryUrl>true</PublishRepositoryUrl>
27+
<IsPackable>false</IsPackable>
2828
</PropertyGroup>
2929
<ItemGroup>
3030
<PackageReference Include="Nerdbank.GitVersioning" Version="3.0.28" PrivateAssets="all" />
31-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/>
31+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="all"/>
32+
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="all" />
3233
</ItemGroup>
3334
</Project>

NuGet.Config

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<packageSources>
44
<clear/>
55
<!--<add key="localNuget" value="c:\code\LocalNuget" />-->
6-
<add key="xUnit" value="https://www.myget.org/F/xunit/api/v3/index.json" />
76
<!--<add key="MyGet" value="https://www.myget.org/F/stackoverflow/api/v3/index.json" />-->
87
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
98
</packageSources>

StackExchange.Redis.sln

+9-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
88
.editorconfig = .editorconfig
99
appveyor.yml = appveyor.yml
1010
build.cmd = build.cmd
11+
Build.csproj = Build.csproj
1112
build.ps1 = build.ps1
12-
Directory.build.props = Directory.build.props
13+
Directory.Build.props = Directory.Build.props
1314
global.json = global.json
1415
NuGet.Config = NuGet.Config
1516
docs\ReleaseNotes.md = docs\ReleaseNotes.md
@@ -86,8 +87,15 @@ EndProject
8687
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KestrelRedisServer", "toys\KestrelRedisServer\KestrelRedisServer.csproj", "{3DA1EEED-E9FE-43D9-B293-E000CFCCD91A}"
8788
EndProject
8889
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{73A5C363-CA1F-44C4-9A9B-EF791A76BA6A}"
90+
ProjectSection(SolutionItems) = preProject
91+
tests\Directory.Build.props = tests\Directory.Build.props
92+
tests\Directory.Build.targets = tests\Directory.Build.targets
93+
EndProjectSection
8994
EndProject
9095
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{00CA0876-DA9F-44E8-B0DC-A88716BF347A}"
96+
ProjectSection(SolutionItems) = preProject
97+
src\Directory.Build.props = src\Directory.Build.props
98+
EndProjectSection
9199
EndProject
92100
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "toys", "toys", "{E25031D3-5C64-430D-B86F-697B66816FD8}"
93101
EndProject

appveyor.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
image:
2-
- Visual Studio 2017
2+
- Visual Studio 2019
33
- Ubuntu
44

55
init:
66
- git config --global core.autocrlf input
77

88
install:
9-
- cmd: choco install dotnetcore-sdk --version 2.2.401
109
- cmd: >-
1110
cd tests\RedisConfigs\3.0.503
1211

build.ps1

+10-36
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,14 @@ Write-Host " RunTests: $RunTests"
1212
Write-Host " dotnet --version:" (dotnet --version)
1313

1414
$packageOutputFolder = "$PSScriptRoot\.nupkgs"
15-
$projectsToBuild = @(
16-
'StackExchange.Redis',
17-
'NRediSearch'
18-
)
19-
20-
$testsToRun = @(
21-
'StackExchange.Redis.Tests'
22-
)
2315

2416
if ($PullRequestNumber) {
2517
Write-Host "Building for a pull request (#$PullRequestNumber), skipping packaging." -ForegroundColor Yellow
2618
$CreatePackages = $false
2719
}
2820

29-
Write-Host "Building projects..." -ForegroundColor "Magenta"
30-
foreach ($project in $projectsToBuild) {
31-
Write-Host "Building $project (dotnet restore/build)..." -ForegroundColor "Magenta"
32-
dotnet restore ".\src\$project\$project.csproj" /p:CI=true
33-
dotnet build ".\src\$project\$project.csproj" -c Release /p:CI=true
34-
Write-Host ""
35-
}
21+
Write-Host "Building all projects (Build.csproj traversal)..." -ForegroundColor "Magenta"
22+
dotnet build ".\Build.csproj" -c Release /p:CI=true
3623
Write-Host "Done building." -ForegroundColor "Green"
3724

3825
if ($RunTests) {
@@ -41,36 +28,23 @@ if ($RunTests) {
4128
& .\RedisConfigs\start-all.cmd
4229
Write-Host "Servers Started." -ForegroundColor "Green"
4330
}
44-
foreach ($project in $testsToRun) {
45-
Write-Host "Running tests: $project (all frameworks)" -ForegroundColor "Magenta"
46-
#Push-Location ".\tests\$project"
47-
Push-Location ".\tests\$project"
48-
49-
dotnet test -c Release
50-
if ($LastExitCode -ne 0) {
51-
Write-Host "Error with tests, aborting build." -Foreground "Red"
52-
Pop-Location
53-
Exit 1
54-
}
55-
56-
Write-Host "Tests passed!" -ForegroundColor "Green"
57-
Pop-Location
31+
Write-Host "Running tests: Build.csproj traversal (all frameworks)" -ForegroundColor "Magenta"
32+
dotnet test ".\Build.csproj" -c Release --no-build --logger trx
33+
if ($LastExitCode -ne 0) {
34+
Write-Host "Error with tests, aborting build." -Foreground "Red"
35+
Exit 1
5836
}
37+
Write-Host "Tests passed!" -ForegroundColor "Green"
5938
}
6039

6140
if ($CreatePackages) {
62-
mkdir -Force $packageOutputFolder | Out-Null
41+
New-Item -ItemType Directory -Path $packageOutputFolder -Force | Out-Null
6342
Write-Host "Clearing existing $packageOutputFolder..." -NoNewline
6443
Get-ChildItem $packageOutputFolder | Remove-Item
6544
Write-Host "done." -ForegroundColor "Green"
6645

6746
Write-Host "Building all packages" -ForegroundColor "Green"
68-
69-
foreach ($project in $projectsToBuild) {
70-
Write-Host "Packing $project (dotnet pack)..." -ForegroundColor "Magenta"
71-
dotnet pack ".\src\$project\$project.csproj" --no-build -c Release /p:PackageOutputPath=$packageOutputFolder /p:NoPackageAnalysis=true /p:CI=true
72-
Write-Host ""
73-
}
47+
dotnet pack ".\Build.csproj" --no-build -c Release /p:PackageOutputPath=$packageOutputFolder /p:CI=true
7448
}
7549

7650
Write-Host "Done."

global.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
{
33
"sdk": {
4-
"version": "2.2.400"
4+
"version": "3.0.100",
5+
"rollForward": "latestMajor"
56
}
67
}

src/Directory.Build.props

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Project>
2+
<Import Project="$(MSBuildThisFileDirectory)..\Directory.Build.props" />
3+
<PropertyGroup>
4+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
5+
<IsPackable>true</IsPackable>
6+
</PropertyGroup>
7+
</Project>

src/NRediSearch/NRediSearch.csproj

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>$(LibTargetFrameworks)</TargetFrameworks>
3+
<TargetFrameworks>netstandard2.0</TargetFrameworks>
44
<GenerateDocumentationFile>false</GenerateDocumentationFile>
55
<PackageTags>Redis;Search;Modules;RediSearch</PackageTags>
66
<SignAssembly>true</SignAssembly>
7-
<LangVersion>7.2</LangVersion>
87
</PropertyGroup>
98
<ItemGroup>
109
<ProjectReference Include="..\StackExchange.Redis\StackExchange.Redis.csproj" />

src/StackExchange.Redis/RedisFeatures.cs

+5
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ public RedisFeatures(Version version)
100100
/// </summary>
101101
public bool MillisecondExpiry => Version >= v2_6_0;
102102

103+
/// <summary>
104+
/// Is MODULE available?
105+
/// </summary>
106+
public bool Module => Version >= v4_0_0;
107+
103108
/// <summary>
104109
/// Does SRANDMEMBER support "count"?
105110
/// </summary>

src/StackExchange.Redis/StackExchange.Redis.csproj

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<!-- extend the default lib targets for the main lib; mostly because of "vectors" -->
4-
<LibTargetFrameworks Condition="'$(OS)' == 'Windows_NT'">net461;netstandard2.0;net472</LibTargetFrameworks>
5-
<TargetFrameworks>$(LibTargetFrameworks)</TargetFrameworks>
4+
<TargetFrameworks>net461;netstandard2.0;net472</TargetFrameworks>
65
<Description>High performance Redis client, incorporating both synchronous and asynchronous usage.</Description>
76
<AssemblyName>StackExchange.Redis</AssemblyName>
87
<AssemblyTitle>StackExchange.Redis</AssemblyTitle>
98
<PackageId>StackExchange.Redis</PackageId>
109
<PackageTags>Async;Redis;Cache;PubSub;Messaging</PackageTags>
1110
<SignAssembly>true</SignAssembly>
1211
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
13-
<LangVersion>latest</LangVersion>
1412
<DefineConstants Condition="'$(TargetFramework)' != 'net461'">$(DefineConstants);VECTOR_SAFE</DefineConstants>
1513
</PropertyGroup>
1614

tests/BasicTest/BasicTest.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
<PackageId>BasicTest</PackageId>
99
<RuntimeIdentifiers>win7-x64</RuntimeIdentifiers>
1010
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
11-
<LangVersion>latest</LangVersion>
1211
</PropertyGroup>
1312

1413
<ItemGroup>

tests/BasicTestBaseline/BasicTestBaseline.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
<PackageId>BasicTestBaseline</PackageId>
99
<RuntimeIdentifiers>win7-x64</RuntimeIdentifiers>
1010
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
11-
<LangVersion>latest</LangVersion>
1211
<DefineConstants>$(DefineConstants);TEST_BASELINE</DefineConstants>
1312
</PropertyGroup>
1413

tests/Directory.Build.props

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<Project>
2+
<!-- We could delete this file, but being consistent in structure here -->
3+
<Import Project="$(MSBuildThisFileDirectory)..\Directory.Build.props" />
4+
</Project>

tests/Directory.Build.targets

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Project>
2+
<PropertyGroup>
3+
<IsTestProject Condition="'$(OS)' != 'Windows_NT' AND $(TargetFramework.StartsWith('net4'))">false</IsTestProject>
4+
</PropertyGroup>
5+
</Project>

tests/NRediSearch.Test/Attributes.cs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace NRediSearch.Test
2+
{
3+
// This is only to make the namespace more-local and not need a using at the top of every test file that's easy to forget
4+
public class FactAttribute : StackExchange.Redis.Tests.FactAttribute { }
5+
6+
public class TheoryAttribute : StackExchange.Redis.Tests.TheoryAttribute { }
7+
}

tests/NRediSearch.Test/NRediSearch.Test.csproj

+1-6
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,11 @@
22
<PropertyGroup>
33
<OutputType>Library</OutputType>
44
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
5-
<GenerateDocumentationFile>false</GenerateDocumentationFile>
65
<SignAssembly>true</SignAssembly>
76
</PropertyGroup>
87
<ItemGroup>
98
<ProjectReference Include="..\..\src\NRediSearch\NRediSearch.csproj" />
9+
<ProjectReference Include="..\StackExchange.Redis.Tests\StackExchange.Redis.Tests.csproj" />
1010
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
11-
<PackageReference Include="xunit" Version="2.4.1" />
12-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
13-
<PrivateAssets>all</PrivateAssets>
14-
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
15-
</PackageReference>
1611
</ItemGroup>
1712
</Project>

tests/NRediSearch.Test/RediSearchTestBase.cs

+8-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using System.Runtime.CompilerServices;
55
using StackExchange.Redis;
6+
using StackExchange.Redis.Tests;
67
using Xunit.Abstractions;
78

89
namespace NRediSearch.Test
@@ -44,10 +45,9 @@ protected static Client Reset(Client client)
4445

4546
internal static ConnectionMultiplexer GetWithFT(ITestOutputHelper output)
4647
{
47-
const string ep = "127.0.0.1:6379";
4848
var options = new ConfigurationOptions
4949
{
50-
EndPoints = { ep },
50+
EndPoints = { TestConfig.Current.MasterServerAndPort },
5151
AllowAdmin = true,
5252
SyncTimeout = 15000,
5353
};
@@ -56,7 +56,10 @@ internal static ConnectionMultiplexer GetWithFT(ITestOutputHelper output)
5656
conn.Connecting += (e, t) => output.WriteLine($"Connecting to {Format.ToString(e)} as {t}");
5757
conn.Closing += complete => output.WriteLine(complete ? "Closed" : "Closing...");
5858

59-
var server = conn.GetServer(ep);
59+
// If say we're on a 3.x Redis server...bomb out.
60+
Skip.IfMissingFeature(conn, nameof(RedisFeatures.Module), r => r.Module);
61+
62+
var server = conn.GetServer(TestConfig.Current.MasterServerAndPort);
6063
var arr = (RedisResult[])server.Execute("module", "list");
6164
bool found = false;
6265
foreach (var module in arr)
@@ -83,7 +86,8 @@ internal static ConnectionMultiplexer GetWithFT(ITestOutputHelper output)
8386
{
8487
var result = server.Execute("module", "load", modulePath);
8588
output?.WriteLine((string)result);
86-
} catch(RedisServerException err)
89+
}
90+
catch (RedisServerException err)
8791
{
8892
// *probably* duplicate load; we'll try the tests anyways!
8993
output?.WriteLine(err.Message);

tests/StackExchange.Redis.Tests/StackExchange.Redis.Tests.csproj

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<Description>StackExchange.Redis.Tests</Description>
4-
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">net462;netcoreapp2.1</TargetFrameworks>
5-
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp2.1</TargetFrameworks>
3+
<TargetFrameworks>net462;netcoreapp2.1</TargetFrameworks>
64
<AssemblyName>StackExchange.Redis.Tests</AssemblyName>
75
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
8-
<GenerateDocumentationFile>false</GenerateDocumentationFile>
96
<SignAssembly>true</SignAssembly>
107
<DebugType>full</DebugType>
11-
<LangVersion>latest</LangVersion>
128
</PropertyGroup>
139

1410
<ItemGroup>
@@ -24,10 +20,7 @@
2420
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.3.0" />
2521
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
2622
<PackageReference Include="xunit" Version="2.4.1" />
27-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
28-
<PrivateAssets>all</PrivateAssets>
29-
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
30-
</PackageReference>
23+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" PrivateAssets="all" />
3124
</ItemGroup>
3225

3326
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">

toys/StackExchange.Redis.Server/StackExchange.Redis.Server.csproj

-3
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@
44
<TargetFrameworks>netstandard2.0</TargetFrameworks>
55
<Description>Basic redis server based on StackExchange.Redis</Description>
66
<AssemblyTitle>StackExchange.Redis</AssemblyTitle>
7-
<GenerateDocumentationFile>true</GenerateDocumentationFile>
87
<AssemblyName>StackExchange.Redis.Server</AssemblyName>
98
<PackageId>StackExchange.Redis.Server</PackageId>
109
<PackageTags>Server;Async;Redis;Cache;PubSub;Messaging</PackageTags>
1110
<OutputTypeEx>Library</OutputTypeEx>
1211
<SignAssembly>true</SignAssembly>
1312
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
14-
<LangVersion>latest</LangVersion>
1513
<NoWarn>$(NoWarn);CS1591</NoWarn>
16-
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
1714
</PropertyGroup>
1815
<ItemGroup>
1916
<ProjectReference Include="..\..\src\StackExchange.Redis\StackExchange.Redis.csproj" />

toys/TestConsole/TestConsole.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFrameworks>netcoreapp2.1;net461;net462;net47;net472</TargetFrameworks>
6-
<LangVersion>latest</LangVersion>
76
<DefineConstants>SEV2</DefineConstants>
87
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
98
</PropertyGroup>

toys/TestConsoleBaseline/TestConsoleBaseline.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFrameworks>netcoreapp2.1;net461;net462;net47;net472</TargetFrameworks>
6-
<LangVersion>latest</LangVersion>
76
</PropertyGroup>
87

98
<PropertyGroup Condition="'$(Computername)'=='OCHO' or '$(Computername)'=='SKINK'">

0 commit comments

Comments
 (0)