我當前的應用程序如下所示:public static class Program{ //Default code-gen unless we include DISABLE_XAML_GENERATED_MAIN in the build properties. static void Main(string[] args) { IActivatedEventArgs activatedArgs = AppInstance.GetActivatedEventArgs(); if(ActivationKind.CommandLineLaunch.Equals(activatedArgs?.Kind)) { CommandLineActivatedEventArgs cmdLineArgs = activatedArgs as CommandLineActivatedEventArgs; CommandLineActivationOperation operation = cmdLineArgs.Operation; string activationPath = operation.CurrentDirectoryPath; System.Console.WriteLine("foo"); } else { global::Windows.UI.Xaml.Application.Start((p) => new App()); } }}我的清單: <Application Id="App" Executable="$targetnametoken$.exe" desktop4:SupportsMultipleInstances="true"> <uap5:Extension Category="windows.appExecutionAlias" [...]根據(jù)用戶是從命令提示符還是從開始菜單啟動應用程序,UI 將如圖所示顯示。但是當用戶從 cmd 啟動應用程序時,不會顯示 Console.WriteLine("foo") 的輸出。因此,我添加了desktop4:Subsystem="console".This 導致控制臺窗口被啟動,無論用戶是從 startmneu 還是命令行啟動應用程序。如何確保僅通過從命令提示符開始顯示控制臺窗口?我是否必須創(chuàng)建第二個 uwp 項目?
如何同時支持 UWP 命令行和 UWP UI?
慕碼人8056858
2021-07-09 18:15:52