Skip to content

Commit d06b28c

Browse files
authored
Change supported target frameworks (#4001)
* Change supported target frameworks * upgrade from net461 to net462 * drop support for net40, net45 * drop support for < netstandard2.0 * drop netcoreapp2.1, netcoreapp3.1 and net5.0 * upgrade NUKE * switch back to using windows-latest GH Actions image which now has NET 6 support * Add Net70 to NSwag.Npm/README.md
1 parent 344e1c7 commit d06b28c

File tree

47 files changed

+136
-377
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+136
-377
lines changed

.github/workflows/build.yml

+7-11
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ on:
2828
- '!**/*.md'
2929

3030
jobs:
31-
windows-2022:
32-
name: windows-2022
33-
runs-on: windows-2022
31+
windows-latest:
32+
name: windows-latest
33+
runs-on: windows-latest
3434
steps:
3535
- name: 'Allow long file path'
3636
run: git config --system core.longpaths true
@@ -40,27 +40,23 @@ jobs:
4040
run: |
4141
echo "Adding GNU tar to PATH"
4242
echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%"
43-
- uses: actions/setup-dotnet@v3
44-
with:
45-
dotnet-version: |
46-
2.1.*
47-
5.0.*
4843
- uses: actions/checkout@v3
49-
- name: Cache .nuke/temp, ~/.nuget/packages
44+
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
5045
uses: actions/cache@v3
5146
with:
5247
path: |
5348
.nuke/temp
5449
~/.nuget/packages
5550
key: ${{ runner.os }}-${{ hashFiles('global.json', 'src/**/*.csproj', 'src/**/package.json') }}
56-
- name: Run './build.cmd InstallDependencies Compile Test Pack Publish'
51+
- name: 'Run: InstallDependencies, Compile, Test, Pack, Publish'
5752
run: ./build.cmd InstallDependencies Compile Test Pack Publish
5853
env:
5954
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
6055
MYGET_API_KEY: ${{ secrets.MYGET_API_KEY }}
6156
CHOCO_API_KEY: ${{ secrets.CHOCO_API_KEY }}
6257
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
63-
- uses: actions/upload-artifact@v3
58+
- name: 'Publish: artifacts'
59+
uses: actions/upload-artifact@v3
6460
with:
6561
name: artifacts
6662
path: artifacts

.github/workflows/pr.yml

+8-10
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ on:
2626
- '!**/*.md'
2727

2828
jobs:
29-
windows-2022:
30-
name: windows-2022
31-
runs-on: windows-2022
29+
windows-latest:
30+
name: windows-latest
31+
runs-on: windows-latest
32+
concurrency:
33+
group: ${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.run_id }}
34+
cancel-in-progress: true
3235
steps:
3336
- name: 'Allow long file path'
3437
run: git config --system core.longpaths true
@@ -38,18 +41,13 @@ jobs:
3841
run: |
3942
echo "Adding GNU tar to PATH"
4043
echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%"
41-
- uses: actions/setup-dotnet@v3
42-
with:
43-
dotnet-version: |
44-
2.1.*
45-
5.0.*
4644
- uses: actions/checkout@v3
47-
- name: Cache .nuke/temp, ~/.nuget/packages
45+
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
4846
uses: actions/cache@v3
4947
with:
5048
path: |
5149
.nuke/temp
5250
~/.nuget/packages
5351
key: ${{ runner.os }}-${{ hashFiles('global.json', 'src/**/*.csproj', 'src/**/package.json') }}
54-
- name: Run './build.cmd InstallDependencies Compile Test Pack'
52+
- name: 'Run: InstallDependencies, Compile, Test, Pack'
5553
run: ./build.cmd InstallDependencies Compile Test Pack

.nuke/build.schema.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "http://json-schema.org/draft-04/schema#",
3-
"title": "Build Schema",
43
"$ref": "#/definitions/build",
4+
"title": "Build Schema",
55
"definitions": {
66
"build": {
77
"type": "object",
@@ -131,4 +131,4 @@
131131
}
132132
}
133133
}
134-
}
134+
}

build.ps1

+6-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ $TempDirectory = "$PSScriptRoot\\.nuke\temp"
1818

1919
$DotNetGlobalFile = "$PSScriptRoot\\global.json"
2020
$DotNetInstallUrl = "https://dot.net/v1/dotnet-install.ps1"
21-
$DotNetChannel = "Current"
21+
$DotNetChannel = "STS"
2222

2323
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
2424
$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1
@@ -65,5 +65,10 @@ else {
6565

6666
Write-Output "Microsoft (R) .NET SDK version $(& $env:DOTNET_EXE --version)"
6767

68+
if (Test-Path env:NUKE_ENTERPRISE_TOKEN) {
69+
& $env:DOTNET_EXE nuget remove source "nuke-enterprise" > $null
70+
& $env:DOTNET_EXE nuget add source "https://f.feedz.io/nuke/enterprise/nuget" --name "nuke-enterprise" --username "PAT" --password $env:NUKE_ENTERPRISE_TOKEN > $null
71+
}
72+
6873
ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet }
6974
ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments }

build.sh

+6-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ TEMP_DIRECTORY="$SCRIPT_DIR//.nuke/temp"
1414

1515
DOTNET_GLOBAL_FILE="$SCRIPT_DIR//global.json"
1616
DOTNET_INSTALL_URL="https://dot.net/v1/dotnet-install.sh"
17-
DOTNET_CHANNEL="Current"
17+
DOTNET_CHANNEL="STS"
1818

1919
export DOTNET_CLI_TELEMETRY_OPTOUT=1
2020
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
@@ -58,5 +58,10 @@ fi
5858

5959
echo "Microsoft (R) .NET SDK version $("$DOTNET_EXE" --version)"
6060

61+
if [[ ! -z ${NUKE_ENTERPRISE_TOKEN+x} && "$NUKE_ENTERPRISE_TOKEN" != "" ]]; then
62+
"$DOTNET_EXE" nuget remove source "nuke-enterprise" &>/dev/null || true
63+
"$DOTNET_EXE" nuget add source "https://f.feedz.io/nuke/enterprise/nuget" --name "nuke-enterprise" --username "PAT" --password "$NUKE_ENTERPRISE_TOKEN" --store-password-in-clear-text &>/dev/null || true
64+
fi
65+
6166
"$DOTNET_EXE" build "$BUILD_PROJECT_FILE" /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet
6267
"$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" --no-build -- "$@"

build/Build.CI.GitHubActions.cs

+4-11
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
using System.Collections.Generic;
2-
using System.Linq;
32
using Nuke.Common.CI.GitHubActions;
43
using Nuke.Common.CI.GitHubActions.Configuration;
54
using Nuke.Common.Execution;
65
using Nuke.Common.Utilities;
76

87
[CustomGitHubActions(
98
"pr",
10-
GitHubActionsImage.WindowsServer2022,
9+
GitHubActionsImage.WindowsLatest,
1110
// GitHubActionsImage.UbuntuLatest,
1211
// GitHubActionsImage.MacOsLatest,
1312
OnPullRequestBranches = new[] { "master", "main" },
1413
OnPullRequestIncludePaths = new[] { "**/*.*" },
1514
OnPullRequestExcludePaths = new[] { "**/*.md" },
1615
PublishArtifacts = false,
1716
InvokedTargets = new[] { nameof(InstallDependencies), nameof(Compile), nameof(Test), nameof(Pack) },
18-
CacheKeyFiles = new[] { "global.json", "src/**/*.csproj", "src/**/package.json" }),
17+
CacheKeyFiles = new[] { "global.json", "src/**/*.csproj", "src/**/package.json" },
18+
JobConcurrencyCancelInProgress = true),
1919
]
2020
[CustomGitHubActions(
2121
"build",
22-
GitHubActionsImage.WindowsServer2022,
22+
GitHubActionsImage.WindowsLatest,
2323
// GitHubActionsImage.UbuntuLatest,
2424
// GitHubActionsImage.MacOsLatest,
2525
OnPushBranches = new[] { "master", "main" },
@@ -47,13 +47,6 @@ protected override GitHubActionsJob GetJobs(GitHubActionsImage image, IReadOnlyC
4747

4848
var newSteps = new List<GitHubActionsStep>(job.Steps);
4949

50-
// only need to list the ones that are missing from default image
51-
newSteps.Insert(0, new GitHubActionsSetupDotNetStep(new[]
52-
{
53-
"2.1.*",
54-
"5.0.*"
55-
}));
56-
5750
newSteps.Insert(0, new GitHubActionsUseGnuTarStep());
5851
newSteps.Insert(0, new GitHubActionsConfigureLongPathsStep());
5952

build/Build.Pack.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public partial class Build
3737
nugetVersion += "-" + VersionSuffix;
3838
}
3939

40-
EnsureCleanDirectory(ArtifactsDirectory);
40+
ArtifactsDirectory.CreateOrCleanDirectory();
4141

4242
// it seems to cause some headache with publishing, so let's dotnet pack only files we know are suitable
4343
var projects = SourceDirectory.GlobFiles("**/*.csproj")
@@ -70,10 +70,10 @@ public partial class Build
7070

7171
Serilog.Log.Information("Build WiX installer");
7272

73-
EnsureCleanDirectory(SourceDirectory / "NSwagStudio.Installer" / "bin");
73+
(SourceDirectory / "NSwagStudio.Installer" / "bin").CreateOrCleanDirectory();
7474

7575
MSBuild(x => x
76-
.SetTargetPath(Solution.GetProject("NSwagStudio.Installer"))
76+
.SetTargetPath(GetProject("NSwagStudio.Installer"))
7777
.SetTargets("Rebuild")
7878
.SetAssemblyVersion(VersionPrefix)
7979
.SetFileVersion(VersionPrefix)
@@ -90,9 +90,9 @@ public partial class Build
9090
Serilog.Log.Information("Package nuspecs");
9191

9292
var apiDescriptionClientNuSpec = SourceDirectory / "NSwag.ApiDescription.Client" / "NSwag.ApiDescription.Client.nuspec";
93-
var content = TextTasks.ReadAllText(apiDescriptionClientNuSpec);
93+
var content = apiDescriptionClientNuSpec.ReadAllText();
9494
content = content.Replace("<dependency id=\"NSwag.MSBuild\" version=\"1.0.0\" />", "<dependency id=\"NSwag.MSBuild\" version=\"" + nugetVersion + "\" />");
95-
TextTasks.WriteAllText(apiDescriptionClientNuSpec, content);
95+
apiDescriptionClientNuSpec.WriteAllText(content);
9696

9797
var nuspecs = new[]
9898
{
@@ -122,9 +122,9 @@ public partial class Build
122122

123123
// patch npm version
124124
var npmPackagesFile = SourceDirectory / "NSwag.Npm" / "package.json";
125-
content = TextTasks.ReadAllText(npmPackagesFile);
125+
content = npmPackagesFile.ReadAllText();
126126
content = Regex.Replace(content, @"""version"": "".*""", @"""version"": """ + nugetVersion + @"""");
127-
TextTasks.WriteAllText(npmPackagesFile, content);
127+
npmPackagesFile.WriteAllText(content);
128128

129129
// ZIP directories
130130
ZipFile.CreateFromDirectory(NSwagNpmBinaries, ArtifactsDirectory / "NSwag.Npm.zip");

build/Build.cs

+15-16
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
using Nuke.Common.Tools.DotNet;
1313
using Nuke.Common.Tools.MSBuild;
1414
using Nuke.Common.Tools.Npm;
15-
using Nuke.Common.Tools.VSTest;
1615
using Nuke.Common.Utilities.Collections;
1716

1817
using static Nuke.Common.IO.FileSystemTasks;
@@ -76,7 +75,7 @@ string DetermineVersionPrefix()
7675
}
7776
else
7877
{
79-
var propsDocument = XDocument.Parse(TextTasks.ReadAllText(SourceDirectory / "Directory.Build.props"));
78+
var propsDocument = XDocument.Parse((SourceDirectory / "Directory.Build.props").ReadAllText());
8079
versionPrefix = propsDocument.Element("Project").Element("PropertyGroup").Element("VersionPrefix").Value;
8180
Serilog.Log.Information("Version prefix {VersionPrefix} read from Directory.Build.props", versionPrefix);
8281
}
@@ -117,19 +116,15 @@ protected override void OnBuildInitialized()
117116
.Before(Restore)
118117
.Executes(() =>
119118
{
120-
SourceDirectory.GlobDirectories("**/bin", "**/obj").ForEach(DeleteDirectory);
121-
EnsureCleanDirectory(ArtifactsDirectory);
119+
SourceDirectory.GlobDirectories("**/bin", "**/obj").ForEach(x => x.DeleteDirectory());
120+
ArtifactsDirectory.CreateOrCleanDirectory();
122121
});
123122

124-
125123
Target InstallDependencies => _ => _
126124
.Before(Restore, Compile)
127125
.Executes(() =>
128126
{
129127
Chocolatey("install wixtoolset -y");
130-
Chocolatey("install dotnetcore-3.1-sdk -y");
131-
Chocolatey("install netfx-4.6.2-devpack -y");
132-
Chocolatey("install dotnet-7.0-sdk -y");
133128
NpmInstall(x => x
134129
.EnableGlobal()
135130
.AddPackages("dotnettools")
@@ -157,18 +152,19 @@ protected override void OnBuildInitialized()
157152
);
158153
});
159154

155+
// logic from 01_Build.bat
160156
Target Compile => _ => _
161157
.DependsOn(Restore)
162158
.Executes(() =>
163159
{
164-
EnsureCleanDirectory(SourceDirectory / "NSwag.Npm" / "bin" / "binaries");
165-
EnsureCleanDirectory(NSwagStudioBinaries);
160+
(SourceDirectory / "NSwag.Npm" / "bin" / "binaries").CreateOrCleanDirectory();
161+
NSwagStudioBinaries.CreateOrCleanDirectory();
166162

167163
Serilog.Log.Information("Build and copy full .NET command line with configuration {Configuration}", Configuration);
168164

169165
// TODO: Fix build here
170166
MSBuild(x => x
171-
.SetProjectFile(Solution.GetProject("NSwagStudio"))
167+
.SetProjectFile(GetProject("NSwagStudio"))
172168
.SetTargets("Build")
173169
.SetAssemblyVersion(VersionPrefix)
174170
.SetFileVersion(VersionPrefix)
@@ -215,9 +211,9 @@ protected override void OnBuildInitialized()
215211

216212
void PublishAndCopyConsoleProjects()
217213
{
218-
var consoleCoreProject = Solution.GetProject("NSwag.ConsoleCore");
219-
var consoleX86Project = Solution.GetProject("NSwag.Console.x86");
220-
var consoleProject = Solution.GetProject("NSwag.Console");
214+
var consoleCoreProject = GetProject("NSwag.ConsoleCore");
215+
var consoleX86Project = GetProject("NSwag.Console.x86");
216+
var consoleProject = GetProject("NSwag.Console");
221217

222218
Serilog.Log.Information("Publish command line projects");
223219

@@ -240,7 +236,7 @@ void PublishConsoleProject(Project project, string[] targetFrameworks)
240236

241237
PublishConsoleProject(consoleX86Project, new[] { "net462" });
242238
PublishConsoleProject(consoleProject, new[] { "net462" });
243-
PublishConsoleProject(consoleCoreProject, new[] { "netcoreapp3.1", "net6.0", "net7.0" });
239+
PublishConsoleProject(consoleCoreProject, new[] { "net6.0", "net7.0" });
244240

245241
void CopyConsoleBinaries(AbsolutePath target)
246242
{
@@ -252,7 +248,6 @@ void CopyConsoleBinaries(AbsolutePath target)
252248
CopyDirectoryRecursively(consoleProject.Directory / "bin" / Configuration / "net462" / "publish", target / "Win", DirectoryExistsPolicy.Merge);
253249

254250
var consoleCoreDirectory = consoleCoreProject.Directory / "bin" / Configuration;
255-
CopyDirectoryRecursively(consoleCoreDirectory / "netcoreapp3.1" / "publish", target / "NetCore31");
256251
CopyDirectoryRecursively(consoleCoreDirectory / "net6.0" / "publish", target / "Net60");
257252
CopyDirectoryRecursively(consoleCoreDirectory / "net7.0" / "publish", target / "Net70");
258253
}
@@ -276,4 +271,8 @@ DotNetBuildSettings BuildDefaults(DotNetBuildSettings s)
276271
.SetDeterministic(IsServerBuild)
277272
.SetContinuousIntegrationBuild(IsServerBuild);
278273
}
274+
275+
// Solution.GetProject only returns solution's direct descendants since NUKE 7.0.1
276+
private Project GetProject(string projectName) =>
277+
Solution.AllProjects.FirstOrDefault(x => x.Name == projectName) ?? throw new ArgumentException($"Could not find project {projectName} from solution");
279278
}

build/_build.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Nuke.Common" Version="6.3.0" />
14+
<PackageReference Include="Nuke.Common" Version="7.0.6" />
1515
</ItemGroup>
1616

1717
<ItemGroup>
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>netstandard2.0;net462</TargetFrameworks>
3+
<TargetFrameworks>net462;netstandard2.0</TargetFrameworks>
44
</PropertyGroup>
5-
5+
66
<PropertyGroup>
77
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
88
</PropertyGroup>
9-
10-
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
11-
<Reference Include="Microsoft.CSharp" />
12-
</ItemGroup>
139
</Project>

0 commit comments

Comments
 (0)