xna-cncnet-client icon indicating copy to clipboard operation
xna-cncnet-client copied to clipboard

Copy built-in resources to "OutputPath" only when needed

Open pzhlkj6612 opened this issue 1 year ago • 2 comments

Hi.

Commit message

Copy built-in resources to "OutputPath" only when needed

The conditions are:

- It's being debugged;
- It's DXMainClient;
- It's cross-targeting build ('$(TargetFramework)' == ''). Don't know the whole story, just from my guess:
    - https://github.com/dotnet/msbuild/blob/b497794a81585d40ba5401acde02200f7b7d863b/src/Tasks/Microsoft.Managed.Before.targets
    - https://github.com/dotnet/msbuild/blob/b497794a81585d40ba5401acde02200f7b7d863b/src/Tasks/Microsoft.Common.CrossTargeting.targets
- No "ClientDefinitions.ini" in destination.

Why

I've seen the "SUN.INI" file multiple times when playing with YR client. So today I did a search in the project root directory:

$ find . -path '*/bin/*' -name 'SUN.ini'
./ClientCore/bin/Debug/YR/WindowsDX/net48/SUN.ini
./ClientCore/bin/Debug/YR/WindowsDX/net8.0-windows/SUN.ini
./ClientCore/bin/Debug/YR/WindowsDX/SUN.ini
./ClientGUI/bin/Debug/YR/WindowsDX/net48/SUN.ini
./ClientGUI/bin/Debug/YR/WindowsDX/net8.0-windows/SUN.ini
./ClientGUI/bin/Debug/YR/WindowsDX/SUN.ini
./ClientUpdater/bin/Debug/YR/WindowsDX/net48/SUN.ini
./ClientUpdater/bin/Debug/YR/WindowsDX/net8.0/SUN.ini
./ClientUpdater/bin/Debug/YR/WindowsDX/SUN.ini
./DTAConfig/bin/Debug/YR/WindowsDX/net48/SUN.ini
./DTAConfig/bin/Debug/YR/WindowsDX/net8.0-windows/SUN.ini
./DTAConfig/bin/Debug/YR/WindowsDX/SUN.ini
./DXMainClient/bin/Debug/YR/WindowsDX/net48/SUN.ini
./DXMainClient/bin/Debug/YR/WindowsDX/net8.0-windows/SUN.ini
./DXMainClient/bin/Debug/YR/WindowsDX/SUN.ini
./SecondStageUpdater/bin/Debug/YR/WindowsDX/net48/SUN.ini
./SecondStageUpdater/bin/Debug/YR/WindowsDX/net48/Updater/SUN.ini
./SecondStageUpdater/bin/Debug/YR/WindowsDX/net8.0/SUN.ini
./SecondStageUpdater/bin/Debug/YR/WindowsDX/net8.0/Updater/SUN.ini
./TranslationNotifierGenerator/bin/Debug/YR/WindowsDX/netstandard2.0/SUN.ini
./TranslationNotifierGenerator/bin/Debug/YR/WindowsDX/SUN.ini

Oh, they are too many, aren't they?

After doing some testing, I think we need to tweak the "CopyResources" target by adding more conditions, so I did it in this PR.

Change

After applying this PR, the built-in resources will be copied to the bin\Debug\$(Game)\$(Engine) directory, so the binary of both net8.0 and non-net8.0 will share the same game files.

Question

I can see the duplicated SearchResourcesDir(string startupPath) functions in both DXMainClient and ClientCore modules:

https://github.com/CnCNet/xna-cncnet-client/blob/bae385595f48c525f1f44baf24044f337dc6cae2/ClientCore/ProgramConstants.cs#L118-L144

My question is: do we need those resources during debugging ClientCore? If so, I think I may need to change the condition statement.

pzhlkj6612 avatar Jan 08 '25 08:01 pzhlkj6612

Nightly build for this pull request:

github-actions[bot] avatar Jan 08 '25 08:01 github-actions[bot]

f1fb5cf98f2959b44108e46e2180980c473c5c4c:

Without the $(MSBuildProjectName) check, we will get copied resources as the follows:

$ find . -path '*/bin/*' -name 'SUN.ini'
./ClientCore/bin/Debug/YR/WindowsDX/SUN.ini
./ClientGUI/bin/Debug/YR/WindowsDX/SUN.ini
./ClientUpdater/bin/Debug/YR/WindowsDX/SUN.ini
./DTAConfig/bin/Debug/YR/WindowsDX/SUN.ini
./DXMainClient/bin/Debug/YR/WindowsDX/SUN.ini
./TranslationNotifierGenerator/bin/Debug/YR/WindowsDX/SUN.ini

for d in 'ClientCore' 'ClientGUI' 'ClientUpdater' 'DTAConfig' 'DXMainClient' 'TranslationNotifierGenerator'; do
    echo "dir($d) = $(grep -rnw 'Resources' --include '*.cs' ./$d | wc -l)";
done

dir(ClientCore) = 22
dir(ClientGUI) = 0
dir(ClientUpdater) = 4
dir(DTAConfig) = 5
dir(DXMainClient) = 14
dir(TranslationNotifierGenerator) = 0

After briefly reading the code of the above projects, I think we only need the copied resources for these projects:

  • ClientCore
  • DTAConfig
  • DXMainClient

.

pzhlkj6612 avatar Jan 26 '25 16:01 pzhlkj6612