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

Unable to run Windows application from command line #5975

Open
4 tasks
Tracked by #10564
eerhardt opened this issue Apr 11, 2022 · 17 comments
Open
4 tasks
Tracked by #10564

Unable to run Windows application from command line #5975

eerhardt opened this issue Apr 11, 2022 · 17 comments
Assignees
Labels
area-publishing Issues with the app packaging/publishing process (ipk/apk/msix/trimming) area-tooling XAML & C# Hot Reload, XAML Editor, Live Visual Tree, Live Preview, Debugging blocked Work that is currently blocked external platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working t/desktop The issue relates to desktop scenarios (MacOS/MacCatalyst/Windows/WinUI/WinAppSDK)
Milestone

Comments

@eerhardt
Copy link
Member

eerhardt commented Apr 11, 2022

Description

I am unable to launch my Maui Windows application from the command line. With Android I can with dotnet build -t:Run. But this doesn't work with Windows. Note that dotnet run -f net6.0-windows10.0.19041.0 also doesn't work.

cc @mattleibow

Steps to Reproduce

  1. dotnet new maui
  2. dotnet build -t:Run -f net6.0-windows10.0.19041.0

Results

C:\git\maui\bin\dotnet\sdk\6.0.300-preview.22207.16\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(901,5): er
ror MSB3073: The command "C:\DotNetTest\MauiTest\bin\Debug\net6.0-windows10.0.19041.0\win10-x64\MauiTest.exe " exited w
ith code -532462766. [C:\DotNetTest\MauiTest\MauiTest.csproj]

Version with bug

Unknown/Other (please specify)

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

All Windows

Did you find any workaround?

No response

Relevant log output

When attaching a Debugger to the process, I see:

System.DllNotFoundException
  HResult=0x80131524
  Message=Unable to load DLL 'Microsoft.ui.xaml.dll' or one of its dependencies: The specified module could not be found. (0x8007007E)
  Source=MauiTest
  StackTrace:
   at MauiTest.WinUI.Program.XamlCheckProcessRequirements()
   at MauiTest.WinUI.Program.Main(String[] args) in C:\DotNetTest\MauiTest\obj\Debug\net6.0-windows10.0.19041.0\win10-x64\Platforms\Windows\App.g.i.cs:line 28

Depends on

@eerhardt eerhardt added t/bug Something isn't working s/needs-verification Indicates that this issue needs initial verification before further triage will happen labels Apr 11, 2022
@eerhardt eerhardt changed the title Unable to run Windows application Unable to run Windows application from command line Apr 11, 2022
@Eilon Eilon added platform/windows 🪟 area-tooling XAML & C# Hot Reload, XAML Editor, Live Visual Tree, Live Preview, Debugging legacy-area-desktop Windows / WinUI / Project Reunion & Mac Catalyst / macOS specifics (Menus & other Controls)) labels Apr 11, 2022
@v-longmin
Copy link

Verified the issue on 17.2.0 Preview 2.1 [32317.152.main], it's repro.

@v-longmin v-longmin added s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage and removed s/needs-verification Indicates that this issue needs initial verification before further triage will happen labels Apr 12, 2022
@jsuarezruiz
Copy link
Contributor

Could be related with #5923? cc @mattleibow

@mattleibow
Copy link
Member

mattleibow commented Apr 12, 2022

Not sure... I don't know if there is a way to run WinUI apps from the CLI, either with msbuild or dotnet.

@mattleibow
Copy link
Member

Opened this discussion to be able to find out the way to do things: microsoft/WindowsAppSDK#2391

@mattleibow
Copy link
Member

Might even be related to this discussion: microsoft/WindowsAppSDK#55

Not sure if there is a way to launch MSIX apps via the CLI, but could be via unpackaged...

@Redth Redth added this to the 6.0.300 milestone Apr 20, 2022
@davidortinau davidortinau added the p/2 Work that is important, but is currently not scheduled for release label Apr 30, 2022
@Redth Redth added p/3 Work that is nice to have and removed p/2 Work that is important, but is currently not scheduled for release labels May 3, 2022
@samhouts samhouts modified the milestones: 6.0.300, 6.0.300-servicing May 4, 2022
@mattjohnsonpint
Copy link
Contributor

Same here. Been doing everything on a Mac so far, where dotnet build -t:Run -f net6.0-maccatalyst (or -ios, -android, etc.) works fine. Thought I'd try it out on Windows and ran into this issue. It only works if I do a full VS2022 preview install and run from within VS. Seems like it should work on the command line for consistent experience.

@geronimus
Copy link

Now that the .NET MAUI general availability release has happened, is there any timeline on resolving this issue?

Some Microsoft material released last year indicated that it was perfectly feasible to develop .NET MAUI apps using only VS Code. (Which means you must be able to do it using only vi too... which is my goal... crazy though that may seem!)

To me, this means that there may be a work-around for this issue that the Microsoft insiders have access to. Perhaps it could be posted here as a viable alternative. That is, until the non-VS experience on Windows works out-of-the-box.

@samhouts samhouts removed the p/3 Work that is nice to have label Jul 20, 2022
@Redth Redth modified the milestones: 6.0-servicing, Backlog Aug 30, 2022
@ghost
Copy link

ghost commented Aug 30, 2022

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@mattleibow
Copy link
Member

I also see that doing a dotnet build -t:Run -f net6.0-windows10.0.19041.0 on a fresh project does not restore or build. I had to add a separate dotnet build as well in order for it to do something.

However, I was able to get something to run with unpackaged:

dotnet build /restore -f net6.0-windows10.0.19041.0  /p:WindowsPackageType=None
dotnet build -t:Run -f net6.0-windows10.0.19041.0  /p:WindowsPackageType=None

But we still also need to get dotnet run working with anything:

The launch profile "(Default)" could not be applied.
A usable launch profile could not be located.

@mattleibow
Copy link
Member

Moving the issue here as well: microsoft/WindowsAppSDK#2922

@DrusTheAxe
Copy link

DrusTheAxe commented Sep 1, 2022

Not sure if there is a way to launch MSIX apps via the CLI, but could be via unpackaged...

Sure! There's a few

Activation via AUMID:

shell:appsfolder\...aumid... e.g. ShellExecute("shell:appsfolder\Microsoft.WindowsCalculator_8wekyb3d8bbwe!App") launches Calculator. Try it from the Win-R prompt.

Activation via Executable:

On Win11 if you run a packaged app's exe from its package directory Windows figures out it's a packaged app and runs it e.g. CreateProcess(GetPackagePath(p) + "\foo.exe") is equivalent to ActivateApplication(fooApplicationUserModelId). This is sometimes referred to as PackagedCreateProcess.

NOTE: This requires the executable be declared for only 1 app in the package e.g. you can declare multiple <Application> in appxmanifest.xml (technically, 0-100) but <Application Executable="foo.exe"...> must be unique. If 2 <Application>s declare the same Executable Windows can't launch the app by running its exe. As you might guess, when running the packaged exe Windows does a xref against apps in the package using the exe so 2+ would be ambiguous.

Alternatively on 20H1+, if the executable has a Fusion manifest declaring <msix...> then you can CreateProcess() the app's exe. CreateProcess sees the manifested identity, does a lookup against packages registered to the user to find the application's details and voila! This is equivalent to PackagedCreateProcess, though it requires <msix> (on the upside, it predates PackagedCreateProcess so available further downlevel). See https://docs.microsoft.com/en-us/windows/win32/sbscs/application-manifests#msix. NOTE: The docs talk about sparse MSIX packages; that's a scenario where this is useful, but <msix> is a mechanism, it doesn't care about WHY you use it - you can use <msix> whether or not you have a sparse package.

NOTE: Running an executable by typing it into a command line invokes CreateProcess (or ShellExecute, depending on the command prompt). These are options you can use to interactively launch MSIX packaged apps. Programmatically there's additional options.

@AvtsVivek
Copy link

I think the issue I raised here on SO is similar.

@Redth Redth added the area-publishing Issues with the app packaging/publishing process (ipk/apk/msix/trimming) label Jan 20, 2023
@mattleibow mattleibow added blocked Work that is currently blocked external labels Mar 15, 2023
@samhouts samhouts removed s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Apr 5, 2023
@homeyf homeyf added s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage labels Apr 20, 2023
@homeyf
Copy link

homeyf commented Apr 21, 2023

Verified this issue with Visual Studio 17.6.0 Preview 2.0. Repro on Windows application from command line.

@samhouts samhouts added the p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint label Oct 10, 2023
@tilkinsc
Copy link

Still an issue in 2024 btw

@samhouts
Copy link
Member

samhouts commented Apr 4, 2024

This is still blocked on microsoft/microsoft-ui-xaml#7331 and other related issues. Thank you for your patience!

@samhouts samhouts removed the p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint label Apr 23, 2024
@Eilon Eilon added t/desktop The issue relates to desktop scenarios (MacOS/MacCatalyst/Windows/WinUI/WinAppSDK) and removed legacy-area-desktop Windows / WinUI / Project Reunion & Mac Catalyst / macOS specifics (Menus & other Controls)) labels May 10, 2024
@ardalis
Copy link

ardalis commented Aug 29, 2024

Still an issue today.

@tilkinsc
Copy link

How do you actually build/run a maui app on windows then? I only use VSCode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-publishing Issues with the app packaging/publishing process (ipk/apk/msix/trimming) area-tooling XAML & C# Hot Reload, XAML Editor, Live Visual Tree, Live Preview, Debugging blocked Work that is currently blocked external platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working t/desktop The issue relates to desktop scenarios (MacOS/MacCatalyst/Windows/WinUI/WinAppSDK)
Projects
None yet
Development

No branches or pull requests