Skip to content
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

CSWinRT compilation issues #18464

Open
mobynet1 opened this issue Oct 14, 2024 · 9 comments
Open

CSWinRT compilation issues #18464

mobynet1 opened this issue Oct 14, 2024 · 9 comments
Labels
difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification

Comments

@mobynet1
Copy link

mobynet1 commented Oct 14, 2024

Current behavior

Guys, I know you may be sick of me complaining about new solutions not working, but I am under such a severe time crunch at the moment, I am trying everything I can to get something to work.

I have been trying for the past week to get Maui control embedding to work. I was able to get it to work in at least two cases, it does not work consistently. I created yet again another new solution, and it does not compile when run on any platform other than the simple Windows platform. I get several issues when I just try to run the app as either a packaged or unpackaged Windows app. The errors are:

The project 'UnoApp1' ran into a problem during the last operation: The value of the 'TargetFrameworks' property is inconsistent between target frameworks. This property must be identical for NuGet restore to function correctly. The value 'net8.0-windows10.0.19041;net8.0-ios;net8.0-maccatalyst;net8.0-android;net8.0-browserwasm;net8.0-desktop;' from the 'Debug|AnyCPU|net8.0-desktop' configuration will be used, other target frameworks may fail to pick NuGet assets. You may need to reload the solution after fixing the problem.

I get this when changing from Desktop to WinAppSDK Packaged or WinAppSDK Unpackaged. This error confuses me as this is a brand new solution that I have made no edits to. Then, as I was saying, to run the app as a packaged app, for instance, gives me a list of the same errors:

Error (active)	CS0227	Unsafe code may only appear if compiling with /unsafe	UnoApp1 (net8.0-windows10.0.19041)	C:\Users\cimfr\source\repos\UnoApp1\UnoApp1\obj\Debug\net8.0-windows10.0.19041\WinRT.SourceGenerator\Generator.WinRTAotSourceGenerator\WinRTGenericInstantiation.g.cs	22

I just started to see this particular error starting this past Saturday, October 12, 2024. I search the the dev folders for WinRT and could not find the file it is complaining about: WinRTGenericInstantiation.g.cs, nor could I find any instance of the string WinRT anywhere in the solution. I have no idea what to do with this error.

When the app does start (as Desktop) the Maui controls are not displayed (which is the issue I have been bumping into for the past several days:

image

When I launch the app in Desktop mode, the output window also shows this error:

The specified framework 'Microsoft.WindowsDesktop.App' is not present in the previously loaded runtime.

I have placed this into a public GitHub repo: https://github.com/mobynet1/UnoApp1-NewWithErrors

Expected behavior

I just want everything to cooperate and do what they're supposed to do.

How to reproduce it (as minimally and precisely as possible)

No response

Workaround

na

Works on UWP/WinUI

None

Environment

No response

NuGet package version(s)

No response

Affected platforms

No response

IDE

Visual Studio 2022, Visual Studio Code, Rider Windows

IDE version

VS Code 1.94.2; Visual Studio 2022 Version 17.11.5; Rider 2024.2.6

Relevant plugins

No response

Anything else we need to know?

As I have indicated, I am being blocked at every turn by extremely low quality Microsoft components. gRPC failed. Visual Studio 2022 failed. And now, this. I need to get this done as there is a potential investor who is withholding any sort of funding until I can get a viable alpha demo going and I simply cannot get it done with the tools I have. I need Maui embedding in Uno to work!!

@mobynet1 mobynet1 added difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification labels Oct 14, 2024
@ArchieCoder
Copy link
Contributor

I discovered the same thing on Saturday trying to help a user.

I retried tonight with selecting only Skia, MVVM, Fluent and I have these unsafe errors as well.

image

cc @jeromelaban the compilation master

@DavidM29
Copy link

I encountered this issue as well, fixed it by rollbacking to visual studio version 17.11.4

@MartinZikmund
Copy link
Member

MartinZikmund commented Oct 15, 2024

I can confirm I also encountered the /unsafe errors after update from 5.4.8 to 5.4.10, I saw these errors in CI. Not sure how to fix this yet though

@jeromelaban
Copy link
Member

This is a breaking change that the WinUI team included that causes all sorts of trouble (tracked in microsoft/CsWinRT#1809). You can either set <AllowUnsafeBlocks>true</AllowUnsafeBlocks> or disable the AOT optimizations with <CsWinRTAotOptimizerEnabled>false</CsWinRTAotOptimizerEnabled>.

We'll include some of it in our templates to avoid this kind of friction.

@jeromelaban jeromelaban changed the title New solution will not compile CSWinRT compilation issues Oct 15, 2024
@jeromelaban
Copy link
Member

Also related to dotnet/sdk#43680 (comment)

@mobynet1
Copy link
Author

@jeromelaban This makes perfect sense. I have logged 3 new issues on the VS team. The quality of VS2022 is spiraling into the depths of Hades with every passing day. They keep bragging about all the "new" features while ignoring the litany of old bugs in their backlog.

Now, would the disabling of CsWinRTAotOptimizerEnabled property be detrimental to any sort of necessary optimatization? I think that with @DavidM29 's observation that the latest update of VS caused this, would it not be more prudent to simply revert to the previous VS version? I update VS often in hopes that the issues I have raised with the VS team have been fixed.... With that said, one of my most recent issues I logged with the VS team was moved to the Maui team (which I still think is wrong - it should be in the WinUI team's queue,,). My guess these issues lie with the WinUI team. I'm sure you have seen the issue where the xaml page and it's code-behind get decoupled and the red squiggly lines and filling the output window with messages like: CS0103 The name 'xxx' does not exist in the current context. The fact there are at least 3 different implementations of xaml could obviously be the root of these issues as well.

@mobynet1
Copy link
Author

@jeromelaban Also, I cannot remember if I mentioned this issue that places an error banner across the top of VS: The project 'UnoApp' ran into a problem during the last operation: The value of the 'TargetFrameworks' property is inconsistent between target frameworks. This property must be identical for NuGet restore to function correctly. The value 'net8.0-windows10.0.19041;net8.0-ios;net8.0-maccatalyst;net8.0-android;net8.0-browserwasm;net8.0-desktop;' from the 'Debug|AnyCPU|net8.0-desktop' configuration will be used, other target frameworks may fail to pick NuGet assets. You may need to reload the solution after fixing the problem. What can be done about this? Should I open a new issue on this?

@jeromelaban
Copy link
Member

jeromelaban commented Oct 15, 2024

@jeromelaban Also, I cannot remember if I mentioned this issue that places an error banner across the top of VS: The project 'UnoApp' ran into a problem during the last operation: The value of the 'TargetFrameworks' property is inconsistent between target frameworks. This property must be identical for NuGet restore to function correctly. The value 'net8.0-windows10.0.19041;net8.0-ios;net8.0-maccatalyst;net8.0-android;net8.0-browserwasm;net8.0-desktop;' from the 'Debug|AnyCPU|net8.0-desktop' configuration will be used, other target frameworks may fail to pick NuGet assets. You may need to reload the solution after fixing the problem. What can be done about this? Should I open a new issue on this?

This is a separate issue, but most likely related to the other. It's a VS issue we're constantly chasing with every new version. It should be transitive, though. Are you able to constantly repro?

@sasakrsmanovic
Copy link
Contributor

@jeromelaban This makes perfect sense. I have logged 3 new issues on the VS team. The quality of VS2022 is spiraling into the depths of Hades with every passing day. They keep bragging about all the "new" features while ignoring the litany of old bugs in their backlog.

Now, would the disabling of CsWinRTAotOptimizerEnabled property be detrimental to any sort of necessary optimatization? I think that with @DavidM29 's observation that the latest update of VS caused this, would it not be more prudent to simply revert to the previous VS version? I update VS often in hopes that the issues I have raised with the VS team have been fixed.... With that said, one of my most recent issues I logged with the VS team was moved to the Maui team (which I still think is wrong - it should be in the WinUI team's queue,,). My guess these issues lie with the WinUI team. I'm sure you have seen the issue where the xaml page and it's code-behind get decoupled and the red squiggly lines and filling the output window with messages like: CS0103 The name 'xxx' does not exist in the current context. The fact there are at least 3 different implementations of xaml could obviously be the root of these issues as well.

Hi @mobynet1 . Could you please share the VS issue links you've created. Sometimes we are able to escalate certain issues, not to mention that sharing them on our discord and asking for upvotes helps rally our community to bubble up issues to VS Team? https://platform.uno/discord .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification
Projects
None yet
Development

No branches or pull requests

6 participants