Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why can't I use "Reformat with CSharpier" in Visual studio 2022? #1072

Open
nickhsu2020 opened this issue Dec 15, 2023 · 4 comments
Open

Why can't I use "Reformat with CSharpier" in Visual studio 2022? #1072

nickhsu2020 opened this issue Dec 15, 2023 · 4 comments

Comments

@nickhsu2020
Copy link

nickhsu2020 commented Dec 15, 2023

It is unclickable
image

It doesn't work. When I set "Reformat with CSharpier on Save"
image

This are my version
CSharpier globally version 0.26.6
Visual Studio CSharpier extension version 1.4.8
Visual Studio 2022 version 17.8.3

I found the log:
OnBeforeSave
Before format
Skipping formatting because process does not support formatting.
Done Format

Thanks.

@NotAsea
Copy link

NotAsea commented Dec 15, 2023

Can confirm this issue, moreover this issue also rise if you install Resharper after this, somehow option is missing completely

@NotAsea
Copy link

NotAsea commented Dec 15, 2023

Anyway if you get this issue, uninstall the extension, manually download tool to global

dotnet tool install -g csharpier #verify you don't have charpier, if you've already had, skip this

Then install this extension and it should work out again

@belav
Copy link
Owner

belav commented Dec 15, 2023

The message "Skipping formatting because process does not support formatting." indicates that the extension was unable to get csharpier running in the background. I haven't had a chance to update VS yet to add more helpful logging, but these Troubleshooting Steps should help figure out why the extension is unable to run CSharpier.

@dacarmr
Copy link

dacarmr commented Dec 19, 2023

I've run into the same problem.

Uninstall the tool globally and the extension.
Folder looks like:
image
dotnet csharpier --version

dotnet : Could not execute because the specified command or file was not found.

Install:
dotnet tool install csharpier -g

Tool 'csharpier' (version '0.26.7') was successfully installed.
PM> dotnet csharpier --version
0.26.7+c8aec14
image
Folder remains unchanged but version has id suffix.

Install extension. Launch VS2022.
image
PM> dotnet csharpier --version

0.26.7+c8aec144f227bda8cf195011e9d91bb36c33337f

[Debug - 12/19/2023 12:40:26 PM] Unable to find dotnet-tools.json, falling back to running dotnet csharpier --version
[Debug - 12/19/2023 12:40:27 PM] dotnet csharpier --version output:
[Debug - 12/19/2023 12:40:27 PM] Using as the version number.
[Warn - 12/19/2023 12:40:27 PM] CSharpier was not found so files may not be formatted.

So probably the issue is the version includes the id but the folder doesn't.
I'll delete all folders after uninstall for csharpier and retry.

EDIT: Not sure if relevant but a different solution I may have clicked "install locally" instead of globally. I wonder if that could cause this issue.

EDIT 2:
Followed the steps from the provided troubleshooting guide.
Uninstall tool, extension, delete folder in appData.

PM> dotnet tool install csharpier --version 0.26.7 --tool-path "not actual path\local\CSharpier\0.26.7"
PM> dotnet csharpier --version
0.26.7+c8aec144f227bda8cf195011e9d91bb36c33337f

But this still didn't resolve the issue.
I tried renaming the folder to include the id but this doesn't work either.
image

[Debug - 12/19/2023 12:56:42 PM] Unable to find dotnet-tools.json, falling back to running dotnet csharpier --version
[Debug - 12/19/2023 12:56:42 PM] dotnet csharpier --version output:
[Debug - 12/19/2023 12:56:42 PM] Using as the version number.
[Warn - 12/19/2023 12:56:42 PM] CSharpier was not found so files may not be formatted.

EDIT 3:
If I click "install globally" warning from vs2022 I get this in the CSharpier output:

[Debug - 12/19/2023 1:03:09 PM] Installing CSharpier globally
[Debug - 12/19/2023 1:03:09 PM] Tool 'csharpier' is already installed.
[Debug - 12/19/2023 1:03:09 PM] disposing of process for version null

EDIT 4:
Today (after a computer shutdown) I opened another solution and the problem is gone.

[Debug - 12/20/2023 11:15:05 AM] Unable to find dotnet-tools.json, falling back to running dotnet csharpier --version
[Debug - 12/20/2023 11:15:07 AM] dotnet csharpier --version output: 0.26.7+c8aec144f227bda8cf195011e9d91bb36c33337f
[Debug - 12/20/2023 11:15:07 AM] Using 0.26.7 as the version number.
[Debug - 12/20/2023 11:15:07 AM] dotnet csharpier --version output: 0.26.7+c8aec144f227bda8cf195011e9d91bb36c33337f
[Debug - 12/20/2023 11:15:07 AM] Using 0.26.7 as the version number.
[Debug - 12/20/2023 11:15:07 AM] CSharpier at C:\Users<redacted>\AppData\Local\CSharpier\0.26.7 already exists
[Debug - 12/20/2023 11:15:07 AM] Adding new version 0.26.7 process for
[Debug - 12/20/2023 11:15:07 AM] Warm CSharpier with initial format

@belav belav modified the milestones: 0.26.7, Planned - Extensions Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants