dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.24k stars 1.76k forks source link

Fail to compile MAUI Blazor Android only in Release build when there is a file starting with dot (.) in wwwroot folder #22882

Open datvm opened 5 months ago

datvm commented 5 months ago

Description

When compile a MAUI Blazor project for Android in Release build, if there is a file like .init in wwwroot file, it fails with the following message:

PS C:\Users\lukev\source\repos\ConsoleApp1\MauiApp1> dotnet build -f:net8.0-android -c:Release
  Determining projects to restore...
  Restored C:\Users\lukev\source\repos\ConsoleApp1\MauiApp1\MauiApp1.csproj (in 1.28 sec).
  MauiApp1 -> C:\Users\lukev\source\repos\ConsoleApp1\MauiApp1\bin\Release\net8.0-android\MauiApp1.dll
C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.95\targets\Microsoft.Android.Sdk.ILLink.targets(34,11): error MSB4186: Invalid stat
ic method invocation syntax: "[System.String]::Copy().StartsWith ('Xamarin.AndroidX.')". Method 'System.String.Copy' not found. Static method invoca
tion should be of the form: $([FullTypeName]::Method()), e.g. $([System.IO.Path]::Combine(`a`, `b`)). Check that all parameters are defined, are of
the correct type, and are specified in the right order. [C:\Users\lukev\source\repos\ConsoleApp1\MauiApp1\MauiApp1.csproj::TargetFramework=net8.0-an
droid]
    0 Warning(s)
    4 Error(s)

Renaming/removing the file would make the error go away but sometimes it's not an option.

This is my workload because I am not sure which to pick from the list:

Installed Workload Id      Manifest Version       Installation Source
---------------------------------------------------------------------------------
android                    34.0.95/8.0.100        SDK 8.0.300, VS 17.10.34928.147
aspire                     8.0.1/8.0.100          SDK 8.0.300, VS 17.10.34928.147
ios                        17.2.8053/8.0.100      SDK 8.0.300, VS 17.10.34928.147
maccatalyst                17.2.8053/8.0.100      SDK 8.0.300, VS 17.10.34928.147
maui-windows               8.0.21/8.0.100         SDK 8.0.300, VS 17.10.34928.147
wasi-experimental          8.0.6/8.0.100          SDK 8.0.300

Steps to Reproduce

  1. Create a new project using .NET 8 MAUI Blazor Hybrid template.
  2. Create a new file (Ctrl Shift A in Visual Studio) in wwwroot folder and name it something like .init.
  3. Build the project in Release mode: dotnet build -f:net8.0-android -c:Release

Link to public reproduction project repository

No response

Version with bug

Unknown/Other

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

github-actions[bot] commented 5 months ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

RoiChen001 commented 5 months ago

Can repro this issue on the latest 17.11.0 Preview 1.1(8.0.21&8.0.40). 22882

drasticactions commented 5 months ago

@jonathanpeppers Would this be an issue with the Android SDK?

mkArtakMSFT commented 1 month ago

@samhouts I removed the area-blazor label intentionally. It's not a blazor issue 👍

Khongchai commented 1 month ago

This is happening to me too. I thought I misconfigured something.

This all of the sudden began happening to both my mac and windows machines when trying to build release for android. However this issue has been opened for a while. Did you manage to fix this somehow @datvm ?

datvm commented 1 month ago

@Khongchai unfortunately not. This is some issue with MAUI. For us, we had to change the code of the external library so that we can use another file name. I know this may not be helpful for everyone.

@mkArtakMSFT is it happening to MAUI in general? In that case I should rename the title to reflect it.

SequPL commented 1 month ago

Hi, same for me ( if files with the first character '.' exists in wwwroot then Release build crash. e.g. .gitignore, .prettier ).

Full message :

C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.138\targets\Microsoft.Android.Sdk.ILLink.targets(34,11): error MSB4186: Invalid static method invocation syntax: "[System.String]::Copy().StartsWith ('Xamarin.AndroidX.')". Method 'System.String.Copy' not found. Static method invocation should be of the form: $([FullTypeName]::Method()), e.g. $([System.IO.Path]::Combine(`a`, `b`)). Check that all parameters are defined, are of the correct type, and are specified in the right order.

After it was removed, compiled without problems.

Khongchai commented 1 month ago

Hi, same for me ( if files with the first character '.' exists in wwwroot then Release build crash. e.g. .gitignore, .prettier ).

Wow that really is what's failing my build. Thanks @SequPL

Btw I added this to my csproj instead of removing .prettierrc and .gitignore

 <ItemGroup>
      <Content Remove="wwwroot\.prettierrc" />
      <Content Remove="wwwroot\.gitignore" />
</ItemGroup>