Skip to content
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

Change supported target frameworks #4001

Merged
merged 2 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
18 changes: 7 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ on:
- '!**/*.md'

jobs:
windows-2022:
name: windows-2022
runs-on: windows-2022
windows-latest:
name: windows-latest
runs-on: windows-latest
steps:
- name: 'Allow long file path'
run: git config --system core.longpaths true
Expand All @@ -40,27 +40,23 @@ jobs:
run: |
echo "Adding GNU tar to PATH"
echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%"
- uses: actions/setup-dotnet@v3
with:
dotnet-version: |
2.1.*
5.0.*
- uses: actions/checkout@v3
- name: Cache .nuke/temp, ~/.nuget/packages
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
uses: actions/cache@v3
with:
path: |
.nuke/temp
~/.nuget/packages
key: ${{ runner.os }}-${{ hashFiles('global.json', 'src/**/*.csproj', 'src/**/package.json') }}
- name: Run './build.cmd InstallDependencies Compile Test Pack Publish'
- name: 'Run: InstallDependencies, Compile, Test, Pack, Publish'
run: ./build.cmd InstallDependencies Compile Test Pack Publish
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
MYGET_API_KEY: ${{ secrets.MYGET_API_KEY }}
CHOCO_API_KEY: ${{ secrets.CHOCO_API_KEY }}
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
- uses: actions/upload-artifact@v3
- name: 'Publish: artifacts'
uses: actions/upload-artifact@v3
with:
name: artifacts
path: artifacts
18 changes: 8 additions & 10 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ on:
- '!**/*.md'

jobs:
windows-2022:
name: windows-2022
runs-on: windows-2022
windows-latest:
name: windows-latest
runs-on: windows-latest
concurrency:
group: ${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.run_id }}
cancel-in-progress: true
steps:
- name: 'Allow long file path'
run: git config --system core.longpaths true
Expand All @@ -38,18 +41,13 @@ jobs:
run: |
echo "Adding GNU tar to PATH"
echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%"
- uses: actions/setup-dotnet@v3
with:
dotnet-version: |
2.1.*
5.0.*
- uses: actions/checkout@v3
- name: Cache .nuke/temp, ~/.nuget/packages
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
uses: actions/cache@v3
with:
path: |
.nuke/temp
~/.nuget/packages
key: ${{ runner.os }}-${{ hashFiles('global.json', 'src/**/*.csproj', 'src/**/package.json') }}
- name: Run './build.cmd InstallDependencies Compile Test Pack'
- name: 'Run: InstallDependencies, Compile, Test, Pack'
run: ./build.cmd InstallDependencies Compile Test Pack
4 changes: 2 additions & 2 deletions .nuke/build.schema.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Build Schema",
"$ref": "#/definitions/build",
"title": "Build Schema",
"definitions": {
"build": {
"type": "object",
Expand Down Expand Up @@ -131,4 +131,4 @@
}
}
}
}
}
7 changes: 6 additions & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $TempDirectory = "$PSScriptRoot\\.nuke\temp"

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

$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1
Expand Down Expand Up @@ -65,5 +65,10 @@ else {

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

if (Test-Path env:NUKE_ENTERPRISE_TOKEN) {
& $env:DOTNET_EXE nuget remove source "nuke-enterprise" > $null
& $env:DOTNET_EXE nuget add source "https://f.feedz.io/nuke/enterprise/nuget" --name "nuke-enterprise" --username "PAT" --password $env:NUKE_ENTERPRISE_TOKEN > $null
}

ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet }
ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments }
7 changes: 6 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ TEMP_DIRECTORY="$SCRIPT_DIR//.nuke/temp"

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

export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
Expand Down Expand Up @@ -58,5 +58,10 @@ fi

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

if [[ ! -z ${NUKE_ENTERPRISE_TOKEN+x} && "$NUKE_ENTERPRISE_TOKEN" != "" ]]; then
"$DOTNET_EXE" nuget remove source "nuke-enterprise" &>/dev/null || true
"$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
fi

"$DOTNET_EXE" build "$BUILD_PROJECT_FILE" /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet
"$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" --no-build -- "$@"
15 changes: 4 additions & 11 deletions build/Build.CI.GitHubActions.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
using System.Collections.Generic;
using System.Linq;
using Nuke.Common.CI.GitHubActions;
using Nuke.Common.CI.GitHubActions.Configuration;
using Nuke.Common.Execution;
using Nuke.Common.Utilities;

[CustomGitHubActions(
"pr",
GitHubActionsImage.WindowsServer2022,
GitHubActionsImage.WindowsLatest,
// GitHubActionsImage.UbuntuLatest,
// GitHubActionsImage.MacOsLatest,
OnPullRequestBranches = new[] { "master", "main" },
OnPullRequestIncludePaths = new[] { "**/*.*" },
OnPullRequestExcludePaths = new[] { "**/*.md" },
PublishArtifacts = false,
InvokedTargets = new[] { nameof(InstallDependencies), nameof(Compile), nameof(Test), nameof(Pack) },
CacheKeyFiles = new[] { "global.json", "src/**/*.csproj", "src/**/package.json" }),
CacheKeyFiles = new[] { "global.json", "src/**/*.csproj", "src/**/package.json" },
JobConcurrencyCancelInProgress = true),
]
[CustomGitHubActions(
"build",
GitHubActionsImage.WindowsServer2022,
GitHubActionsImage.WindowsLatest,
// GitHubActionsImage.UbuntuLatest,
// GitHubActionsImage.MacOsLatest,
OnPushBranches = new[] { "master", "main" },
Expand Down Expand Up @@ -47,13 +47,6 @@ protected override GitHubActionsJob GetJobs(GitHubActionsImage image, IReadOnlyC

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

// only need to list the ones that are missing from default image
newSteps.Insert(0, new GitHubActionsSetupDotNetStep(new[]
{
"2.1.*",
"5.0.*"
}));

newSteps.Insert(0, new GitHubActionsUseGnuTarStep());
newSteps.Insert(0, new GitHubActionsConfigureLongPathsStep());

Expand Down
14 changes: 7 additions & 7 deletions build/Build.Pack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public partial class Build
nugetVersion += "-" + VersionSuffix;
}

EnsureCleanDirectory(ArtifactsDirectory);
ArtifactsDirectory.CreateOrCleanDirectory();

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

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

EnsureCleanDirectory(SourceDirectory / "NSwagStudio.Installer" / "bin");
(SourceDirectory / "NSwagStudio.Installer" / "bin").CreateOrCleanDirectory();

MSBuild(x => x
.SetTargetPath(Solution.GetProject("NSwagStudio.Installer"))
.SetTargetPath(GetProject("NSwagStudio.Installer"))
.SetTargets("Rebuild")
.SetAssemblyVersion(VersionPrefix)
.SetFileVersion(VersionPrefix)
Expand All @@ -90,9 +90,9 @@ public partial class Build
Serilog.Log.Information("Package nuspecs");

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

var nuspecs = new[]
{
Expand Down Expand Up @@ -122,9 +122,9 @@ public partial class Build

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

// ZIP directories
ZipFile.CreateFromDirectory(NSwagNpmBinaries, ArtifactsDirectory / "NSwag.Npm.zip");
Expand Down
31 changes: 15 additions & 16 deletions build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using Nuke.Common.Tools.DotNet;
using Nuke.Common.Tools.MSBuild;
using Nuke.Common.Tools.Npm;
using Nuke.Common.Tools.VSTest;
using Nuke.Common.Utilities.Collections;

using static Nuke.Common.IO.FileSystemTasks;
Expand Down Expand Up @@ -76,7 +75,7 @@ string DetermineVersionPrefix()
}
else
{
var propsDocument = XDocument.Parse(TextTasks.ReadAllText(SourceDirectory / "Directory.Build.props"));
var propsDocument = XDocument.Parse((SourceDirectory / "Directory.Build.props").ReadAllText());
versionPrefix = propsDocument.Element("Project").Element("PropertyGroup").Element("VersionPrefix").Value;
Serilog.Log.Information("Version prefix {VersionPrefix} read from Directory.Build.props", versionPrefix);
}
Expand Down Expand Up @@ -117,19 +116,15 @@ protected override void OnBuildInitialized()
.Before(Restore)
.Executes(() =>
{
SourceDirectory.GlobDirectories("**/bin", "**/obj").ForEach(DeleteDirectory);
EnsureCleanDirectory(ArtifactsDirectory);
SourceDirectory.GlobDirectories("**/bin", "**/obj").ForEach(x => x.DeleteDirectory());
ArtifactsDirectory.CreateOrCleanDirectory();
});


Target InstallDependencies => _ => _
.Before(Restore, Compile)
.Executes(() =>
{
Chocolatey("install wixtoolset -y");
Chocolatey("install dotnetcore-3.1-sdk -y");
Chocolatey("install netfx-4.6.2-devpack -y");
Chocolatey("install dotnet-7.0-sdk -y");
NpmInstall(x => x
.EnableGlobal()
.AddPackages("dotnettools")
Expand Down Expand Up @@ -157,18 +152,19 @@ protected override void OnBuildInitialized()
);
});

// logic from 01_Build.bat
Target Compile => _ => _
.DependsOn(Restore)
.Executes(() =>
{
EnsureCleanDirectory(SourceDirectory / "NSwag.Npm" / "bin" / "binaries");
EnsureCleanDirectory(NSwagStudioBinaries);
(SourceDirectory / "NSwag.Npm" / "bin" / "binaries").CreateOrCleanDirectory();
NSwagStudioBinaries.CreateOrCleanDirectory();

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

// TODO: Fix build here
MSBuild(x => x
.SetProjectFile(Solution.GetProject("NSwagStudio"))
.SetProjectFile(GetProject("NSwagStudio"))
.SetTargets("Build")
.SetAssemblyVersion(VersionPrefix)
.SetFileVersion(VersionPrefix)
Expand Down Expand Up @@ -215,9 +211,9 @@ protected override void OnBuildInitialized()

void PublishAndCopyConsoleProjects()
{
var consoleCoreProject = Solution.GetProject("NSwag.ConsoleCore");
var consoleX86Project = Solution.GetProject("NSwag.Console.x86");
var consoleProject = Solution.GetProject("NSwag.Console");
var consoleCoreProject = GetProject("NSwag.ConsoleCore");
var consoleX86Project = GetProject("NSwag.Console.x86");
var consoleProject = GetProject("NSwag.Console");

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

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

PublishConsoleProject(consoleX86Project, new[] { "net462" });
PublishConsoleProject(consoleProject, new[] { "net462" });
PublishConsoleProject(consoleCoreProject, new[] { "netcoreapp3.1", "net6.0", "net7.0" });
PublishConsoleProject(consoleCoreProject, new[] { "net6.0", "net7.0" });

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

var consoleCoreDirectory = consoleCoreProject.Directory / "bin" / Configuration;
CopyDirectoryRecursively(consoleCoreDirectory / "netcoreapp3.1" / "publish", target / "NetCore31");
CopyDirectoryRecursively(consoleCoreDirectory / "net6.0" / "publish", target / "Net60");
CopyDirectoryRecursively(consoleCoreDirectory / "net7.0" / "publish", target / "Net70");
}
Expand All @@ -276,4 +271,8 @@ DotNetBuildSettings BuildDefaults(DotNetBuildSettings s)
.SetDeterministic(IsServerBuild)
.SetContinuousIntegrationBuild(IsServerBuild);
}

// Solution.GetProject only returns solution's direct descendants since NUKE 7.0.1
private Project GetProject(string projectName) =>
Solution.AllProjects.FirstOrDefault(x => x.Name == projectName) ?? throw new ArgumentException($"Could not find project {projectName} from solution");
}
2 changes: 1 addition & 1 deletion build/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Nuke.Common" Version="6.3.0" />
<PackageReference Include="Nuke.Common" Version="7.0.6" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 2 additions & 6 deletions src/NSwag.Annotations/NSwag.Annotations.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net462</TargetFrameworks>
<TargetFrameworks>net462;netstandard2.0</TargetFrameworks>
</PropertyGroup>

<PropertyGroup>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
</Project>
Loading
Loading