Pryaxis / TShock

☕️⚡️TShock provides Terraria servers with server-side characters, anti-cheat, and community management tools.
GNU General Public License v3.0
2.41k stars 377 forks source link

Use global.json to control .NET SDK version #2883

Open Arthri opened 1 year ago

Arthri commented 1 year ago

Is your feature request related to a problem? Please describe. Currently, the NuGet CI and OTAPI CI use different versions of the .NET SDK. This is not a problem right now but someone might forget to update them in the future. Additionally, introducing a global.json ensures everyone is on the same SDK version and mitigates build problems https://github.com/Pryaxis/TShock/blob/6e589ffaeed99fa1b1559a5aa18c375d04961fb3/.github/workflows/ci-otapi3.yml#L16 https://github.com/Pryaxis/TShock/blob/6e589ffaeed99fa1b1559a5aa18c375d04961fb3/.github/workflows/ci-otapi3.yml#L34 https://github.com/Pryaxis/TShock/blob/6e589ffaeed99fa1b1559a5aa18c375d04961fb3/.github/workflows/ci-otapi3-nuget.yml#L20

Describe the solution you'd like Introduce a global.json at the repository's top level. This file controls which version of the .NET SDK MSBuild uses, but setup-dotnet(action used to setup .NET in CI) also supports it(in this case the dotnet-version should be removed):

Usage

See action.yml

Basic:

steps:
- uses: actions/checkout@v3
- uses: actions/setup-dotnet@v3
  with:
    dotnet-version: '3.1.x'
- run: dotnet build <my project>

Warning: Unless a concrete version is specified in the global.json file, the latest .NET version installed on the runner (including preinstalled versions) will be used by default. Please refer to the documentation for the currently preinstalled .NET SDK versions.

The example config below specifies 6.0.100 as the SDK version, but allows a leniency of any version under 6.0.*. 6.0.404 passes, but 6.1.100 or 7.0.101 doesn't

{
    "sdk": {
        "version": "6.0.100",
        "rollForward": "latestFeature"
    }
}

Describe alternatives you've considered none considered

Additional context none

csmir commented 1 year ago

It should also be worth to implement the security patches that have been rolled out so far. Considering these patches range from remote code execution (112) to unintended privilege elevation (110), it should be quite important to keep up with them, even if they don't directly apply to the current codebase.