Copy built-in resources to "OutputPath" only when needed
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.
Nightly build for this pull request:
- artifacts-YR.zip
- artifacts-Ares.zip
- artifacts-TS.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.
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
.