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

Updated to WinAppSdk 1.6, fixed AoT annotations #561

Merged
merged 22 commits into from
Aug 23, 2024
Merged

Updated to WinAppSdk 1.6, fixed AoT annotations #561

merged 22 commits into from
Aug 23, 2024

Conversation

Arlodotexe
Copy link
Member

@Arlodotexe
Copy link
Member Author

I'm seeing these errors in the MarqueeText and MarkdownTextBlock components, in places where TextDecorations is used:

"V:\Labs-Windows\tooling\ProjectHeads\AllComponents\wasdk\CommunityToolkit.App.Wasdk.csproj" (Clean;Build target) (1:7) ->
"V:\Labs-Windows\components\MarkdownTextBlock\src\CommunityToolkit.WinUI.Controls.MarkdownTextBlock.csproj" (default target) (12:31) ->(XamlPreCompile target) ->
V:\Labs-Windows\components\MarkdownTextBlock\src\TextElements\MyEmphasisInline.cs(67,33): error CS0433: The type 'TextDecorations' exists in both 'Microsoft.WinUI, Version=3.0.0.0, Culture=neutral, PublicKeyToken=de31ebe4ad15742b' and 'Microsoft.Windows.UI.Xaml, Version=10.0.22621.35, Culture=neutral, PublicKeyToken=31bf3856ad364e35' [V:\Labs-Windows\components\MarkdownTextBlock\src\CommunityToolkit.WinUI.Controls.MarkdownTextBlock.csproj::TargetFramework=net8.0-windows10.0.22621.0]

"V:\Labs-Windows\tooling\ProjectHeads\AllComponents\wasdk\CommunityToolkit.App.Wasdk.csproj" (Clean;Build target) (1:7) ->
"V:\Labs-Windows\components\MarqueeText\src\CommunityToolkit.Labs.WinUI.MarqueeText.csproj" (default target) (6:31) ->
V:\Labs-Windows\components\MarqueeText\src\MarqueeText.Properties.cs(102,12): error CS0433: The type 'TextDecorations' exists in both 'Microsoft.WinUI, Version=3.0.0.0, Culture=neutral, PublicKeyToken=de31ebe4ad15742b' and 'Microsoft.Windows.UI.Xaml, Version=10.0.22621.35, Culture=neutral, PublicKeyToken=31bf3856ad364e35' [V:\Labs-Windows\components\MarqueeText\src\CommunityToolkit.Labs.WinUI.MarqueeText.csproj::TargetFramework=net8.0-windows10.0.22621.0]

If you try to fix the issue using Microsoft.Windows.UI.Xaml.TextDecorations, you get CS0234 "type or namespace does not exist in namespace":

"V:\Labs-Windows\tooling\ProjectHeads\AllComponents\wasdk\CommunityToolkit.App.Wasdk.csproj" (Clean;Build target) (1:7) ->
"V:\Labs-Windows\components\MarkdownTextBlock\src\CommunityToolkit.WinUI.Controls.MarkdownTextBlock.csproj" (default target) (9:31) -> (XamlPreCompile target) ->
V:\Labs-Windows\components\MarkdownTextBlock\src\TextElements\MyEmphasisInline.cs(67,33): error CS0234: The type or namespace name 'UI' does not exist in the namespace 'Microsoft.Windows' (are you missing an assembly reference?) [V:\Labs-Windows\components\MarkdownTextBlock\src\CommunityToolkit.WinUI.Controls.MarkdownTextBlock.csproj::TargetFramework=net8.0-windows10.0.22621.0]

"V:\Labs-Windows\tooling\ProjectHeads\AllComponents\wasdk\CommunityToolkit.App.Wasdk.csproj" (Clean;Build target) (1:7) ->
"V:\Labs-Windows\components\MarqueeText\src\CommunityToolkit.Labs.WinUI.MarqueeText.csproj" (default target) (17:31) ->
V:\Labs-Windows\components\MarqueeText\src\MarqueeText.Properties.cs(102,30): error CS0234: The type or namespace name 'UI' does not exist in the namespace 'Microsoft.Windows' (are you missing an assembly reference?) [V:\Labs-Windows\components\MarqueeText\src\CommunityToolkit.Labs.WinUI.MarqueeText.csproj::TargetFramework=net8.0-windows10.0.22621.0]

If you try to fix the issue with the other suggestion, Microsoft.WinUI.TextDecorations, you get the same CS0234 "type or namespace does not exist in namespace":

"V:\Labs-Windows\tooling\ProjectHeads\AllComponents\wasdk\CommunityToolkit.App.Wasdk.csproj" (Clean;Build target) (1:7) ->
"V:\Labs-Windows\components\MarkdownTextBlock\src\CommunityToolkit.WinUI.Controls.MarkdownTextBlock.csproj" (default target) (2:31) -> (XamlPreCompile target) ->
V:\Labs-Windows\components\MarkdownTextBlock\src\TextElements\MyEmphasisInline.cs(67,33): error CS0234: The type or namespace name 'WinUI' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [V:\Labs-Windows\components\MarkdownTextBlock\src\CommunityToolkit.WinUI.Controls.MarkdownTextBlock.csproj::TargetFramework=net8.0-windows10.0.22621.0]

"V:\Labs-Windows\tooling\ProjectHeads\AllComponents\wasdk\CommunityToolkit.App.Wasdk.csproj" (Clean;Build target) (1:7) ->
 "V:\Labs-Windows\components\MarqueeText\src\CommunityToolkit.Labs.WinUI.MarqueeText.csproj" (default target) (15:31) ->
V:\Labs-Windows\components\MarqueeText\src\MarqueeText.Properties.cs(102,22): error CS0234: The type or namespace name 'WinUI' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [V:\Labs-Windows\components\MarqueeText\src\CommunityToolkit.Labs.WinUI.MarqueeText.csproj::TargetFramework=net8.0-windows10.0.22621.0]

Similar errors if you try to use the type Windows.UI.Text.TextDecorations.

Anybody know what's happening here? Why is it telling me that these types exist, but erroring when I try to use them?

@Sergio0694
Copy link
Member

Ah, yeah this is expected. FYI @manodasanW. @Arlodotexe you'll need to wait for the new SDK projections and WASDK preview.

@manodasanW
Copy link

If this is just WinAppSDK, you can do the below workaround until we have builds with the right fixes.

    <!-- Temporary workaround -->
    <Target Name="CsWinRTRemoveXamlDllReferences" AfterTargets="ResolveTargetingPackAssets;ResolveReferences" BeforeTargets="XamlPreCompile;CoreCompile" Outputs="@(Reference)">
        <ItemGroup>
            <Reference Remove="@(Reference)"
               Condition="'%(Reference.Filename)%(Reference.Extension)' == 'Microsoft.Windows.UI.Xaml.dll'" />
            <ReferencePathWithRefAssemblies Remove="@(ReferencePathWithRefAssemblies)"
               Condition="'%(ReferencePathWithRefAssemblies.Filename)%(ReferencePathWithRefAssemblies.Extension)' == 'Microsoft.Windows.UI.Xaml.dll'" />
            <ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)"
               Condition="'%(ReferenceCopyLocalPaths.Filename)%(ReferenceCopyLocalPaths.Extension)' == 'Microsoft.Windows.UI.Xaml.dll'" />
            <ReferencePath Remove="@(ReferencePath)"
               Condition="'%(ReferencePath.Filename)%(ReferencePath.Extension)' == 'Microsoft.Windows.UI.Xaml.dll'" />
        </ItemGroup>
    </Target>

@manodasanW
Copy link

If this is just WinAppSDK, you can do the below workaround until we have builds with the right fixes.

    <!-- Temporary workaround -->
    <Target Name="CsWinRTRemoveXamlDllReferences" AfterTargets="ResolveTargetingPackAssets;ResolveReferences" BeforeTargets="XamlPreCompile;CoreCompile" Outputs="@(Reference)">
        <ItemGroup>
            <Reference Remove="@(Reference)"
               Condition="'%(Reference.Filename)%(Reference.Extension)' == 'Microsoft.Windows.UI.Xaml.dll'" />
            <ReferencePathWithRefAssemblies Remove="@(ReferencePathWithRefAssemblies)"
               Condition="'%(ReferencePathWithRefAssemblies.Filename)%(ReferencePathWithRefAssemblies.Extension)' == 'Microsoft.Windows.UI.Xaml.dll'" />
            <ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)"
               Condition="'%(ReferenceCopyLocalPaths.Filename)%(ReferenceCopyLocalPaths.Extension)' == 'Microsoft.Windows.UI.Xaml.dll'" />
            <ReferencePath Remove="@(ReferencePath)"
               Condition="'%(ReferencePath.Filename)%(ReferencePath.Extension)' == 'Microsoft.Windows.UI.Xaml.dll'" />
        </ItemGroup>
    </Target>

Can you also add the below to the target and see if it helps.

            <RuntimePackAsset Remove="@(RuntimePackAsset)"
               Condition="'%(RuntimePackAsset.Filename)%(RuntimePackAsset.Extension)' == 'Microsoft.Windows.UI.Xaml.dll'" />

Arlodotexe added a commit to CommunityToolkit/Tooling-Windows-Submodule that referenced this pull request Aug 9, 2024
@Arlodotexe
Copy link
Member Author

Not getting any errors when building locally, but CI is throwing:

error MSB3030: Could not copy the file "C:\Users\runneradmin\.nuget\packages\microsoft.web.webview2\1.0.2646-prerelease\build\..\\runtimes\win-anycpu\native_uap\Microsoft.Web.WebView2.Core.dll" because it was not found. [D:\a\Labs-Windows\Labs-Windows\components\TransitionHelper\src\CommunityToolkit.Labs.WinUI.TransitionHelper.csproj::TargetFramework=net6.0-windows10.0.22621.0]

Directory.Build.props Outdated Show resolved Hide resolved
@Sergio0694
Copy link
Member

@Arlodotexe just as a test, try updating WebView2 to 1.0.2730-prerelease that was released today and see if it helps.

@Arlodotexe
Copy link
Member Author

@Arlodotexe just as a test, try updating WebView2 to 1.0.2730-prerelease that was released today and see if it helps.

Our reference to WebView2 is transient and doesn't seem to be coming from Microsoft.WindowsAppSDK. It's happening on the wasdk multitarget for each component source project, even ones with no dependencies like Converters and Extensions. Where is this coming from 🤔

@Arlodotexe
Copy link
Member Author

I see, the way WebView2 is bundled with the WindowsAppSDK changed as of Preview1, now using a nuget package. The dependency shows on nuget.org when you select 1.6.240807006-preview1 or greater.

@Arlodotexe
Copy link
Member Author

Looks like that resolved our issue with WebView 2.

Seeing an issue from before resurface, reproduces locally and in CI:

Error: D:\a\Labs-Windows\Labs-Windows\components\MarkdownTextBlock\src\TextElements\MyEmphasisInline.cs(72,33): error CS0433: The type 'TextDecorations' exists in both 'Microsoft.WinUI, Version=3.0.0.0...' and 'Microsoft.Windows.SDK.NET, Version=10.0.22621.38...

@manodasanW
Copy link

Looks like that resolved our issue with WebView 2.

Seeing an issue from before resurface, reproduces locally and in CI:

Error: D:\a\Labs-Windows\Labs-Windows\components\MarkdownTextBlock\src\TextElements\MyEmphasisInline.cs(72,33): error CS0433: The type 'TextDecorations' exists in both 'Microsoft.WinUI, Version=3.0.0.0...' and 'Microsoft.Windows.SDK.NET, Version=10.0.22621.38...

See my comment here: CommunityToolkit/Tooling-Windows-Submodule#195 (comment)

@Arlodotexe
Copy link
Member Author

Arlodotexe commented Aug 22, 2024

This warning on wasm-linux might be something to fix in a future PR:

Found version-specific or distribution-specific runtime identifier(s): win10-ARM, win10-ARM64, win10-x64, win10-x86. Affected libraries: Rive.RiveSharp. In .NET 8.0 and higher, assets for version-specific and distribution-specific runtime identifiers will not be found by default. See https://aka.ms/dotnet/rid-usage for details.

@Arlodotexe
Copy link
Member Author

Arlodotexe commented Aug 22, 2024

Seems like tests are failing as a result of some issue with RivePlayer.

System.TypeInitializationException: The type initializer for 'RiveSharp.Factory' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'rive' or one of its dependencies: The specified module could not be found. (0x8007007E)
  Stack Trace:
      at RiveSharp.RiveAPI.Factory_RegisterDelegates(FactoryDelegates delegates)
   at RiveSharp.Factory..cctor()
--- End of inner exception stack trace ---
    at RiveSharp.Scene..ctor()
   at CommunityToolkit.Labs.WinUI.Rive.RivePlayer..ctor() in /_/components/RivePlayer/src/RivePlayer.cs:line 49
   at RivePlayerExperiment.Tests.ExampleRivePlayerTestClass.ComplexAsyncLoadUIExampleWithoutDispatcherTest() in D:\a\Labs-Windows\Labs-Windows\components\RivePlayer\tests\ExampleRivePlayerTestClass.cs:line 121
   at RivePlayerExperiment.Tests.ExampleRivePlayerTestClass.<ComplexAsyncLoadUIExampleWithoutDispatcherTest_ExampleRivePlayerTestClass_Test>b__12_0() in /_/ProjectHeads/AllComponents/Tests.Wasdk/obj/x64/Release/net8.0-windows10.0.22621.0/win-x64/CommunityToolkit.Tooling.TestGen/CommunityToolkit.Tooling.TestGen.UIThreadTestMethodGenerator/ComplexAsyncLoadUIExampleWithoutDispatcherTest_ExampleRivePlayerTestClass.g.cs:line 15

Copy link
Member

@Sergio0694 Sergio0694 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, minus those leftover ifdefs with the same code.

Arlodotexe added a commit to CommunityToolkit/Tooling-Windows-Submodule that referenced this pull request Aug 23, 2024
@Arlodotexe Arlodotexe merged commit 0d89e01 into main Aug 23, 2024
20 of 21 checks passed
@Arlodotexe Arlodotexe deleted the wasdk/1.6 branch August 23, 2024 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants