Skip to content

CSHARP-5591: Configure MongoDB.Driver.Encryption.Tests to run on net472 target #1692

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

Merged
merged 2 commits into from
May 16, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 0 additions & 6 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,6 @@ Task("Test")
items: GetFiles("./**/*.Tests.csproj").Where(name => !name.ToString().Contains("Atlas")),
action: (BuildConfig buildConfig, Path testProject) =>
{
if (Environment.GetEnvironmentVariable("MONGODB_API_VERSION") != null &&
Copy link
Contributor

Choose a reason for hiding this comment

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

+1

testProject.ToString().Contains("Legacy"))
{
return; // Legacy tests are exempt from Version API testing
}

var mongoX509ClientCertificatePath = Environment.GetEnvironmentVariable("MONGO_X509_CLIENT_CERTIFICATE_PATH");
if (mongoX509ClientCertificatePath != null)
{
Expand Down
6 changes: 2 additions & 4 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,16 @@ if($FoundDotNetCliVersion -ne $DotNetVersion) {
New-Item -Path $InstallPath -ItemType Directory -Force | Out-Null;
}

# N.B. We explicitly install .NET Core 2.1 and 3.1 because .NET 5.0 SDK can build those TFMs
# 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 2.1 and 3.1 won't be installed if
# 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 2.1 --no-path
& 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
Expand All @@ -111,7 +110,6 @@ if($FoundDotNetCliVersion -ne $DotNetVersion) {
else {
$ScriptPath = Join-Path $InstallPath 'dotnet-install.ps1'
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallerUri, $ScriptPath);
& $ScriptPath -Channel 2.1 -InstallDir $InstallPath;
& $ScriptPath -Channel 3.1 -InstallDir $InstallPath;
& $ScriptPath -Channel 5.0 -InstallDir $InstallPath;
& $ScriptPath -Channel 6.0 -InstallDir $InstallPath;
Expand Down
5 changes: 2 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,17 @@ if [ "$DOTNET_VERSION" != "$DOTNET_INSTALLED_VERSION" ]; 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 2.1 and 3.1 because .NET 6.0 SDK can build those TFMs
# 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 2.1 and 3.1 won't be installed if
# 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 2.1 --architecture x64 --install-dir .dotnet --no-path
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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\BuildProps\Tests.Build.props" />
<Import Project="..\BuildProps\Tests.Build.props" />

<PropertyGroup>
<TargetFrameworks>net472;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp3.1;net6.0</TargetFrameworks>

<Platforms>AnyCPU</Platforms>
<IsPackable>false</IsPackable>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\MongoDB.Driver.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<ItemGroup>
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" PrivateAssets="All" Version="1.0.0" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Combine with other PackageReference.

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved into Test.Build.props file

</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
Expand All @@ -21,8 +25,8 @@
</PropertyGroup>

<ItemGroup>
<None Include="$(CMakeCurrentSourceDir)/xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<None Update="xunit.runner.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

Expand Down
8 changes: 4 additions & 4 deletions tests/MongoDB.Driver.Encryption.Tests/xunit.runner.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://xunit.github.io/schema/current/xunit.runner.schema.json",

"appDomain": "denied",
"shadowCopy": false
"longRunningTestSeconds": 10,
"parallelizeAssembly": false,
"parallelizeTestCollections": false,
"shadowCopy": false
}