Colored build output in Visual Studio - visual-studio

I am using a Visual Studio project with custom build script/batch file (ala make, ant, etc.).
When the build is run from the command line we have placed colored highlighting on various output lines.
However, when built via Visual Studio (2005 in my case) the output window does not show the color anymore.
Is this possible? I am quite happy to put specific code into the build script if required.

If you don't want to go with the pro version of the VSCommands plug-in, there is a free one called VSColorOutput, which does just that. I've worked with it a bit, does what it says.
See http://coolthingoftheday.blogspot.com/2011/12/vscoloroutput-visual-studio-output.html or look it up in the extension gallery.

The VSCommands plug-in for Visual Studio 2010 adds colour formatting to the output window so errors are red. I'm not sure how they are doing it but it might give you a starting point.

The problem isn't with your build scripts, but with Visual Studio not supporting ANSI control codes to change the color.

Related

how to get color code on my code FOR EXAMPLE (Debug.Log) to be in a color?

s
I want someone to tell me how to put colors on the code so its easier for me to code.
I think you forgot to select unity c# components when installing visual studio,
try again with visual code
If you are talking about Intellisense / syntax highlighting, you need to make sure that you installed Visual Studio Tools for Unity (Note this is needed for Visual Studio only and you may already have it installed).
Then follow these steps:
Close Visual Studio
In Unity, go to Edit > Preferences > External Tools
Click on the External Script Editor dropdown (this should be on which ever Visual Studio editor you are using or any other supported editor).
Make sure Embedded packages and Local Packages is checked under Generate csproj files for:
Click on Regenerate project files
Open any C# script and check if syntax highlighting is working.
In the worst case, if that does not work, you can close Unity and delete everything except the Assets/ and Project Settings/ folders (as well as anything you explicitly added) in your project's root directory. Unity will regenerate the project folders and files again when you open the project in the editor. It may just be that some of your project files were corrupt.
Also, in case I misinterpreted your question and you are talking about coloring the output in the console window within the editor, you can try using rich text which I believe is supported by Unity's console window in the latest versions.
Example:
Debug.Log("<color=red>this is red text</color>");
For more info on that:
https://docs.unity3d.com/Packages/com.unity.ugui#1.0/manual/StyledText.html

Code color code and highlighting for unity

I have just starting learning how to make games in Unity, using Visual Studio as the Script Editor, I see other people have their Code colour coded and it also has auto completion.
I've followed some tutorials online but nothing has worked for me.
what do I have to install to get it working?
To add auto-completion you have to add the unity visual studio package. To add this package please type in your windows search field: "Visual Studio Installer" and then click at the visual studio version the button "change". After that, a new window opens in this window click the field with the unity package and then install this package. Now you have auto-completion in Visual Studio.
To add colors look this video: https://www.youtube.com/watch?v=_g1TyAGk6Lk& I really recommend this color theme.
The Color Coding of Code can be found on the Tools>Options>Environment>Fonts and Colors. For example, you want to change the color for the Operators (+, -, /, *, etc.), you would need to find it in the Display items List and edit (found on the Right Side of the Display Items) the color of the foreground (the text itself), it's background or whether it is displayed in bold or not.
I believe that auto completion or IntelliSense is on by default as for what I have Experienced in switching from MonoDevelop to Visual Studio 2017.
Actually, i think you're looking at a popular visual studio plugin called Resharper;
https://www.jetbrains.com/resharper/
It also has a Unity3D plugin (for resharper) which adds full support. That's were the coloring and extra intellisense comes from.
You can see some sample pictures here; https://github.com/JetBrains/resharper-unity

Refactor on save in Visual Studio 2019

I love Prettier for VS Code. I want to do similar things in Visual Studio (2019).
It now has 'Wrap, indent, and align parameters or arguments' for example (https://learn.microsoft.com/en-us/visualstudio/ide/reference/wrap-align-indent-parameters?view=vs-2019); and I'd like to do this automatically whenever I save the file.
Does anyone know if this is possible? Or if there's a free extension that can do this?
Mads Kristensen (a Microsoft employee who makes scads of Visual Studio extensions and teaches you to too!) made a JsPrettier extension for "classic" Visual Studio (ie, not VS Code):
https://github.com/madskristensen/JavaScriptPrettier
It does not format on save if you set that up in its settings.
If it's literally Prettier in Visual Studio that you're after, this isn't a bad option.
I don't know of a free plugin but you can get quite a long way towards this with some muscle memory and the built in autoformat command.
CTRL+E, CTRL+D, CTRL+S
will do code indentation and formatting, and save the file.
If you have Resharper (sorry), there's a configurable code cleanup tool which will do what you want and CTRL+E, CTRL+F, CTRL+S will do the cleanup and save.
The Format document on Save VS extension does exactly what you want, with one exception. It automatically runs Visual Studio's code cleanup command on save.
Visual Studio's code cleanup commands covers many code style preferences and can be configured with a .editorconfig file. Unfortunately one thing that is not supported by VS yet (not counting Resharper) is line wrap preferences. There is an open ticket for this: dotnet/roslyn#33872
If and when Roslyn supports line wrap preferences (presumably as a new .editorconfig preference), then Visual Studio code cleanup will enforce it and the extension will apply it on save.

Visual Studio extension: How to make editor text behave like a link

I would like to write a Visual Studio extension, that makes a part of the text behave like a link: blue, underlined on hover, open a URL on click. (Like the default editor works for http://... texts.)
I can do classification (coloring) and also custom adornments and commands, so I could probably make this "manually", but I wonder if there is an easier way to do that.
I am interested to do this in normal Visual Studio (2017 or newer), not VS Code.
You can use UrlTag.
On how to use tags see Walkthrough: Highlight text and Visual Studio 2017 Extension development tutorial part 5: Highlight code in Editor.

Visual Studio not displaying compile time errors in editor

For example, when I write:
string x = "turtle";
x.Go();
There is no red squiggly line detecting the absence of the Go() method on String.
Only when I compile does the error get detected.
I've just upgraded to Windows 7, I have Visual Studio 2008.
In my old environment the errors were detected before the actual compile.
Is there a setting that I am missing?
EDIT: "Tools -> Options -> Text Editor -> C# -> Underline errors in the editor" is checked.
I dont have the "Live Semantic" option. Maybe I need to go to SP1?
You need to turn on the underline errors in the editor and show live semantic errors options in Visual Studio.
These options can be found here:
Tools > Options > Text Editor > C# > Advanced > Editor Help
Edit: You will need to install SP1 for this functionality to work.
Select Tool -> Options, then Text Editor. Under the language you are using (ie C#), go to the Advanced and make sure the Underline errors in the editor and Show live semantic errors are checked
Stop the project.
Open Folder Project.
Delete .vs folder (he is a hidden folder)
Then restart Visual Studio
EDIT:
This approach has been around since the 2012 version of Visual Studio. This folder consists of keeping all breakpoint information and other settings saved. It is not known why, the configurations arrive at a time when the errors of compilations no longer appear. Deleting the .vs folder will "reset" your breakpoints forcing you to do them again if you need to.
For visual studio 2015 and higher:
Go to: Tools > Options > Text Editor > C# > Advanced > Editor Help
Then select: Enable Full solution analysis
I had the same issue and had SP1 installed and had Underline errors in the editor and Show live semantic errors checked in VS2008's options.
My solution was to download Microsoft Visual Studio 2008 Service Pack 1 (Installer) and re-install the package. It wasn't classified as a 'repair' or a 're-install' despite the fact it was already installed, but it worked.
Restarting VS solved my problem once.
my solution; I know it won't help like 80% of the viewers, but for the sake of who it will:
i have had a lot of noise in the IOS part of the solution, a VS bug that showed a lot of errors that weren't supposed to appear, so I just deleted the IOS part because I didn't really needed it as I didn't even had a Mac server to test it on... Something happened after that and the squiggly line returned! Seriously, VS team, fix your bugs...
JavaScript Type Checking
Sometimes type checking your JavaScript code can help you spot mistakes you might have not caught otherwise. You can run the TypeScript type checker against your existing JavaScript code by simply adding a // #ts-check comment to the top of your file.
// #ts-nocheck
let easy = true;
easy = 42;
Tip: You can also enable the checks workspace or application wide by adding "javascript.implicitProjectConfig.checkJs": true to your workspace or user settings and explicitly ignoring files or lines using // #ts-nocheck and // #ts-ignore. Check out the docs on JavaScript in VS Code to learn more.
In my case the problem was that I created a file with .s extension instead of .cs an then changed the extension to .cs once it was created.
I deleted it and created again correctly and now VS is underlining the errors in this file.

Resources