xna-cncnet-client
xna-cncnet-client copied to clipboard
.NET 6 Cross platform
-
Updated frameworks
- .NET 4.8
- DirectX targets AnyCPU
- OpenGL targets AnyCPU
- XNA targets x86
- .NET 6.0:
- net6.0-windows: WinForms, Windows 7 and up
- net6.0: cross platform
- DirectX targets AnyCPU
- OpenGL targets AnyCPU
- XNA targets x86
- .NET 4.8
-
Updated dependencies
- New Rampastring.Tools local NuGet package
- New Rampastring.XNAUI.* local NuGet packages
- XNA 4.0 Refresh
- MonoGame DX & GL 3.8.0 (.NET 4.8)
- MonoGame DX & GL 3.8.1 (.NET 6.0)
- Replaced Ionic.Zip with System.IO.Compression
- Use Izo.net NuGet package
- Use OpenMcdf NuGet package
- New ClientUpdater local NuGet package
-
Switch to new project file format
-
New solution configurations and platforms
- Configurations: AresWindowsDXDebug;AresUniversalGLDebug;AresWindowsGLDebug;AresWindowsXNADebug; AresWindowsDXRelease;AresUniversalGLRelease;AresWindowsGLRelease;AresWindowsXNARelease; TSWindowsDXDebug;TSUniversalGLDebug;TSWindowsGLDebug;TSWindowsXNADebug; TSWindowsDXRelease;TSUniversalGLRelease;TSWindowsGLRelease;TSWindowsXNARelease; YRWindowsDXDebug;YRUniversalGLDebug;YRWindowsGLDebug;YRWindowsXNADebug; YRWindowsDXRelease;YRUniversalGLRelease;YRWindowsGLRelease;YRWindowsXNARelease
- Platforms: AnyCPU, x86, x64, ARM64
-
Includes .editorconfig with my default warning rules. This triggers many new warnings. The rules can be reviewed and updated, or I can fix the current warnings in another PR.
-
Cross platform
-
Adds an additional .NET6.0 'UniversalGL' build without WinForms. Allows client to be run on any device with .NET6.0 installed (new Rampastring.XNAUI package).
-
Improves .NET4.8 compatibility on mono
-
Cross platform building (build on Linux, run on Windows and vice versa)
-
Tested (YR):
- .NET4.8 WindowsGL on mono (WSL2 Ubuntu 20.04)
- .NET6.0 UniversalGL on WSL2 Ubuntu 20.04
- .NET6.0 UniversalGL on Fedora 36.1.5
- .NET6.0 UniversalGL on Windows 11
- All other existing builds on Windows 11
-
Changes:
- Uses the platform safe SafePath methods for handling file system path operations (new Rampastring.Tools package)
- Replaced WinForms Clipboard with TextCopy
- Replaced WinForms/System.Drawing with ImageSharp
- Replaced WinForms Screen with XNA GraphicsAdapter.DefaultAdapter
- Replaced WindowsIdentity.GetCurrent().Name with Environment.UserName
-
Limitations for UniversalGL build:
- Can not use WinForms based methods of WindowManager; HasFocus, Minimize, Maximize, Hide, ...
- Win API is only supported on Windows; FlashWindowEx, LoadCursorFromFile
- Registry is only supported on Windows
-
TODO:
- The Windows Registry is used by TS. Currently this code is guarded by RuntimeInformation.IsOSPlatform() checks. This will need a replacement to store information on the file system instead.
-
Notes:
- Switching to/from an XNA configuration within Visual Studio may require you to unload and reload the ClientCore project file (or restart VS) regarding MonoGame/XNA dependencies
Prerequisites* for this PR:
- https://github.com/Rampastring/Rampastring.Tools/pull/4
- https://github.com/Rampastring/Rampastring.XNAUI/pull/17
- https://github.com/CnCNet/cncnet-client-updater/pull/1 And just FYI there's also this PR, which is not related to this PR:
- https://github.com/CnCNet/cncnet-server/pull/1
* Strictly taken these are not prerequisites because the code in the linked PR's is included in this PR as local NuGet packages.
Nightly build for this pull request:
- artifacts.zip This comment is automatic and is meant to allow guests to get latest automatic builds without registering. It is updated on every successful build.
I added the recently added new updater temporarily as a project in the solution until it's made officially public. This is needed to make it work on .NET6 as the current updater code throws exceptions.
I added the recently added new updater temporarily as a project in the solution until it's made officially public. This is needed to make it work on .NET6 as the current updater code throws exceptions.
Check CnCNet repos, should be public already.
I added the recently added new updater temporarily as a project in the solution until it's made officially public. This is needed to make it work on .NET6 as the current updater code throws exceptions.
Check CnCNet repos, should be public already.
Thanks for the heads up. I saw that repo a while ago but noticed it was not the currently included updater dll. I didn't realize the newly added dll was coming from this repo. I'll create a PR for that repo and include it as a NuGet package in this PR similar to Rampastring.Tools and Rampastring.XNAUI.
Included the new updater as a NuGet package
.NET 6 abandoned the machine-specific ANSI encoding and writing text files with this encoding is needed for the map editors for TS/RA2. Otherwise, the map editors will not work if the program path contains any non-ASCII characters. I suggest find an alternative way to generate configuration files for map editors before migrating to .NET 6.
See https://github.com/CnCNet/xna-cncnet-client/pull/127 for more details about the text encoding issues that is needed for legacy games
See also https://docs.microsoft.com/en-us/dotnet/api/system.text.encoding.default?view=netframework-4.8
https://stackoverflow.com/a/70258850

ref
- https://docs.microsoft.com/dotnet/api/system.text.codepagesencodingprovider
- https://github.com/dotnet/standard/issues/260#issuecomment-289534859
ref
* https://docs.microsoft.com/dotnet/api/system.text.codepagesencodingprovider * [What is default encoding in .Net? dotnet/standard#260 (comment)](https://github.com/dotnet/standard/issues/260#issuecomment-289534859)
Good catch. One question remaining: If the option "Beta: Use Unicode UTF-8 for worldwide language support" is enabled, does your code get UTF-8 as the default ANSI encoding?
ref
* https://docs.microsoft.com/dotnet/api/system.text.codepagesencodingprovider * [What is default encoding in .Net? dotnet/standard#260 (comment)](https://github.com/dotnet/standard/issues/260#issuecomment-289534859)Good catch. One question remaining: If the option "Beta: Use Unicode UTF-8 for worldwide language support" is enabled, does your code get UTF-8 as the default ANSI encoding?
yes

Isn't this handled already with this change in the PR? bc885d6ab8b977176d13ff41510d588f29bfbec9
Isn't this handled already with this change in the PR? bc885d6
No. Your commit completely breaks the functionality. See the original comment in the source code.
ANSI doesn't mean a specific codepage, it means the default non-Unicode codepage which can be changed from Control Panel.
ref
* https://docs.microsoft.com/dotnet/api/system.text.codepagesencodingprovider * [What is default encoding in .Net? dotnet/standard#260 (comment)](https://github.com/dotnet/standard/issues/260#issuecomment-289534859)Good catch. One question remaining: If the option "Beta: Use Unicode UTF-8 for worldwide language support" is enabled, does your code get UTF-8 as the default ANSI encoding?
yes
Excellent work
Looks good to me :)
Looks good to my eye. Though I think this now bumps the requirement to having VS2022 if you plan on building for .NET 6 right? Would be good to mention that in the readme.
I made some updates to the readme
Closes #218
Closes #218
We can use asynchronous methods. It waits until there is no data until it is transferred.
The suggestion I wrote in #218 was a busy waiting, which was a mistake.
and add closed CnCNet/xna-cncnet-client#218 in commit can close issue when PR be merge.
see github docs https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue
Closes #218
We can use asynchronous methods. It waits until there is no data until it is transferred.
I was planning to replace all Threading code with Tasks and async/await at a later stage.
Cross platform changes merged MonoGame updated to 3.8.1
Umm... May you can public the AppHostPatcher source code? I'll try to make it as MSBuild Extension.
Umm... May you can public the AppHostPatcher source code? I'll try to make it as MSBuild Extension.
I don't have a proper place to upload it, but it's not that much code, you can maybe use ILSpy or something :)
Umm... May you can public the AppHostPatcher source code? I'll try to make it as MSBuild Extension.
I don't have a proper place to upload it, but it's not that much code, you can maybe use ILSpy or something :)
Well, I find a MSBuild Task in .Net SDK. We can use this target to hack apphost.
We just need to change the AppBinaryName property.
It should be executed after the task _CreateAppHost and before _ComputeNETCoreBuildOutputFiles.
_CreateAppHostwill create anapphost.exeinobjfolder._ComputeNETCoreBuildOutputFileswill moveapphost.exeto output folder.
<Target Name="_CreateAppHost_Hack" AfterTargets="_CreateAppHost">
<CreateAppHost AppHostSourcePath="$(AppHostSourcePath)"
AppHostDestinationPath="$(AppHostIntermediatePath)"
AppBinaryName="$(AssemblyName)$(TargetExt)"
IntermediateAssembly="@(IntermediateAssembly->'%(FullPath)')"
WindowsGraphicalUserInterface="$(_UseWindowsGraphicalUserInterface)"
Retries="$(CopyRetryCount)"
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
EnableMacOSCodeSign="$(_EnableMacOSCodeSign)"
/>
</Target>
My brain is churning.
I resignoff some commit at https://github.com/frg2089/xna-cncnet-client/commits/develop
rebase that to remove Unverified tag.
maybe.
use this command to signoff commit history.
git rebase --signoff <HASH>
Oh and also, I didn't see a clear way to specify what target runtime, 4.8 or 6.0, to compile for.
LGTM on your front 😄