Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to output to console in UWP on Windows 10?

Is there a way to write to console / command prompt / powershell (like Console.WriteLine()) or anything similar in UWP apps?

If console is unavailable is there a proper alternative that I can use instead to write to the screen large amounts of text?

I, of course, can make a XAML control and output to it, but it doesn't seem to be convenient in comparison to simple Console.WriteLine().

There is also very old discussion on WPF console, but nothing seems to work from there (at least, I couldn't find Project-Properties-Application tab-Output Type-Console Application and Trace.WriteLine("text") is unavailable).

like image 249
Bad Avatar asked Oct 03 '15 10:10

Bad


People also ask

How do I display console output?

Press CTRL + F5 to see your output. This will wait the console screen until you press any key.

How do I add UWP to Visual Studio?

On the Create a new project screen, enter Universal Windows in the search box, choose the C# template for Blank App (Universal Windows), and then choose Next. If you don't see the Blank App (Universal Windows) project template, click the Install more tools and features link. The Visual Studio Installer launches.


2 Answers

You can use Debug.WriteLine method from System.Diagnostics namespace

MSDN Link

When you start debugging your application those messages will be displayed in the Output Window (Standard VS shortcut is Ctrl+Alt+O, ReSharper shortcut is Ctrl+W, O)

like image 198
Grzegorz Piotrowski Avatar answered Sep 22 '22 21:09

Grzegorz Piotrowski


Starting with RS4 (the release coming out mid-2018) you can build command - line apps with UWP or output info to the command line. The pre-release SDK is already available and you can watch a Channel 9 video.

like image 34
Peter Torr - MSFT Avatar answered Sep 24 '22 21:09

Peter Torr - MSFT