dotnet build with multi-targeting#3932
Merged
Merged
Conversation
7cb2264 to
eca8868
Compare
eca8868 to
be8c2e3
Compare
This comment was marked as resolved.
This comment was marked as resolved.
techman83
approved these changes
Nov 27, 2023
Member
techman83
left a comment
There was a problem hiding this comment.
This is awesome @HebaruSan - yes, every time I got looking at that stuff, my head hurts. Nice to see the warnings gone!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivations
Since #2820, we have had
Debug_NetCoreandRelease_NetCorebuild configurations that compiled the Core and Test projects targeting .NET Core (now ".NET 7"; I'm not going to try to explain the difference between .NET Core/Standard/5/6/7/etc. and .NET Framework here because it drives me batty). These build options were run by our GitHub build workflows, but not used, and it was easy to forget they existed and thus submit a PR that broke them. They worked by setting theBuildFrameworkconditionally inside the .csproj files based on theConfiguration, which is not great because it tightly couples the framework and configuration when in principle these could be independent. It would be nice to integrate this support better into the main build.In addition, see #3929 (review), our .NET 7 builds currently emit about 100 warnings about obsolete code, platform-specific code reachable on all platforms, etc.
https://github.com/KSP-CKAN/CKAN/actions/runs/6916657258?pr=3929
Changes
Debug_NetCoreandRelease_NetCoreconfigurations are replaced by aNoGUIconfiguration that builds everything except GUI and AutoUpdater (because both depend on WinForms), which is independent of the target framework<TargetFramework>is replaced by<TargetFrameworks>net48;net7.0-windows</TargetFrameworks>if it uses WinForms (which .NET 7 considers specific to the Windows platform), or<TargetFrameworks>net48;net7.0;net7.0-windows</TargetFrameworks>otherwise, which will make them always build for both .NET Framework 4.8 and .NET 7.0. Tests and CmdLine use#ifchecks to include and exclude code that depends on those projects.build.cakealways builds for both frameworks, and./build testand.\build.ps1 testrun tests for both frameworksdotnet buildbecause it can successfully build all projects for all target frameworks, but on Linux it usesdotnet buildfor the .NET 7 part of the build and the old Monomsbuildto build for .NET Framework 4.8, because it is the only way to build WinForms code on Linux. Ideally in the future we would find a way to makedotnet buildwork for everything on Linux as well, but that would require finding a way to install non-Mono WinForms support libraries.build.ymlno longer uses the*_NetCoreconfigurations because the main build covers what they used to doResources.Designer.csfiles are deleted and automatically generated from the .resx files during the build, as VS intended, which will simplify translation maintenanceUri.EscapeUriStringare replaced byUri.EscapeDataString#ifchecks or checkPlatform.IsWindows, which is now marked with theSupportedOSPlatformGuardattribute to indicate that it is safe to run platform-specific code if it returnstrueWebClientandWebRequestare switched to the newerHttpClientPermissionSetattribute isn't used in .NET 7SHA1.Create()andSHA256.Create()instead of calling the constructors ofSHA1CryptoServiceProviderandSHA256CryptoServiceProviderRedirectWebClientwas unused and is removedSupportedOSPlatformattribute so it can use WinForms in .NET 7This addresses all of those .NET 7 build warnings and brings CKAN another step closer to using a more modern framework. With all our projects now able to build on .NET 7, we have the future opportunity to investigate switching over to it fully. There are many obstacles in the way (cross-platform WinForms, packing dependencies into an EXE, etc.), but all of the unnecessary ones that our build system had created are cleared.