Skip to content

Commit

Permalink
target .NET 8
Browse files Browse the repository at this point in the history
  • Loading branch information
adamralph committed Dec 21, 2023
1 parent 6b2c00b commit d964e85
Show file tree
Hide file tree
Showing 17 changed files with 71 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM mcr.microsoft.com/vscode/devcontainers/dotnet:0-7.0
FROM mcr.microsoft.com/vscode/devcontainers/dotnet:0-8.0

RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install lts/* && npm install -g cspell 2>&1"
52 changes: 23 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,23 @@ jobs:
- job:
os: macos-11
tests:
framework: net6.0
sdk: "6.0.417"
sdk-major-minor: "6.0"
framework: net8.0
sdk: "8.0.100"
sdk-major-minor: "8.0"
# current macOS, latest LTS and latest
- job:
os: macos-12
tests:
framework: net6.0
sdk: "6.0.417"
sdk-major-minor: "6.0"
- job:
os: macos-12
tests:
framework: net7.0
sdk: "7.0.404"
sdk-major-minor: "7.0"
framework: net8.0
sdk: "8.0.100"
sdk-major-minor: "8.0"
# old Linux, latest LTS
- job:
os: ubuntu-20.04
tests:
framework: net6.0
sdk: "6.0.417"
sdk-major-minor: "6.0"
framework: net8.0
sdk: "8.0.100"
sdk-major-minor: "8.0"
# current Linux, all
- job:
os: ubuntu-22.04
Expand All @@ -53,34 +47,34 @@ jobs:
framework: net7.0
sdk: "7.0.404"
sdk-major-minor: "7.0"
# old Windows, latest LTS
- job:
os: windows-2019
os: ubuntu-22.04
tests:
framework: net6.0
sdk: "6.0.417"
sdk-major-minor: "6.0"
# current Windows, latest LTS and latest
framework: net8.0
sdk: "8.0.100"
sdk-major-minor: "8.0"
# old Windows, latest LTS
- job:
os: windows-2022
os: windows-2019
tests:
framework: net6.0
sdk: "6.0.417"
sdk-major-minor: "6.0"
framework: net8.0
sdk: "8.0.100"
sdk-major-minor: "8.0"
# current Windows, latest LTS and latest
- job:
os: windows-2022
tests:
framework: net7.0
sdk: "7.0.404"
sdk-major-minor: "7.0"
framework: net8.0
sdk: "8.0.100"
sdk-major-minor: "8.0"
name: ${{ matrix.job.os }}-sdk-${{ matrix.tests.sdk-major-minor }}
runs-on: ${{ matrix.job.os }}
steps:
- uses: actions/[email protected]
with:
dotnet-version: |
${{ matrix.tests.sdk }}
7.0.404
8.0.100
- run: dotnet --info
- run: git --version
- uses: actions/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
steps:
- uses: actions/[email protected]
with:
dotnet-version: 7.0.404
dotnet-version: 8.0.100
- uses: actions/[email protected]
- env:
MINVER_VERSION: ${{ vars.MINVER_VERSION }}
Expand Down
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": ".NET Launch (console)",
"type": "coreclr",
"request": "launch",
"program": "${workspaceFolder}/targets/bin/Debug/net7.0/Targets.dll",
"program": "${workspaceFolder}/targets/bin/Debug/net8.0/Targets.dll",
"args": [
"default"
],
Expand Down
3 changes: 1 addition & 2 deletions MinVer.Lib/MinVer.Lib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

<PropertyGroup>
<IsPackable>false</IsPackable>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<LangVersion>default</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="NuGet.Versioning" Version="6.8.0" />
</ItemGroup>

Expand Down
3 changes: 1 addition & 2 deletions MinVer/MinVer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<RollForward>major</RollForward>
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<LangVersion>default</LangVersion>
</PropertyGroup>

Expand All @@ -29,7 +29,6 @@

<ItemGroup>
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="4.1.0" PrivateAssets="All" Publish="true" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Update="Microsoft.NETCore.App" PrivateAssets="All" />
</ItemGroup>

Expand Down
1 change: 1 addition & 0 deletions MinVer/build/MinVer.targets
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<MinVerDetailed Condition="'$(MinVerVerbosity)' == 'detailed' Or '$(MinVerVerbosity)' == 'd' Or '$(MinVerVerbosity)' == 'diagnostic' Or '$(MinVerVerbosity)' == 'diag'">high</MinVerDetailed>
<MinVerTargetFramework>net6.0</MinVerTargetFramework>
<MinVerTargetFramework Condition="'$(MSBuildAssemblyVersion)' &gt;= '17.4'">net7.0</MinVerTargetFramework>
<MinVerTargetFramework Condition="'$(MSBuildAssemblyVersion)' &gt;= '17.8'">net8.0</MinVerTargetFramework>
<NoWarn>$(NoWarn);NU5105</NoWarn>
</PropertyGroup>

Expand Down
3 changes: 3 additions & 0 deletions MinVerTests.Infra/MinVerCli.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public static string GetPath(string configuration) =>
#endif
#if NET7_0
Solution.GetFullPath($"minver-cli/bin/{configuration}/net7.0/minver-cli.dll");
#endif
#if NET8_0
Solution.GetFullPath($"minver-cli/bin/{configuration}/net8.0/minver-cli.dll");
#endif
}
}
2 changes: 1 addition & 1 deletion MinVerTests.Infra/MinVerTests.Infra.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<IsPackable>false</IsPackable>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
45 changes: 31 additions & 14 deletions MinVerTests.Infra/Sdk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ public static async Task CreateSolution(string path, string[] projectNames, stri
}
}

public static async Task CreateProject(string path, string configuration = Configuration.Current, bool multiTarget = false)
public static async Task CreateProject(string path, string configuration = Configuration.Current, bool multiTarget = false, bool enableSourceLink = false)
{
FileSystem.EnsureEmptyDirectory(path);

CreateGlobalJsonIfRequired(path);

await CreateProject(path, configuration, "test", multiTarget).ConfigureAwait(false);
await CreateProject(path, configuration, "test", multiTarget, enableSourceLink).ConfigureAwait(false);
}

private static async Task CreateProject(string path, string configuration, string name, bool multiTarget = false)
private static async Task CreateProject(string path, string configuration, string name, bool multiTarget = false, bool enableSourceLink = false)
{
_ = await DotNet($"new classlib --name {name} --output {path}{(multiTarget ? " --langVersion 8.0" : "")}", path).ConfigureAwait(false);

Expand All @@ -70,21 +70,38 @@ private static async Task CreateProject(string path, string configuration, strin

_ = await DotNet($"add package MinVer --source {source} --version {minVerPackageVersion} --package-directory packages", path).ConfigureAwait(false);

if (multiTarget)
{
var project = Path.Combine(path, $"{name}.csproj");
var lines = await File.ReadAllLinesAsync(project).ConfigureAwait(false);
var project = Path.Combine(path, $"{name}.csproj");
var lines = await File.ReadAllLinesAsync(project).ConfigureAwait(false);
var editedLines = new List<string>();

var editedLines = lines
.Select(line => line.Contains("<TargetFramework>", StringComparison.OrdinalIgnoreCase)
? line
foreach (var line in lines)
{
if (line.Contains("<TargetFramework>", StringComparison.OrdinalIgnoreCase))
{
if (multiTarget)
{
editedLines.Add(line
.Replace("TargetFramework", "TargetFrameworks", StringComparison.OrdinalIgnoreCase)
.Replace("</TargetFrameworks>", ";netstandard2.1</TargetFrameworks>", StringComparison.Ordinal)
: line);

await File.WriteAllLinesAsync(project, editedLines).ConfigureAwait(false);
.Replace("</TargetFrameworks>", ";netstandard2.1</TargetFrameworks>", StringComparison.Ordinal));
}
else
{
editedLines.Add(line);
}

if (!enableSourceLink)
{
editedLines.Add("<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>");
}
}
else
{
editedLines.Add(line);
}
}

await File.WriteAllLinesAsync(project, editedLines).ConfigureAwait(false);

_ = await DotNet($"restore --source {source} --packages packages", path).ConfigureAwait(false);
}

Expand Down
2 changes: 1 addition & 1 deletion MinVerTests.Lib/MinVerTests.Lib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<RollForward>major</RollForward>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion MinVerTests.Packages/MinVerTests.Packages.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<RollForward>major</RollForward>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>default</LangVersion>
</PropertyGroup>

Expand Down
6 changes: 1 addition & 5 deletions MinVerTests.Packages/SourceLink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ public static async Task HasCommitSha()
{
// arrange
var path = MethodBase.GetCurrentMethod().GetTestDirectory();
await Sdk.CreateProject(path);

_ = await Sdk.DotNet($"add package Microsoft.SourceLink.GitHub --version 1.1.1 --package-directory packages", path);
_ = await Sdk.DotNet("restore --packages packages", path);

await Sdk.CreateProject(path,enableSourceLink:true);
await Git.Init(path);
await Git.Commit(path);
var sha = (await Git.GetCommitShas(path)).Single();
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "7.0.100",
"version": "8.0.100",
"rollForward": "latestMajor"
}
}
3 changes: 1 addition & 2 deletions minver-cli/minver-cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<RollForward>major</RollForward>
<RootNamespace>MinVer</RootNamespace>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<ToolCommandName>minver</ToolCommandName>
<LangVersion>default</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="4.1.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion targets/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using static Bullseye.Targets;
using static SimpleExec.Command;

var testFx = Environment.GetEnvironmentVariable("MINVER_TESTS_FRAMEWORK") ?? "net7.0";
var testFx = Environment.GetEnvironmentVariable("MINVER_TESTS_FRAMEWORK") ?? "net8.0";
var testLoggerArgs = new List<string> { "--logger", "\"console;verbosity=normal\"", };

if (Environment.GetEnvironmentVariable("GITHUB_ACTIONS")?.ToUpperInvariant() == "TRUE")
Expand Down
2 changes: 1 addition & 1 deletion targets/Targets.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<IsPackable>false</IsPackable>
<OutputType>Exe</OutputType>
<RollForward>major</RollForward>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>default</LangVersion>
</PropertyGroup>

Expand Down

0 comments on commit d964e85

Please sign in to comment.