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

Publishing a Maui Windows app SelfContained=false doesn't run #7170

Closed
eerhardt opened this issue Apr 11, 2022 · 9 comments
Closed

Publishing a Maui Windows app SelfContained=false doesn't run #7170

eerhardt opened this issue Apr 11, 2022 · 9 comments
Assignees
Labels
area-publishing Issues with the app packaging/publishing process (ipk/apk/msix/trimming) platform/windows 🪟 s/triaged Issue has been reviewed s/try-latest-version Please try to reproduce the potential issue on the latest public version t/bug Something isn't working
Milestone

Comments

@eerhardt
Copy link
Member

Describe the bug

When I try to package, install, and run a Maui Windows app with SelfContained=false, it doesn't run. It pops up a dialog:

image

The reason this happens is because this is generated into the runtimeconfig.json file:

{
  "runtimeOptions": {
    "tfm": "net6.0",
    "frameworks": [
      {
        "name": "Microsoft.NETCore.App",
        "version": "6.0.0"
      },
      {
        "name": "Microsoft.Maui.Core",
        "version": "**FromWorkload**"
      },
      {
        "name": "Microsoft.Maui.Controls",
        "version": "**FromWorkload**"
      },
      {
        "name": "Microsoft.Maui.Essentials",
        "version": "**FromWorkload**"
      }
    ],
    "configProperties": {
      "System.Reflection.Metadata.MetadataUpdater.IsSupported": false,
      "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
    }
  }
}

Notice the FromWorkload things for Microsoft.Maui.*. These things shouldn't be in the runtimeconfig.json file. Removing them allows the app to proceed.

To Reproduce

  1. Get Maui installed on your machine
  2. dotnet new maui
  3. Edit the .csproj to have:
		<WindowsPackageType>None</WindowsPackageType>
		<WinUISDKReferences>false</WinUISDKReferences>

		<SelfContained>false</SelfContained>
  1. dotnet build -c Release -f net6.0-windows10.0.19041.0
  2. Try to run the .exe in the bin\Release\net6.0-windows10.0.19041.0\win10-x64 folder.

Further technical details

❯ dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.300-preview.22207.16
 Commit:    1827808c3e

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19043
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\git\maui\bin\dotnet\sdk\6.0.300-preview.22207.16\

Host (useful for support):
  Version: 6.0.3
  Commit:  c24d9a9c91

.NET SDKs installed:
  6.0.300-preview.22207.16 [C:\git\maui\bin\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.3 [C:\git\maui\bin\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.3 [C:\git\maui\bin\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.3 [C:\git\maui\bin\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

cc @dsplaisted

@jfversluis
Copy link
Member

Also noticed this when trying out the ClickOnce publishing, this seems to be the only thing from stopping that to work.

@dsplaisted
Copy link
Member

I think what needs to happen is the Maui KnownFrameworkReference items should have RuntimePackAlwaysCopyLocal="true". This means that the SDK will copy the implementation from the runtime pack to the app even if the app is framework-dependent.

Additionally, I added a change to dotnet/sdk#25358 to support RuntimePackAlwaysCopyLocal runtime packs for RuntimeIdentifiers besides any. So we'll also need that change for this to work.

You'll also need to specify a RuntimeIdentifier when building the app, as there isn't a RuntimeIdentifier-agnostic version of the runtime pack available.

@jonathanpeppers @mattleibow @Redth

@dsplaisted dsplaisted removed their assignment May 12, 2022
@dsplaisted
Copy link
Member

Probably this should be transferred to the dotnet/maui repo, but it looks like I don't have permissions for that.

@jonathanpeppers jonathanpeppers transferred this issue from dotnet/sdk May 13, 2022
@jonathanpeppers
Copy link
Member

jonathanpeppers commented May 13, 2022

@dsplaisted I moved this, thanks.

Should %(RuntimePackAlwaysCopyLocal) be based on if $(SelfContained) is false and $(TargetPlatformIdentifier) is Windows? Or just set it no matter what?

@jonathanpeppers jonathanpeppers added this to the 6.0.300-servicing milestone May 13, 2022
@jonathanpeppers jonathanpeppers self-assigned this May 13, 2022
@jfversluis jfversluis added platform/windows 🪟 area-publishing Issues with the app packaging/publishing process (ipk/apk/msix/trimming) and removed Area-NetSDK labels May 16, 2022
@dsplaisted
Copy link
Member

It should be OK to set %(RuntimePackAlwaysCopyLocal) to true in all cases. It means that the contents of the runtime pack should be included in the app whether the app is self-contained or not.

@gerhard17
Copy link

gerhard17 commented Jun 23, 2022

I have the same problem, when using SelfContained (false). Compiling from Visual Studio 17.3.0 Preview 2.0 (windows)

@mattleibow
Copy link
Member

mattleibow commented Jun 24, 2022

@dsplaisted I tried setting this to true but then it fails for class libraries:

C:\Program Files\dotnet\sdk\6.0.400-preview.22301.10\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(430,5):
error NETSDK1082: There was no runtime pack for Microsoft.Maui.Core available for the specified RuntimeIdentifier 'any'.

It seems this ResolveRuntimePackAssets only runs on windows

msbuild (8).zip

@mattleibow mattleibow modified the milestones: 6.0-sr2, Backlog Aug 3, 2022
@mattleibow mattleibow removed their assignment Aug 3, 2022
@samhouts samhouts added the t/bug Something isn't working label Jul 31, 2023
@Zhanglirong-Winnie Zhanglirong-Winnie added s/triaged Issue has been reviewed s/try-latest-version Please try to reproduce the potential issue on the latest public version labels Aug 7, 2023
@ghost
Copy link

ghost commented Aug 7, 2023

Hi @eerhardt. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.

You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.

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.

@Zhanglirong-Winnie
Copy link

Verified this issue with Visual Studio Enterprise 17.7.0 Preview 5.0. Not repro on windows platform with cmd.
Screenshot 2023-08-07 142035

@ghost ghost closed this as completed Aug 14, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Sep 13, 2023
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-publishing Issues with the app packaging/publishing process (ipk/apk/msix/trimming) platform/windows 🪟 s/triaged Issue has been reviewed s/try-latest-version Please try to reproduce the potential issue on the latest public version t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants