unoplatform / uno

Open-source platform for building cross-platform native Mobile, Web, Desktop and Embedded apps quickly. Create rich, C#/XAML, single-codebase apps from any IDE. Hot Reload included! 90m+ NuGet Downloads!!
https://platform.uno
Apache License 2.0
9.04k stars 734 forks source link

Empty template fails on windows #15743

Open Vespion opened 8 months ago

Vespion commented 8 months ago

Current behavior

When creating a project via the template wizard, the generated AppHead.xaml fails to load AppResources.xaml on Windows and crashes with a XamlParseException.

This seems to be a Windows issue, as running the project on Android is successful (or at least, it starts up without crashing).

Expected behavior

The template should be able to run on all platforms if the user has not changed it.

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

Cannot locate resource from 'ms-appx:///WinTest/AppResources.xaml'. [Line: 12 Position: 29]


[Zipped project](https://github.com/unoplatform/uno/files/14489930/repo.zip)
[Github Repo](https://github.com/Vespion/WinTest)

### Workaround

Removing `ms-appx:///WinTest/AppResources.xaml` from `AppHead.xaml` allows the app to start up, but it also causes the AppResources to not be loaded so it's not a "real" workaround

### Works on UWP/WinUI

No

### Environment

Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia

### NuGet package version(s)

| Package                          | Version         |
|----------------------------------|-----------------|
| Microsoft.Windows.SDK.BuildTools | 10.0.22621.2428 |
| Microsoft.WindowsAppSDK          | 1.4.240211001   |
| Uno.WinUI                        | 5.1.50          |
| Uno.WinUI.DevServer              | 5.1.50          |
| Uno.Sdk                          | 5.1.50          |

### Affected platforms

Windows

### IDE

Rider Windows

### IDE version

2023.3.3

### Relevant plugins

| Plugin                          | Version         |
|----------------------------------|-----------------|
| Rider Xamarin Android Support | 233.14015.60 |

### Anything else we need to know?

_No response_
jeromelaban commented 8 months ago

@Vespion thanks for the report. We fixed this in later versions of Uno. Can you upgrade to the latest version and let us know?

Vespion commented 8 months ago

I've updated all the packages, now I'm seeing an error during build

CONSOLE: Use build tool: C:\Program Files\dotnet\sdk\8.0.201\MSBuild.dll 18:10:35 Building I:\Programming\WinTest\WinTest.Windows\WinTest.Windows.csproj 18:10:35 Building I:\Programming\WinTest\WinTest\WinTest.csproj ... Applying NuGet packaging workaround for dependent PRI files exclusion 0>MrtCore.PriGen.targets(913,5): Error MSB4062 : The "Microsoft.Build.Packaging.Pri.Tasks.ExpandPriContent" task could not be loaded from the assembly C:\Program Files\dotnet\sdk\8.0.201\Microsoft\VisualStudio\v17.0\AppxPackage\\Microsoft.Build.Packaging.Pri.Tasks.dll. Could not load file or assembly 'C:\Program Files\dotnet\sdk\8.0.201\Microsoft\VisualStudio\v17.0\AppxPackage\Microsoft.Build.Packaging.Pri.Tasks.dll'. The system cannot find the path specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.

I think this might be similar #12013? However, I'm not sure how you're supposed to run the project through the IDE in that case.

jeromelaban commented 8 months ago

Thanks for the update. This is indeed the same error, but this should not be a problem using Visual Studio. How do you get to this ? Do you use F5 to get this error?

Vespion commented 8 months ago

No, I've been using the Unpackaged Application run configuration in Rider.

VS does work when using F5. I assumed this might be because VS calls MSBuild, not the dotnet CLI, but after checking, I noticed that Rider calls MSBuild directly, too.

lindexi commented 6 months ago

No, I've been using the Unpackaged Application run configuration in Rider.

VS does work when using F5. I assumed this might be because VS calls MSBuild, not the dotnet CLI, but after checking, I noticed that Rider calls MSBuild directly, too.

I find the Rider's bug. Rider will use .NET Framework debugger to debug the application when I select the msbuild to build the project.