我当前的应用程序如下所示:
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" [...]
根据用户是从命令提示符还是从开始菜单启动应用程序,UI 将如图所示显示。但是当用户从 cmd 启动应用程序时,不会显示 Console.WriteLine("foo") 的输出。
因此,我添加了desktop4:Subsystem="console".This 导致控制台窗口被启动,无论用户是从 startmneu 还是命令行启动应用程序。如何确保仅通过从命令提示符开始显示控制台窗口?我是否必须创建第二个 uwp 项目?
白衣染霜花
相关分类