dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.13k stars 4.04k forks source link

[Bug] Space in Common Class Project triggers some issue while MAUI Class Library is refer on it #72078

Open AlexDialga opened 1 year ago

AlexDialga commented 1 year ago

Description

Issue Description:

I encountered an issue in .NET MAUI related to project references when creating a new class library with spaces in its name. The issue seems to cause a build failure with the CS0006 error, indicating that the metadata file could not be found.

Steps to Reproduce:

  1. Create a new class library project in Visual Studio.
  2. Include spaces in the project name during creation.
  3. Reference this class library project from a .NET MAUI project.
  4. Attempt to build the solution.

Expected Behavior:

The .NET MAUI project should be able to reference and build successfully, even if the class library project has spaces in its name.

Actual Behavior:

The build fails with a CS0006 error, stating that the metadata file could not be found.

Environment:

image Class Library with space will trigger some errors.

image Class Library without space.

Most of the content in this Report was generated by AI

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

8.0.3

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

I was not able test on other platforms

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

ghost commented 1 year ago

Hi @AlexDialga. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

drasticactions commented 1 year ago

I tried to reproduce this (https://github.com/drasticactions/MauiRepros/tree/main/TestApp) but it compiles and deploys fine for me. Could you create a repro project that can show this error? Maybe my setup is different than what you tried.

AlexDialga commented 1 year ago

I tried to reproduce this (https://github.com/drasticactions/MauiRepros/tree/main/TestApp) but it compiles and deploys fine for me. Could you create a repro project that can show this error? Maybe my setup is different than what you tried.

Here is a sample for testing the issue: https://github.com/AlexDialga/TestSpaceIssueForMAUI If you try to build "MAUI Common Classes" with "Common Classes", the issue will be appeared. Another problem is that any reference from solution will not appear in "References": ezgif com-video-to-gif

jeffschwMSFT commented 1 year ago

@marcpopMSFT and @ManishJayaswal thoughts on where this issue should be transferred too? It seems like tooling

marcpopMSFT commented 1 year ago

Is it only failing when referenced from a MAUI Class Library? Given it's a CS error, I'd probably start with dotnet/roslyn. CC @jaredpar who has opinions.

CyrusNajmabadi commented 1 week ago

@jasonmalinowski ptal and redirect as appropriate.

jasonmalinowski commented 1 week ago

I don't imagine this is Roslyn's fault; I'm unable to build the test project though so it's hard to know what's up. I'm getting errors like:

 Assets file 'C:\Users\WDAGUtilityAccount\Downloads\TestSpaceIssueForMAUI-master\TestSpaceIssueForMAUI-master\Common Classes\obj\project.assets.json' doesn't have a target for 'net8.0-windows10.0.19041'. Ensure that restore has run and that you have included 'net8.0-windows10.0.19041' in the TargetFrameworks for your project.

That is of course what's in the project file, and if I look in the project.assets.json I see that file too. So seems like something more fundamental is busted. @marcpopMSFT any idea?

marcpopMSFT commented 6 days ago

@jasonmalinowski if you see errors about the assets file, it typically means that the restore config was different than the build config (ie different TFM or different RID). I didn't look closely at the test project the first time around but I guess I'd assume it's because the Maui common classes csproj has the windows TFM but the other two do not. Not sure how the customer doesn't hit this but you do. @nkolev92 @dsplaisted.

jasonmalinowski commented 6 days ago

@marcpopMSFT Ah, you pointed out something I misread -- the project.assets.json in this case was the library app, not the MAUI app.