Jetbrains Cleanup Code

Hi guys,

 I am trying to integrate a git hook with Jetbrains Cleanup Code, but I am facing this error.

JetBrains Cleanup Code 2024.3.5
Running on x64 OS in x64 architecture, .NET 9.0.2 under Microsoft Windows 10.0.26100

The SDK 'Microsoft.NET.SDK.WorkloadAutoImportPropsLocator' specified could not be found.  C:\Program Files\dotnet\sdk\8.0.406\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.props at (14:38)
The SDK 'Microsoft.NET.SDK.WorkloadAutoImportPropsLocator' specified could not be found.  C:\Program Files\dotnet\sdk\8.0.406\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.props at (14:38)
The SDK 'Microsoft.NET.SDK.WorkloadAutoImportPropsLocator' specified could not be found.  C:\Program Files\dotnet\sdk\8.0.406\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.props at (14:38)

I'm on windows with dotnet 8 and 9 skds installed and in the target solution i need dotnet 8 (setted up via global.json)

The thing I noticed from the log is that from the header it shows dotnet 9 while in the exception the paths refer to dotnet 8 sdk.

Has anyone had similar error ? any advice ?

 

Update:
Same issue with the same dotnet version. Trying to set dotnet 9 at global.json a similar error occurs:

JetBrains Cleanup Code 2024.3.5
Running on x64 OS in x64 architecture, .NET 9.0.2 under Microsoft Windows 10.0.26100
The SDK 'Microsoft.NET.SDK.WorkloadAutoImportPropsLocator' specified could not be found.  C:\Program Files\dotnet\sdk\9.0.200\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.props at (14:38)

 

0
6 comments

Already tried:

  • dotnet workload restore which still fail
  • $env:MSBuildEnableWorkloadResolver = 'false' that does not cause the error

But the env var is not an option because is needed for other purposes.

0

Hello Claudio,

Thank you for contacting Rider support.

I looked into this and see that normally the cleanupcode.exe runs under .Net Framework. The way to launch it under .Net installed on machine (or .Net specified on global.json) is to pass cleanupcode.exe as an argument for dotnet command.

So, I suppose you use CLI dotnet <pathToRSCmdTools>/cleanupcode.exe <pathtoSlnOrCsproj>. Would you mind trying to use <pathToRSCmdTools>/cleanupcode.exe <pathtoSlnOrCsproj> instead to see if that helps?

Have a nice day!

0

Actually at the moment I followed the guide by installing it as a dotnet tool.

So I did dotnet tool install JetBrains.ReSharper.GlobalTools whose references are saved in the ./.config/dotnet-tools.json file.

I am running the command like this

dotnet tool restore
dotnet jb cleanupcode MySolution.sln "--include=${staged:;}"

Where staged are all the file path separated by ; char.

— 

Regarding your suggestion, the error is identical although it actually changes something in the header.

  • I retrieved path of the executable from %USERPROFILE%\.dotnet\toolResolverCache\1
  • That brought me to the nuget cache %NUGET_PACKAGES%\jetbrains.resharper.globaltools\2024.3.5\tools\netcoreapp3.1\any

This is the output

> $cc = '' # full exe path described above
> . $cc MySolution.sln
JetBrains Cleanup Code 2024.3.5
Running on x64 OS in x64 architecture, .NET Framework 4.8.9290.0 under Microsoft Windows 10.0.26100
Using toolset version 17.0 from "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\amd64"
Configuration: Debug, Platform: Any CPU
[MSB4236] The SDK 'Microsoft.NET.SDK.WorkloadAutoImportPropsLocator' specified could not be found.  C:\Program Files\dotnet\sdk\9.0.200\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.props at (14:38)

 

0
Would you mind sharing the output of `dotnet --info` and the content of youyr global.json, please?
0

assuming that working directory is: D:\git\myproject

global.json

{
  "sdk": {
    "version": "8.0.0",
    "rollForward": "latestMajor",
    "allowPrerelease": true
  },
  "msbuild-sdks": {
    "Microsoft.Build.Traversal": "3.0.23"
  }
}

dotnet --info

.NET SDK:
 Version:           9.0.200
 Commit:            90e8b202f2
 Workload version:  9.0.200-manifests.69179adf
 MSBuild version:   17.13.8+cbc39bea8

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.26100
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\9.0.200\

.NET workloads installed:
 [aspire]
   Installation Source: SDK 9.0.200, VS 17.13.35818.85
   Manifest Version:    8.2.2/8.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.2.2\WorkloadManifest.json
   Install Type:              Msi

Configured to use loose manifests when installing new manifests.

Host:
  Version:      9.0.2
  Architecture: x64
  Commit:       80aa709f5d

.NET SDKs installed:
  8.0.406 [C:\Program Files\dotnet\sdk]
  9.0.103 [C:\Program Files\dotnet\sdk]
  9.0.200 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 9.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  D:\git\myproject\global.json

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

 

0

Hello Claudio,

Unfortunately, it is hard to day what exactly goes wrong. Would you mind sharing more details and commenting on my questions/suggestions below?

What about dotnet workload restore ? Does it succeeds when invoked from the terminal (with "cd D:\git\myproject")?

And what about this variable $env:MSBuildEnableWorkloadResolver = 'false' . Do you mean the cleanupcode finishes fine when MSBuildEnableWorkloadResolver=true?

First, I would try specifying exact sdk from global.json to avoid ambiguity: (or temporary remove the global.json file)

"version": "8.0.0", -> "version": "8.0.406",
"rollForward": "latestMajor", -> "rollForward": "disable", 

Second,  I suggest ensuring the whole “.Net desktop development” and “ASP.NET and web development” workloads are installed in VS installer;
Third, try building your solution using the same MSBuild utilized by cleanup tool:
& "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\amd64\MSBuild.exe" "C:\PathTo\Your\Solution.sln"
Fourth, try uninstalling both existing .Net 9 installations, so that only .Net 8 remain available. If still issue persists, try reinstalling .Net 8 using installer from .Net downloads page.

Additionally, would you mind checking if invoking cleanup tool from Rider-bundled terminal prints the same error? And does the issue persists for a newly created solution? (or the issue reproduces only with exact solution)

If nothing helps or you do not wish reinstalling .Net, I would appreciate it if you could share a log file for the cleanupcode tool:

dotnet jb cleanupcode .\AspireTest.sln --verposity=TRACE > output.txt
Please attach the log to the Upload Service and let me know the Upload ID.

Have a nice day!

0

Please sign in to leave a comment.