Unverified Commit 9976b286 authored by Nick Craver's avatar Nick Craver Committed by GitHub

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!
parent 6d0df198
......@@ -26,4 +26,5 @@ StackExchange.Redis.Tests/*Config.json
t8.shakespeare.txt
launchSettings.json
*.vsp
*.diagsession
\ No newline at end of file
*.diagsession
TestResults/
\ No newline at end of file
<Project Sdk="Microsoft.Build.Traversal/2.0.24">
<ItemGroup>
<ProjectReference Include="src\**\*.csproj" />
<ProjectReference Include="tests\**\*.csproj" />
<ProjectReference Include="toys\**\*.csproj" />
</ItemGroup>
</Project>
\ No newline at end of file
<Project>
<PropertyGroup>
<VersionPrefix>2.0.0</VersionPrefix>
<Copyright>2017 Stack Exchange, Inc.</Copyright>
<Copyright>2014 - $([System.DateTime]::Now.Year) Stack Exchange, Inc.</Copyright>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<LibTargetFrameworks>netstandard2.0</LibTargetFrameworks>
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)StackExchange.Redis.snk</AssemblyOriginatorKeyFile>
<PackageId>$(AssemblyName)</PackageId>
<Features>strict</Features>
......@@ -17,6 +15,7 @@
<PackageProjectUrl>https://github.com/StackExchange/StackExchange.Redis/</PackageProjectUrl>
<PackageLicenseUrl>https://raw.github.com/StackExchange/StackExchange.Redis/master/LICENSE</PackageLicenseUrl>
<LangVersion>8.0</LangVersion>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/StackExchange/StackExchange.Redis/</RepositoryUrl>
......@@ -25,9 +24,11 @@
<DefaultLanguage>en-US</DefaultLanguage>
<IncludeSymbols>false</IncludeSymbols>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning" Version="3.0.28" PrivateAssets="all" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="all"/>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="all" />
</ItemGroup>
</Project>
......@@ -3,7 +3,6 @@
<packageSources>
<clear/>
<!--<add key="localNuget" value="c:\code\LocalNuget" />-->
<add key="xUnit" value="https://www.myget.org/F/xunit/api/v3/index.json" />
<!--<add key="MyGet" value="https://www.myget.org/F/stackoverflow/api/v3/index.json" />-->
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
</packageSources>
......
......@@ -8,8 +8,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.editorconfig = .editorconfig
appveyor.yml = appveyor.yml
build.cmd = build.cmd
Build.csproj = Build.csproj
build.ps1 = build.ps1
Directory.build.props = Directory.build.props
Directory.Build.props = Directory.Build.props
global.json = global.json
NuGet.Config = NuGet.Config
docs\ReleaseNotes.md = docs\ReleaseNotes.md
......@@ -86,8 +87,15 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KestrelRedisServer", "toys\KestrelRedisServer\KestrelRedisServer.csproj", "{3DA1EEED-E9FE-43D9-B293-E000CFCCD91A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{73A5C363-CA1F-44C4-9A9B-EF791A76BA6A}"
ProjectSection(SolutionItems) = preProject
tests\Directory.Build.props = tests\Directory.Build.props
tests\Directory.Build.targets = tests\Directory.Build.targets
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{00CA0876-DA9F-44E8-B0DC-A88716BF347A}"
ProjectSection(SolutionItems) = preProject
src\Directory.Build.props = src\Directory.Build.props
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "toys", "toys", "{E25031D3-5C64-430D-B86F-697B66816FD8}"
EndProject
......
image:
- Visual Studio 2017
- Visual Studio 2019
- Ubuntu
init:
- git config --global core.autocrlf input
install:
- cmd: choco install dotnetcore-sdk --version 2.2.401
- cmd: >-
cd tests\RedisConfigs\3.0.503
......
......@@ -12,27 +12,14 @@ Write-Host " RunTests: $RunTests"
Write-Host " dotnet --version:" (dotnet --version)
$packageOutputFolder = "$PSScriptRoot\.nupkgs"
$projectsToBuild = @(
'StackExchange.Redis',
'NRediSearch'
)
$testsToRun = @(
'StackExchange.Redis.Tests'
)
if ($PullRequestNumber) {
Write-Host "Building for a pull request (#$PullRequestNumber), skipping packaging." -ForegroundColor Yellow
$CreatePackages = $false
}
Write-Host "Building projects..." -ForegroundColor "Magenta"
foreach ($project in $projectsToBuild) {
Write-Host "Building $project (dotnet restore/build)..." -ForegroundColor "Magenta"
dotnet restore ".\src\$project\$project.csproj" /p:CI=true
dotnet build ".\src\$project\$project.csproj" -c Release /p:CI=true
Write-Host ""
}
Write-Host "Building all projects (Build.csproj traversal)..." -ForegroundColor "Magenta"
dotnet build ".\Build.csproj" -c Release /p:CI=true
Write-Host "Done building." -ForegroundColor "Green"
if ($RunTests) {
......@@ -41,36 +28,23 @@ if ($RunTests) {
& .\RedisConfigs\start-all.cmd
Write-Host "Servers Started." -ForegroundColor "Green"
}
foreach ($project in $testsToRun) {
Write-Host "Running tests: $project (all frameworks)" -ForegroundColor "Magenta"
#Push-Location ".\tests\$project"
Push-Location ".\tests\$project"
dotnet test -c Release
if ($LastExitCode -ne 0) {
Write-Host "Error with tests, aborting build." -Foreground "Red"
Pop-Location
Exit 1
}
Write-Host "Tests passed!" -ForegroundColor "Green"
Pop-Location
Write-Host "Running tests: Build.csproj traversal (all frameworks)" -ForegroundColor "Magenta"
dotnet test ".\Build.csproj" -c Release --no-build --logger trx
if ($LastExitCode -ne 0) {
Write-Host "Error with tests, aborting build." -Foreground "Red"
Exit 1
}
Write-Host "Tests passed!" -ForegroundColor "Green"
}
if ($CreatePackages) {
mkdir -Force $packageOutputFolder | Out-Null
New-Item -ItemType Directory -Path $packageOutputFolder -Force | Out-Null
Write-Host "Clearing existing $packageOutputFolder..." -NoNewline
Get-ChildItem $packageOutputFolder | Remove-Item
Write-Host "done." -ForegroundColor "Green"
Write-Host "Building all packages" -ForegroundColor "Green"
foreach ($project in $projectsToBuild) {
Write-Host "Packing $project (dotnet pack)..." -ForegroundColor "Magenta"
dotnet pack ".\src\$project\$project.csproj" --no-build -c Release /p:PackageOutputPath=$packageOutputFolder /p:NoPackageAnalysis=true /p:CI=true
Write-Host ""
}
dotnet pack ".\Build.csproj" --no-build -c Release /p:PackageOutputPath=$packageOutputFolder /p:CI=true
}
Write-Host "Done."
\ No newline at end of file
{
"sdk": {
"version": "2.2.400"
"version": "3.0.100",
"rollForward": "latestMajor"
}
}
\ No newline at end of file
<Project>
<Import Project="$(MSBuildThisFileDirectory)..\Directory.Build.props" />
<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<IsPackable>true</IsPackable>
</PropertyGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(LibTargetFrameworks)</TargetFrameworks>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<PackageTags>Redis;Search;Modules;RediSearch</PackageTags>
<SignAssembly>true</SignAssembly>
<LangVersion>7.2</LangVersion>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\StackExchange.Redis\StackExchange.Redis.csproj" />
......
......@@ -100,6 +100,11 @@ public RedisFeatures(Version version)
/// </summary>
public bool MillisecondExpiry => Version >= v2_6_0;
/// <summary>
/// Is MODULE available?
/// </summary>
public bool Module => Version >= v4_0_0;
/// <summary>
/// Does SRANDMEMBER support "count"?
/// </summary>
......
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-- extend the default lib targets for the main lib; mostly because of "vectors" -->
<LibTargetFrameworks Condition="'$(OS)' == 'Windows_NT'">net461;netstandard2.0;net472</LibTargetFrameworks>
<TargetFrameworks>$(LibTargetFrameworks)</TargetFrameworks>
<TargetFrameworks>net461;netstandard2.0;net472</TargetFrameworks>
<Description>High performance Redis client, incorporating both synchronous and asynchronous usage.</Description>
<AssemblyName>StackExchange.Redis</AssemblyName>
<AssemblyTitle>StackExchange.Redis</AssemblyTitle>
......@@ -10,7 +9,6 @@
<PackageTags>Async;Redis;Cache;PubSub;Messaging</PackageTags>
<SignAssembly>true</SignAssembly>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<LangVersion>latest</LangVersion>
<DefineConstants Condition="'$(TargetFramework)' != 'net461'">$(DefineConstants);VECTOR_SAFE</DefineConstants>
</PropertyGroup>
......
......@@ -8,7 +8,6 @@
<PackageId>BasicTest</PackageId>
<RuntimeIdentifiers>win7-x64</RuntimeIdentifiers>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
......
......@@ -8,7 +8,6 @@
<PackageId>BasicTestBaseline</PackageId>
<RuntimeIdentifiers>win7-x64</RuntimeIdentifiers>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<LangVersion>latest</LangVersion>
<DefineConstants>$(DefineConstants);TEST_BASELINE</DefineConstants>
</PropertyGroup>
......
<Project>
<!-- We could delete this file, but being consistent in structure here -->
<Import Project="$(MSBuildThisFileDirectory)..\Directory.Build.props" />
</Project>
<Project>
<PropertyGroup>
<IsTestProject Condition="'$(OS)' != 'Windows_NT' AND $(TargetFramework.StartsWith('net4'))">false</IsTestProject>
</PropertyGroup>
</Project>
namespace NRediSearch.Test
{
// 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
public class FactAttribute : StackExchange.Redis.Tests.FactAttribute { }
public class TheoryAttribute : StackExchange.Redis.Tests.TheoryAttribute { }
}
......@@ -2,16 +2,11 @@
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\NRediSearch\NRediSearch.csproj" />
<ProjectReference Include="..\StackExchange.Redis.Tests\StackExchange.Redis.Tests.csproj" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
\ No newline at end of file
......@@ -3,6 +3,7 @@
using System.Linq;
using System.Runtime.CompilerServices;
using StackExchange.Redis;
using StackExchange.Redis.Tests;
using Xunit.Abstractions;
namespace NRediSearch.Test
......@@ -44,10 +45,9 @@ protected static Client Reset(Client client)
internal static ConnectionMultiplexer GetWithFT(ITestOutputHelper output)
{
const string ep = "127.0.0.1:6379";
var options = new ConfigurationOptions
{
EndPoints = { ep },
EndPoints = { TestConfig.Current.MasterServerAndPort },
AllowAdmin = true,
SyncTimeout = 15000,
};
......@@ -56,7 +56,10 @@ internal static ConnectionMultiplexer GetWithFT(ITestOutputHelper output)
conn.Connecting += (e, t) => output.WriteLine($"Connecting to {Format.ToString(e)} as {t}");
conn.Closing += complete => output.WriteLine(complete ? "Closed" : "Closing...");
var server = conn.GetServer(ep);
// If say we're on a 3.x Redis server...bomb out.
Skip.IfMissingFeature(conn, nameof(RedisFeatures.Module), r => r.Module);
var server = conn.GetServer(TestConfig.Current.MasterServerAndPort);
var arr = (RedisResult[])server.Execute("module", "list");
bool found = false;
foreach (var module in arr)
......@@ -83,7 +86,8 @@ internal static ConnectionMultiplexer GetWithFT(ITestOutputHelper output)
{
var result = server.Execute("module", "load", modulePath);
output?.WriteLine((string)result);
} catch(RedisServerException err)
}
catch (RedisServerException err)
{
// *probably* duplicate load; we'll try the tests anyways!
output?.WriteLine(err.Message);
......
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>StackExchange.Redis.Tests</Description>
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">net462;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>net462;netcoreapp2.1</TargetFrameworks>
<AssemblyName>StackExchange.Redis.Tests</AssemblyName>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<SignAssembly>true</SignAssembly>
<DebugType>full</DebugType>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
......@@ -24,10 +20,7 @@
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.3.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" PrivateAssets="all" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
......
......@@ -4,16 +4,13 @@
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<Description>Basic redis server based on StackExchange.Redis</Description>
<AssemblyTitle>StackExchange.Redis</AssemblyTitle>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>StackExchange.Redis.Server</AssemblyName>
<PackageId>StackExchange.Redis.Server</PackageId>
<PackageTags>Server;Async;Redis;Cache;PubSub;Messaging</PackageTags>
<OutputTypeEx>Library</OutputTypeEx>
<SignAssembly>true</SignAssembly>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<LangVersion>latest</LangVersion>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\StackExchange.Redis\StackExchange.Redis.csproj" />
......
......@@ -3,7 +3,6 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp2.1;net461;net462;net47;net472</TargetFrameworks>
<LangVersion>latest</LangVersion>
<DefineConstants>SEV2</DefineConstants>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
......
......@@ -3,7 +3,6 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp2.1;net461;net462;net47;net472</TargetFrameworks>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Computername)'=='OCHO' or '$(Computername)'=='SKINK'">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment