Skip to content

Commit 7145e19

Browse files
qmfrederikAArnott
andauthored
Enable tests on netcoreapp3.1 (#520)
* AssemblyVersionInfo task: Log error when targetting an unsupported language. * Skip SevenZipNet dependency on .NET Core * Enable tests on netcoreapp3.1 RuntimePath is ./runtimes instead of ../runtimes * Skip NativeVersionInfo_CreateNativeResourceDll on .NET Core * Update src/NerdBank.GitVersioning.Tests/BuildIntegrationTests.cs Co-authored-by: Andrew Arnott <[email protected]>
1 parent d56dc3e commit 7145e19

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

src/NerdBank.GitVersioning.Tests/BuildIntegrationTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ public BuildIntegrationTests(ITestOutputHelper logger)
5757

5858
private void Init()
5959
{
60+
#if !NET461
61+
GitLoaderContext.RuntimePath = "./runtimes";
62+
#endif
63+
6064
int seed = (int)DateTime.Now.Ticks;
6165
this.random = new Random(seed);
6266
this.Logger.WriteLine("Random seed: {0}", seed);
@@ -936,6 +940,7 @@ public async Task AssemblyInfo_SuppressedImplicitlyByTargetExt()
936940
Assert.Empty(result.LoggedEvents.OfType<BuildWarningEventArgs>());
937941
}
938942

943+
#if !NETCOREAPP
939944
/// <summary>
940945
/// Create a native resource .dll and verify that its version
941946
/// information is set correctly.
@@ -958,6 +963,7 @@ public async Task NativeVersionInfo_CreateNativeResourceDll()
958963
Assert.Equal("NerdBank", fileInfo.CompanyName);
959964
Assert.Equal($"Copyright (c) {DateTime.Now.Year}. All rights reserved.", fileInfo.LegalCopyright);
960965
}
966+
#endif
961967

962968
private static Version GetExpectedAssemblyVersion(VersionOptions versionOptions, Version version)
963969
{

src/NerdBank.GitVersioning.Tests/NerdBank.GitVersioning.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net461</TargetFramework>
3+
<TargetFrameworks>net461;netcoreapp3.1</TargetFrameworks>
44
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
55
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
66
<DebugType>full</DebugType>

src/NerdBank.GitVersioning.Tests/TestUtilities.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using SevenZipNET;
1+
#if NET461
2+
using SevenZipNET;
3+
#endif
24
using Validation;
35

46
using System;
@@ -58,6 +60,7 @@ internal static void ExtractEmbeddedResource(string resourcePath, string extract
5860

5961
internal static ExpandedRepo ExtractRepoArchive(string repoArchiveName)
6062
{
63+
#if NET461
6164
string archiveFilePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
6265
string expandedFolderPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
6366

@@ -84,6 +87,9 @@ internal static ExpandedRepo ExtractRepoArchive(string repoArchiveName)
8487
File.Delete(archiveFilePath);
8588
}
8689
}
90+
#else
91+
throw new PlatformNotSupportedException();
92+
#endif
8793
}
8894

8995
internal class ExpandedRepo : IDisposable

src/Nerdbank.GitVersioning.Tasks/AssemblyVersionInfo.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,10 @@ public override bool Execute()
310310
Directory.CreateDirectory(Path.GetDirectoryName(this.OutputFile));
311311
Utilities.FileOperationWithRetry(() => File.WriteAllText(this.OutputFile, fileContent));
312312
}
313+
else
314+
{
315+
this.Log.LogError("CodeDomProvider not available for language: {0}. No version info will be embedded into assembly.", this.CodeLanguage);
316+
}
313317

314318
return !this.Log.HasLoggedErrors;
315319
}

src/Nerdbank.GitVersioning.Tasks/GitLoaderContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Nerdbank.GitVersioning
1313
{
14-
internal class GitLoaderContext : AssemblyLoadContext
14+
public class GitLoaderContext : AssemblyLoadContext
1515
{
1616
public static readonly GitLoaderContext Instance = new GitLoaderContext();
1717

0 commit comments

Comments
 (0)