dotnet/maui

.NET MAUI Class Library build in the Release config fails to compile for the Windows target whereas Debug config works fine

egvijayanand opened this issue · 3 comments

Description

After upgrading to .NET MAUI on .NET 7 SR1.1 (v7.0.52), .NET MAUI Class Library build in the Release config fails to compile for the Windows target whereas Debug config works fine.

Note: Have tried to build the direct WinUI class library project in the Release config, which compiles without causing any error.

Kindly include the latest release versions in the Version with bug and Last version that worked well dropdowns.

Version with bug: .NET 7 SR1.1 (v7.0.52)

Last version that worked well: .NET 7 GA (v7.0.49)

Steps to Reproduce

  1. Create a new .NET MAUI Class Library project from the default template
  2. Build the project in the Release config
dotnet new mauilib -o TestLib
dotnet build -c Release

Link to public reproduction project repository

Default template itself is suffice, no authored code

Version with bug

Unknown/Other (please specify)

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

Windows SDK 10.0.19041

Did you find any workaround?

Nope.

Relevant log output

C:\Program Files\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(299,5): error NETSDK1094: Unable to optimize assemblies for performance: a valid runtime package was not found. Either set the PublishReadyToRun property to false, or use a supported runtime identifier when publishing. When targeting .NET 6 or higher, make sure to restore packages with the PublishReadyToRun property set to true. [E:\SampleLib\SampleLib.csproj::TargetFramework=net7.0-windows10.0.19041.0]

Until PR #12114 gets out, you can stick this in the class library csproj:

<PublishReadyToRun>false</PublishReadyToRun>

An alternative is to just always set PublishReadyToRun=False on the command line, but this will cause a slowdown in startup as described here: #9357

Hi @egvijayanand. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. 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.

Yes, setting the PublishReadyToRun project property to false does resolve the build issue for time being.

dotnet build -c Release -p:PublishReadyToRun=false