Description
Issue Description
While creating a batch file for automated compilation of my project for all platforms, I encountered a problem during compilation for Android.
To compile for each platform, I used this function:
:build
rem %1 = project
rem %2 = platform
rem %3 = arch
if exist "publish\%2-%3.zip" (
echo "%2-%3 already exists."
pause >nul
exit /b 1
rem skip
)
echo Starting building %1 for %2-%3...
echo MSBuild:
echo dotnet build %1 -c Release --os %2 -a %3 -v m -o publish\%2-%3
echo.
dotnet build %1 -c Release --os %2 -a %3 -v m -o publish\%2-%3
Full source code
I called the functions like this:
call :build Eclair.Desktop win x64
call :build Eclair.Android android arm64
Usually, when compiling on Android, a file <project-name>.xml
is created in the output folder
In my case it was Eclair.Android
.
When compiling via Visual Studio 2022, everything is fine. But when compiling via a bat file, the following happened:
Let's imagine that we are compiling for Android and the x64 architecture.
In the publish
folder, a file is created with the name: android-x64Eclair.Android.xml
.
This looks very strange, but most likely it happens because of the missing \ between the paths.
Moreover, other files are created normally, in the android-x64
folder.
Important
I would also like to point out that this bug can be easily fixed by adding \ to the end.
It's not difficult, but in theory the path separator should not be at the end.
Steps to Reproduce
The source code of my project where you can repeat this bug is here.
Warning
The batch file is already fixed. So you will have to manually change the line number: 35
Expected Behavior
A file should be created in the output folder.
Example:
If we compile the SampleAndroidProject
project for the x64 architecture:
Then a file should be created at the path android-x64/SampleAndroidProject.xml
.
Actual Behavior
If we compile the SampleAndroidProject
project for the x64 architecture:
Then a file with a strange name will be created: android-x64SampleAndroidProject.xml
.
Because there is no separating path symbol between 4 and S.
Analysis
Most likely, MSBuild does not automatically add a path separator character between the platform and architecture of the project and the project name:
platform-arch/projectname.xml
Versions & Configurations
Key | Value |
---|---|
MSBuild Version | 17.12.7.52203 |
.NET CLI Version | 9.0.100 |
System | Windows 11 10.0.22621 |
Architecture | x64 |