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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 8 additions & 60 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ var mongoDbDriverPackageName = "MongoDB.Driver";

var solutionFile = solutionDirectory.CombineWithFilePath("CSharpDriver.sln");
var solutionFullPath = solutionFile.FullPath;
var srcProjectNames = new[]
{
"MongoDB.Bson",
"MongoDB.Driver"
};

Task("Default")
.IsDependentOn("Test");
Expand Down Expand Up @@ -70,13 +65,6 @@ Task("Build")
}
};

if (buildConfig.IsReleaseMode)
{
Console.WriteLine("Build continuousIntegration is enabled");
settings.MSBuildSettings = new DotNetMSBuildSettings();
// configure deterministic build for better compatibility with debug symbols (used in Package/Build tasks). Affects: *.nupkg
settings.MSBuildSettings.SetContinuousIntegrationBuild(continuousIntegrationBuild: true);
}
DotNetBuild(solutionFullPath, settings);
});

Expand Down Expand Up @@ -132,10 +120,6 @@ Task("Test")
})
.DeferOnError();

Task("TestNet472").IsDependentOn("Test");
Task("TestNetStandard21").IsDependentOn("Test");
Task("TestNet60").IsDependentOn("Test");

Task("TestAwsAuthentication")
.IsDependentOn("Build")
.DoesForEach(
Expand Down Expand Up @@ -184,10 +168,6 @@ Task("TestGssapi")
action: (BuildConfig buildConfig, Path testProject) =>
RunTests(buildConfig, testProject, filter: "Category=\"GssapiMechanism\""));

Task("TestGssapiNet472").IsDependentOn("TestGssapi");
Task("TestGssapiNetStandard21").IsDependentOn("TestGssapi");
Task("TestGssapiNet60").IsDependentOn("TestGssapi");

Task("TestMongoDbOidc")
.IsDependentOn("Build")
.DoesForEach(
Expand All @@ -208,35 +188,20 @@ Task("TestLoadBalanced")
action: (BuildConfig buildConfig, Path testProject) =>
RunTests(buildConfig, testProject, filter: "Category=\"SupportLoadBalancing\""));

Task("TestLoadBalancedNetStandard21").IsDependentOn("TestLoadBalanced");
Task("TestLoadBalancedNet60").IsDependentOn("TestLoadBalanced");

Task("TestSocks5ProxyNet472").IsDependentOn("TestSocks5Proxy");
Task("TestSocks5ProxyNetStandard21").IsDependentOn("TestSocks5Proxy");
Task("TestSocks5ProxyNet60").IsDependentOn("TestSocks5Proxy");

Task("TestCsfleWithMockedKms")
.IsDependentOn("TestLibMongoCrypt")
.DoesForEach(
items: GetFiles("./**/*.Tests.csproj"),
action: (BuildConfig buildConfig, Path testProject) =>
RunTests(buildConfig, testProject, filter: "Category=\"CSFLE\""));

Task("TestCsfleWithMockedKmsNet472").IsDependentOn("TestCsfleWithMockedKms");
Task("TestCsfleWithMockedKmsNetStandard21").IsDependentOn("TestCsfleWithMockedKms");
Task("TestCsfleWithMockedKmsNet60").IsDependentOn("TestCsfleWithMockedKms");

Task("TestCsfleWithMongocryptd")
.IsDependentOn("TestLibMongoCrypt")
.DoesForEach(
items: GetFiles("./**/*.Tests.csproj"),
action: (BuildConfig buildConfig, Path testProject) =>
RunTests(buildConfig, testProject, filter: "Category=\"CSFLE\""));

Task("TestCsfleWithMongocryptdNet472").IsDependentOn("TestCsfleWithMongocryptd");
Task("TestCsfleWithMongocryptdNetStandard21").IsDependentOn("TestCsfleWithMongocryptd");
Task("TestCsfleWithMongocryptdNet60").IsDependentOn("TestCsfleWithMongocryptd");

Task("TestCsfleWithAzureKms")
.IsDependentOn("TestLibMongoCrypt")
.DoesForEach(
Expand All @@ -258,8 +223,6 @@ Task("TestX509")
action: (BuildConfig buildConfig, Path testProject) =>
RunTests(buildConfig, testProject, filter: "Category=\"X509\""));

Task("TestX509Net60").IsDependentOn("TestX509");

Task("TestSocks5Proxy")
.IsDependentOn("Build")
.DoesForEach(
Expand Down Expand Up @@ -376,12 +339,6 @@ Task("SmokeTests")
});
});

Task("SmokeTestsNet472").IsDependentOn("SmokeTests");
Task("SmokeTestsNetCoreApp31").IsDependentOn("SmokeTests");
Task("SmokeTestsNet50").IsDependentOn("SmokeTests");
Task("SmokeTestsNet60").IsDependentOn("SmokeTests");
Task("SmokeTestsNet80").IsDependentOn("SmokeTests");

Setup<BuildConfig>(
setupContext =>
{
Expand All @@ -392,37 +349,28 @@ Setup<BuildConfig>(
var unknownArchitecture => throw new Exception($"Unknown CPU architecture: {unknownArchitecture}.")
};

var lowerTarget = target.ToLowerInvariant();
var framework = lowerTarget switch
var framework = Environment.GetEnvironmentVariable("FRAMEWORK");
if (string.Equals(framework, "netstandard2.1", StringComparison.InvariantCultureIgnoreCase))
{
string s when s.EndsWith("netstandard21") || s.EndsWith("netcoreapp31") => "netcoreapp3.1",
string s when s.EndsWith("net472") => "net472",
string s when s.EndsWith("net50") => "net5.0",
string s when s.EndsWith("net60") => "net6.0",
string s when s.EndsWith("net80") => "net8.0",
_ => null
};

var isReleaseMode = lowerTarget.StartsWith("package") || lowerTarget == "release";
var packageVersion = lowerTarget.StartsWith("smoketests") ? Environment.GetEnvironmentVariable("PACKAGE_VERSION") : gitVersion.LegacySemVer;
framework = "netcoreapp3.1";
}

Console.WriteLine($"Framework: {framework ?? "null (not set)"}, TargetPlatform: {targetPlatform}, IsReleaseMode: {isReleaseMode}, PackageVersion: {packageVersion}");
var packageVersion = target.ToLowerInvariant().StartsWith("smoketests") ? Environment.GetEnvironmentVariable("PACKAGE_VERSION") : gitVersion.LegacySemVer;
Console.WriteLine($"Framework: {framework ?? "null (not set)"}, TargetPlatform: {targetPlatform}, PackageVersion: {packageVersion}");

return new BuildConfig(isReleaseMode, framework, targetPlatform, packageVersion);
return new BuildConfig(framework, targetPlatform, packageVersion);
});

RunTarget(target);

public class BuildConfig
{
public bool IsReleaseMode { get; }
public string Framework { get; }
public string PackageVersion { get; }
public string TargetPlatform { get; }

public BuildConfig(bool isReleaseMode, string framework, string targetPlatform, string packageVersion)
public BuildConfig(string framework, string targetPlatform, string packageVersion)
{
IsReleaseMode = isReleaseMode;
Framework = framework;
TargetPlatform = targetPlatform;
PackageVersion = packageVersion;
Expand Down
1 change: 0 additions & 1 deletion build.config
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
#!/usr/bin/env bash
CAKE_VERSION=2.3.0
DOTNET_VERSION=8.0.204
83 changes: 2 additions & 81 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,16 @@ $DotNetChannel = 'LTS'
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent

[string] $CakeVersion = ''
[string] $DotNetVersion= ''
foreach($line in Get-Content (Join-Path $PSScriptRoot 'build.config'))
{
if ($line -like 'CAKE_VERSION=*') {
$CakeVersion = $line.SubString(13)
}
elseif ($line -like 'DOTNET_VERSION=*') {
$DotNetVersion =$line.SubString(15)
}
}


if ([string]::IsNullOrEmpty($CakeVersion) -or [string]::IsNullOrEmpty($DotNetVersion)) {
'Failed to parse Cake / .NET Core SDK Version'
if ([string]::IsNullOrEmpty($CakeVersion)) {
'Failed to parse Cake Version'
exit 1
}

Expand Down Expand Up @@ -46,81 +42,6 @@ if ($PSVersionTable.PSEdition -ne 'Core') {
}
}

###########################################################################
# INSTALL .NET CORE CLI
###########################################################################

$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
$env:DOTNET_CLI_TELEMETRY_OPTOUT=1
$env:DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX=2


Function Remove-PathVariable([string]$VariableToRemove)
{
$SplitChar = ';'
if ($IsMacOS -or $IsLinux) {
$SplitChar = ':'
}

$path = [Environment]::GetEnvironmentVariable("PATH", "User")
if ($path -ne $null)
{
$newItems = $path.Split($SplitChar, [StringSplitOptions]::RemoveEmptyEntries) | Where-Object { "$($_)" -inotlike $VariableToRemove }
[Environment]::SetEnvironmentVariable("PATH", [System.String]::Join($SplitChar, $newItems), "User")
}

$path = [Environment]::GetEnvironmentVariable("PATH", "Process")
if ($path -ne $null)
{
$newItems = $path.Split($SplitChar, [StringSplitOptions]::RemoveEmptyEntries) | Where-Object { "$($_)" -inotlike $VariableToRemove }
[Environment]::SetEnvironmentVariable("PATH", [System.String]::Join($SplitChar, $newItems), "Process")
}
}

# Get .NET Core CLI path if installed.
$FoundDotNetCliVersion = $null;
if (Get-Command dotnet -ErrorAction SilentlyContinue) {
$FoundDotNetCliVersion = dotnet --version;
}

if($FoundDotNetCliVersion -ne $DotNetVersion) {
$InstallPath = Join-Path $PSScriptRoot ".dotnet"
if (!(Test-Path $InstallPath)) {
New-Item -Path $InstallPath -ItemType Directory -Force | Out-Null;
}

# N.B. We explicitly install .NET Core 3.1 because .NET 5.0 SDK can build those TFMs
# but will silently upgrade to a more recent runtime to execute tests if the desired runtime
# isn't available. For example, `dotnet run --framework netcoreapp3.0` will silently run
# on .NET 5.0 if .NET Core 3.0 and 3.1 aren't installed.
# This solution is admittedly hacky as .NET Core 3.1 won't be installed if
# $DOTNET_VERSION matches $DOTNET_INSTALLED_VERSION, but it minimizes the changes required
# to install required dependencies on Evergreen.
if ($IsMacOS -or $IsLinux) {
$ScriptPath = Join-Path $InstallPath 'dotnet-install.sh'
(New-Object System.Net.WebClient).DownloadFile($DotNetUnixInstallerUri, $ScriptPath);
& bash $ScriptPath --install-dir "$InstallPath" --channel 3.1 --no-path
& bash $ScriptPath --install-dir "$InstallPath" --channel 5.0 --no-path
& bash $ScriptPath --install-dir "$InstallPath" --channel 6.0 --no-path
& bash $ScriptPath --version "$DotNetVersion" --install-dir "$InstallPath" --channel "$DotNetChannel" --no-path

Remove-PathVariable "$InstallPath"
$env:PATH = "$($InstallPath):$env:PATH"
}
else {
$ScriptPath = Join-Path $InstallPath 'dotnet-install.ps1'
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallerUri, $ScriptPath);
& $ScriptPath -Channel 3.1 -InstallDir $InstallPath;
& $ScriptPath -Channel 5.0 -InstallDir $InstallPath;
& $ScriptPath -Channel 6.0 -InstallDir $InstallPath;
& $ScriptPath -Channel $DotNetChannel -Version $DotNetVersion -InstallDir $InstallPath;

Remove-PathVariable "$InstallPath"
$env:PATH = "$InstallPath;$env:PATH"
}
$env:DOTNET_ROOT=$InstallPath
}

###########################################################################
# INSTALL CAKE
###########################################################################
Expand Down
43 changes: 3 additions & 40 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ TOOLS_DIR=$SCRIPT_DIR/tools
CAKE_EXE=$TOOLS_DIR/dotnet-cake
CAKE_PATH=$TOOLS_DIR/.store/cake.tool/$CAKE_VERSION

if [ "$CAKE_VERSION" = "" ] || [ "$DOTNET_VERSION" = "" ]; then
echo "An error occured while parsing Cake / .NET Core SDK version."
if [ "$CAKE_VERSION" = "" ]; then
echo "An error occured while parsing Cake version."
exit 1
fi

Expand All @@ -16,48 +16,11 @@ if [ ! -d "$TOOLS_DIR" ]; then
mkdir "$TOOLS_DIR"
fi

###########################################################################
# INSTALL .NET CORE CLI
###########################################################################

export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0
export DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX=2

DOTNET_INSTALLED_VERSION=$(dotnet --version 2>&1)

if [ "$DOTNET_VERSION" != "$DOTNET_INSTALLED_VERSION" ]; then
echo "Installing .NET CLI..."
if [ ! -d "$SCRIPT_DIR/.dotnet" ]; then
mkdir "$SCRIPT_DIR/.dotnet"
fi
curl -Lfo "$SCRIPT_DIR/.dotnet/dotnet-install.sh" https://builds.dotnet.microsoft.com/dotnet/scripts/v1/dotnet-install.sh
# N.B. We explicitly install .NET Core 3.1 because .NET 6.0 SDK can build those TFMs
# but will silently upgrade to a more recent runtime to execute tests if the desired runtime
# isn't available. For example, `dotnet run --framework netcoreapp3.0` will silently run
# on .NET 6.0 if .NET Core 3.0 and 3.1 aren't installed.
# This solution is admittedly hacky as .NET Core 3.1 won't be installed if
# $DOTNET_VERSION matches $DOTNET_INSTALLED_VERSION, but it minimizes the changes required
# to install required dependencies on Evergreen.
# Since ARM64 support was first added in .NET 6.0, the following commands will install:
# | CPU | 2.1 | 3.1 | Latest |
# | x64 | x64 | x64 | x64 |
# | arm64 | x64 | x64 | arm64 |
bash "$SCRIPT_DIR/.dotnet/dotnet-install.sh" --channel 3.1 --architecture x64 --install-dir .dotnet --no-path
bash "$SCRIPT_DIR/.dotnet/dotnet-install.sh" --channel 5.0 --architecture x64 --install-dir .dotnet --no-path
bash "$SCRIPT_DIR/.dotnet/dotnet-install.sh" --channel 6.0 --install-dir .dotnet --no-path
bash "$SCRIPT_DIR/.dotnet/dotnet-install.sh" --version $DOTNET_VERSION --install-dir .dotnet --no-path
export PATH="$SCRIPT_DIR/.dotnet":$PATH
export DOTNET_ROOT="$SCRIPT_DIR/.dotnet"
fi

###########################################################################
# INSTALL CAKE
###########################################################################

CAKE_INSTALLED_VERSION=$(dotnet-cake --version 2>&1)

CAKE_INSTALLED_VERSION=$(dotnet-cake --version 2>&1) || true
if [ "$CAKE_VERSION" != "$CAKE_INSTALLED_VERSION" ]; then
if [ ! -f "$CAKE_EXE" ] || [ ! -d "$CAKE_PATH" ]; then
if [ -f "$CAKE_EXE" ]; then
Expand Down
22 changes: 0 additions & 22 deletions evergreen/compile.sh

This file was deleted.

Loading