Skip to content

Commit de13412

Browse files
committed
Do more with .NET 5
- Build with .NET 5.0.100 SDK This requires also updating the NB.GV LKG version we build with. - Build benchmarks for net5.0 as well - Install the new SDK on agents - Add .NET Core 3.1 runtime for testing - Run tests on net5.0 instead of netcoreapp3.1 While we'd rather test *both*, microsoft/MSBuildLocator#95 is likely the cause for a failure of MSBuild to locate System.Collections.dll,v5.0 when running on the .NET Core 3.1 runtime but under the 5.0 SDK.
1 parent 77fe64b commit de13412

File tree

12 files changed

+35
-29
lines changed

12 files changed

+35
-29
lines changed

azure-pipelines.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ stages:
3939
matrix:
4040
linux:
4141
imageName: 'ubuntu-20.04'
42-
testModifier: -f netcoreapp3.1
42+
testModifier: -f net5.0
4343
windows:
4444
imageName: 'windows-2019'
4545
testModifier:
@@ -58,10 +58,17 @@ stages:
5858
displayName: Configure git commit author for testing
5959
6060
- task: UseDotNet@2
61-
displayName: Install .NET Core SDK 3.1.100
61+
displayName: Install .NET Core SDK 5.0.100
6262
inputs:
6363
packageType: sdk
64-
version: 3.1.100
64+
version: 5.0.100
65+
66+
- task: UseDotNet@2
67+
displayName: Install .NET Core 3.1
68+
inputs:
69+
packageType: runtime
70+
version: 3.1.x
71+
6572
- script: dotnet --info
6673
displayName: Show dotnet SDK info
6774

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"sdk": {
3-
"version": "3.1.100"
3+
"version": "5.0.100"
44
}
55
}

src/Cake.GitVersioning/Cake.GitVersioning.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<ItemGroup>
3333
<PackageReference Include="Cake.Core" Version="0.33.0" PrivateAssets="all" />
3434
<PackageReference Include="DotNetMDDocs" Version="0.111.0" Condition=" '$(GenerateMarkdownApiDocs)' == 'true' " />
35-
<PackageReference Include="Nerdbank.GitVersioning.LKG" Version="3.1.93" />
35+
<PackageReference Include="Nerdbank.GitVersioning.LKG" Version="3.3.37" />
3636
</ItemGroup>
3737

3838
<ItemGroup>

src/NerdBank.GitVersioning.Benchmarks/Nerdbank.GitVersioning.Benchmarks.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netcoreapp3.1;netcoreapp2.1</TargetFrameworks>
4+
<TargetFrameworks>netcoreapp3.1;netcoreapp2.1;net5.0</TargetFrameworks>
55
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">$(TargetFrameworks);net461</TargetFrameworks>
66
<OutputType>Exe</OutputType>
77
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
@@ -12,7 +12,7 @@
1212
<ItemGroup>
1313
<PackageReference Include="BenchmarkDotNet" Version="0.12.1" />
1414
<PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.12.0" />
15-
<PackageReference Include="Nerdbank.GitVersioning.LKG" Version="3.1.93" />
15+
<PackageReference Include="Nerdbank.GitVersioning.LKG" Version="3.3.37" />
1616
</ItemGroup>
1717

1818
<ItemGroup>

src/NerdBank.GitVersioning.Tests/BuildIntegrationTests.cs

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

9191
private void Init()
9292
{
93-
#if !NET461
94-
GitLoaderContext.RuntimePath = "./runtimes";
95-
#endif
96-
9793
int seed = (int)DateTime.Now.Ticks;
9894
this.random = new Random(seed);
9995
this.Logger.WriteLine("Random seed: {0}", seed);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>netcoreapp3.1;net461</TargetFrameworks>
3+
<TargetFrameworks>net5.0;net461</TargetFrameworks>
44
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
55
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
66
<DebugType>full</DebugType>
@@ -37,13 +37,13 @@
3737
<PackageReference Include="System.Collections.Immutable" Version="1.5.0" />
3838
<PackageReference Include="Microsoft.Build" Version="15.1.548" ExcludeAssets="runtime" />
3939
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="15.1.548" ExcludeAssets="runtime" />
40-
<PackageReference Include="Microsoft.Build.Locator" Version="1.2.2" />
40+
<PackageReference Include="Microsoft.Build.Locator" Version="1.2.6" />
4141
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="4.9.0" />
4242
<PackageReference Include="Xunit.Combinatorial" Version="1.2.7" />
4343
<PackageReference Include="xunit" Version="2.4.1" />
4444
<PackageReference Include="coverlet.collector" Version="1.3.0" />
4545
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.10.0" />
46-
<PackageReference Include="Nerdbank.GitVersioning.LKG" Version="3.1.93" />
46+
<PackageReference Include="Nerdbank.GitVersioning.LKG" Version="3.3.37" />
4747
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
4848
<PrivateAssets>all</PrivateAssets>
4949
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>

src/NerdBank.GitVersioning/NerdBank.GitVersioning.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
1616
<PackageReference Include="Nullable" Version="1.3.0" PrivateAssets="all" />
1717
<PackageReference Include="Validation" Version="2.5.5-beta" />
18-
<PackageReference Include="Nerdbank.GitVersioning.LKG" Version="3.1.93" />
18+
<PackageReference Include="Nerdbank.GitVersioning.LKG" Version="3.3.37" />
1919
<PackageReference Include="System.Text.Json" Version="4.7.2" />
2020
<PackageReference Include="PInvoke.Kernel32" Version="0.7.82" />
2121
</ItemGroup>

src/Nerdbank.GitVersioning.Tasks/GitLoaderContext.cs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,13 @@ public class GitLoaderContext : AssemblyLoadContext
1515
{
1616
public static readonly GitLoaderContext Instance = new GitLoaderContext();
1717

18-
// When invoked as a MSBuild task, the native libraries will be at
19-
// ../runtimes. When invoked from the nbgv CLI, the libraries
20-
// will be at ./runtimes.
21-
// This property allows code which consumes GitLoaderContext to
22-
// differentiate between these different locations.
23-
// In the case of the nbgv CLI, the value is set in Program.Main()
24-
public static string RuntimePath = "../runtimes";
18+
public const string RuntimePath = "./runtimes";
2519

2620
protected override Assembly Load(AssemblyName assemblyName)
2721
{
2822
var path = Path.Combine(Path.GetDirectoryName(typeof(GitLoaderContext).Assembly.Location), assemblyName.Name + ".dll");
2923
return File.Exists(path)
30-
? LoadFromAssemblyPath(path)
24+
? this.LoadFromAssemblyPath(path)
3125
: Default.LoadFromAssemblyName(assemblyName);
3226
}
3327

@@ -52,7 +46,7 @@ protected override IntPtr LoadUnmanagedDll(string unmanagedDllName)
5246
nativeLibraryPath = Path.Combine(directory, "lib" + unmanagedDllName);
5347
}
5448

55-
modulePtr = LoadUnmanagedDllFromPath(nativeLibraryPath);
49+
modulePtr = this.LoadUnmanagedDllFromPath(nativeLibraryPath);
5650
}
5751

5852
return (modulePtr != IntPtr.Zero) ? modulePtr : base.LoadUnmanagedDll(unmanagedDllName);
@@ -61,7 +55,17 @@ protected override IntPtr LoadUnmanagedDll(string unmanagedDllName)
6155
internal static string GetNativeLibraryDirectory()
6256
{
6357
var dir = Path.GetDirectoryName(typeof(GitLoaderContext).Assembly.Location);
64-
return Path.Combine(dir, RuntimePath, RuntimeIdMap.GetNativeLibraryDirectoryName(RuntimeEnvironment.GetRuntimeIdentifier()), "native");
58+
59+
// When invoked as a MSBuild task, the native libraries will be at
60+
// ../runtimes. When invoked from the nbgv CLI, the libraries
61+
// will be at ./runtimes.
62+
string runtimePath = RuntimePath;
63+
if (!Directory.Exists(Path.Combine(dir, runtimePath)))
64+
{
65+
runtimePath = "." + runtimePath;
66+
}
67+
68+
return Path.Combine(dir, runtimePath, RuntimeIdMap.GetNativeLibraryDirectoryName(RuntimeEnvironment.GetRuntimeIdentifier()), "native");
6569
}
6670

6771
private static string GetNativeLibraryExtension()

src/Nerdbank.GitVersioning.Tasks/Nerdbank.GitVersioning.Tasks.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
</ItemDefinitionGroup>
7575

7676
<ItemGroup>
77-
<PackageReference Include="Nerdbank.GitVersioning.LKG" Version="3.1.93" />
77+
<PackageReference Include="Nerdbank.GitVersioning.LKG" Version="3.3.37" />
7878
</ItemGroup>
7979
<ItemGroup>
8080
<ProjectReference Include="..\NerdBank.GitVersioning\NerdBank.GitVersioning.csproj" />

src/Nerdbank.GitVersioning.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1010
..\azure-pipelines.yml = ..\azure-pipelines.yml
1111
..\build.ps1 = ..\build.ps1
1212
Directory.Build.props = Directory.Build.props
13+
..\global.json = ..\global.json
1314
..\init.ps1 = ..\init.ps1
1415
nuget.config = nuget.config
1516
..\README.md = ..\README.md

0 commit comments

Comments
 (0)