-
Notifications
You must be signed in to change notification settings - Fork 524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Xamarin.Android.Build.Tasks] ->Replace('.s', '.o') replaced not only at the end, but also in the middle of the path, and breaks if the containing directory contains .s #5043
Comments
Fixes: dotnet#5043 Instead of replacing `.s` with `.o` in the entire string, thus risking breaking the path to the file, replace just the extension.
Fixes: dotnet#5043 Instead of replacing `.s` with `.o` in the entire string, thus risking breaking the path to the file, replace just the extension. Co-authored by: @jonathanpeppers
Fixes: #5043 The `@(_TypeMapAssemblySource)` item group contains the `.s` files which should be compiled into `libxamarin-app.so`; see ce2bc68. The `_PrepareNativeAssemblyItems` target takes `@(_TypeMapAssemblySource)` to create the `@(_NativeAssemblyTarget)` item group, the set of `.o` files which should be linked into `libxamarin-app.so`. Unfortunately, `_PrepareNativeAssemblyItems` replaced *all* instances of `.s` to fill `@(_NativeAssemblyTarget)`: <_NativeAssemblyTarget Include="@(_TypeMapAssemblySource->Replace('.s', '.o'))"> This *looks* fine, until some part of the *full path name* of `@(_TypeMapAssemblySource)` *also* contains `.s`, e.g. if the username is `tobias.schulz`. This results in `@(_NativeAssemblyTarget)` instead containing `tobias.ochulz`, and a slew of related build errors: [i686-linux-android-ld.EXE stderr] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\ndk\i686-linux-android-ld.EXE: error: cannot open C:\[....]tobias.ochulz[....]\Debug\monoandroid10.0\android\typemaps.x86.o: No such file or directory Oops. *Properly* change the file extension by using `$([System.IO.Path]::ChangeExtension()` instead of `string.Replace()`: <_NativeAssemblyTarget Include="@(_TypeMapAssemblySource->'$([System.IO.Path]::ChangeExtension('%(Identity)', '.o'))')"> This ensures that correct path names are used.
Fixes: #5043 The `@(_TypeMapAssemblySource)` item group contains the `.s` files which should be compiled into `libxamarin-app.so`; see ce2bc68. The `_PrepareNativeAssemblyItems` target takes `@(_TypeMapAssemblySource)` to create the `@(_NativeAssemblyTarget)` item group, the set of `.o` files which should be linked into `libxamarin-app.so`. Unfortunately, `_PrepareNativeAssemblyItems` replaced *all* instances of `.s` to fill `@(_NativeAssemblyTarget)`: <_NativeAssemblyTarget Include="@(_TypeMapAssemblySource->Replace('.s', '.o'))"> This *looks* fine, until some part of the *full path name* of `@(_TypeMapAssemblySource)` *also* contains `.s`, e.g. if the username is `tobias.schulz`. This results in `@(_NativeAssemblyTarget)` instead containing `tobias.ochulz`, and a slew of related build errors: [i686-linux-android-ld.EXE stderr] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\ndk\i686-linux-android-ld.EXE: error: cannot open C:\[....]tobias.ochulz[....]\Debug\monoandroid10.0\android\typemaps.x86.o: No such file or directory Oops. *Properly* change the file extension by using `$([System.IO.Path]::ChangeExtension()` instead of `string.Replace()`: <_NativeAssemblyTarget Include="@(_TypeMapAssemblySource->'$([System.IO.Path]::ChangeExtension('%(Identity)', '.o'))')"> This ensures that correct path names are used.
Thanks for submitting this issue! Release status update A new Preview version of Xamarin.Android has now been published that includes the fix for this item. The fix is not yet included in a Release version. I will update this item again when a Release version is available that includes the fix. Fix included in Xamarin.Android SDK version 11.1.0.15. Fix included on Windows in Visual Studio 2019 version 16.8 Preview 4. To try the Preview version that includes the fix, check for the latest updates in Visual Studio Preview. Fix included on macOS in Visual Studio 2019 for Mac version 8.8 Preview 4. To try the Preview version that includes the fix, check for the latest updates on the Preview updater channel. |
Release status update A new Release version of Xamarin.Android has now been published that includes the fix for this item. Fix included in Xamarin.Android SDK version 11.1.0.17. Fix included on Windows in Visual Studio 2019 version 16.8. To get the new version that includes the fix, check for the latest updates or install the most recent release from https://visualstudio.microsoft.com/downloads/. Fix included on macOS in Visual Studio 2019 for Mac version 8.8. To get the new version that includes the fix, check for the latest updates on the Stable updater channel. |
Steps to Reproduce
My windows user name contains ".s"(tobias.schulz).
This causes this code to fail, because it replaces the directory that the files are in (C:\users\tobias.schulz....) to "C:\users\tobias**.o**chulz...."
Expected Behavior
The build shouild succeed (only the file endings should be replaced).
Actual Behavior
The build failed because of:
Version Information
Microsoft Visual Studio Community 2019
Version 16.7.2
VisualStudio.16.Release/16.7.2+30413.136
Microsoft .NET Framework
Version 4.8.04084
Installed Version: Community
Visual C++ 2019 00435-60000-00000-AA470
Microsoft Visual C++ 2019
ASP.NET and Web Tools 2019 16.7.532.28833
ASP.NET and Web Tools 2019
ASP.NET Core Razor Language Services 16.1.0.2035807+72d099b977d3a85e65fa3b0614ca8cfc803fef02
Provides languages services for ASP.NET Core Razor.
ASP.NET Web Frameworks and Tools 2019 16.7.532.28833
For additional information, visit https://www.asp.net/
Azure App Service Tools v3.0.0 16.7.532.28833
Azure App Service Tools v3.0.0
Azure Functions and Web Jobs Tools 16.7.532.28833
Azure Functions and Web Jobs Tools
C# Tools 3.7.0-6.20412.3+d3c3a44a4e7ad31cc75c59be0d3df4a19ff33878
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.
Extensibility Message Bus 1.2.6 (master@34d6af2)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.
IntelliCode Extension 1.0
IntelliCode Visual Studio Extension Detailed Info
Microsoft Azure Tools 2.9
Microsoft Azure Tools for Microsoft Visual Studio 2019 - v2.9.30701.1
Microsoft Continuous Delivery Tools for Visual Studio 0.4
Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE.
Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
Microsoft Library Manager 2.1.79+ge3567815aa.RR
Install client-side libraries easily to any web project
Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers
Microsoft Visual C++ Wizards 1.0
Microsoft Visual C++ Wizards
Microsoft Visual Studio Tools for Containers 1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.
Microsoft Visual Studio VC Package 1.0
Microsoft Visual Studio VC Package
Mono Debugging for Visual Studio 16.7.5 (112c7bc)
Support for debugging Mono processes with Visual Studio.
NuGet Package Manager 5.7.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/
ProjectServicesPackage Extension 1.0
ProjectServicesPackage Visual Studio Extension Detailed Info
SQL Server Data Tools 16.0.62008.03130
Microsoft SQL Server Data Tools
Syntax Visualizer 1.0
An extension for visualizing Roslyn SyntaxTrees.
TypeScript Tools 16.0.20702.2001
TypeScript Tools for Microsoft Visual Studio
Visual Basic Tools 3.7.0-6.20412.3+d3c3a44a4e7ad31cc75c59be0d3df4a19ff33878
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Visual C++ for Cross Platform Mobile Development (iOS) 16.0.30309.115
Visual C++ for Cross Platform Mobile Development (iOS)
Visual C++ for Linux Development 1.0.9.30329
Visual C++ for Linux Development
Visual F# Tools 10.10.0.0 for F# 4.7 16.7.0-beta.20361.3+3ef6f0b514198c0bfa6c2c09fefe41a740b024d5
Microsoft Visual F# Tools 10.10.0.0 for F# 4.7
Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio
Visual Studio Container Tools Extensions (Preview) 1.0
View, manage, and diagnose containers within Visual Studio.
Visual Studio Tools for CMake 1.0
Visual Studio Tools for CMake
Visual Studio Tools for Containers 1.0
Visual Studio Tools for Containers
VisualStudio.DeviceLog 1.0
Information about my package
VisualStudio.Mac 1.0
Mac Extension for Visual Studio
Xamarin 16.7.000.440 (d16-7@358f3c6)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.
Xamarin Designer 16.7.0.495 (remotes/origin/d16-7@79c0c522c)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.
Xamarin Templates 16.7.85 (1bcbbdf)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.
Xamarin.Android SDK 11.0.2.0 (d16-7/025fde9)
Xamarin.Android Reference Assemblies and MSBuild support.
Mono: 83105ba
Java.Interop: xamarin/java.interop/d16-7@1f3388a
ProGuard: Guardsquare/proguard@ebe9000
SQLite: xamarin/sqlite@1a3276b
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-7@017078f
Xamarin.iOS and Xamarin.Mac SDK 13.20.2.2 (817b6f72a)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
Log File
The text was updated successfully, but these errors were encountered: