dotnet / dotnet/format

Can't capture 'dotnet format --verify-no-changes' output into a Powershell variable

Open
#1,514 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
No language data
Stars
1.9k
Forks
173
Avg merge
10d 13h
Merged PRs (30d)
1

Description

## Summary

If you run the command `dotnet format --verify-no-changes` in PowerShell and try to assign the output of the command to a variable, it doesn't work.

However, if you run a different command such as `dotnet build`, I am able to capture the output.

I know that there are work arounds for that (json report), but I believe the output behavior of the commands should be consistent across the board.

## Steps

* Have a small .NET 6 project that needs formatting (i.e. extra spaces).
* Run: `PS > $output = dotnet format --verify-no-changes`
* **The tool will output the results, but the variable $output will be empty.**
* If you try to do the same thing with `dotnet build`, you can see that the variable has the output of the command.

![image](https://user-images.githubusercontent.com/4195793/153107392-345af232-653b-4d74-8b01-05abed0e3fdf.png)

![image](https://user-images.githubusercontent.com/4195793/153107476-eeb3aa8a-131f-46ef-9059-4616971493b9.png)

Powershell: 7.2.1
dotnet: 6.0.102
dotnet format version: 6.0.252703+68bc36719088c86b0ff01334039b0611741b8276

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.