ODataConnectedService icon indicating copy to clipboard operation
ODataConnectedService copied to clipboard

Unhandled exception. System.InvalidOperationException: No instances of MSBuild could be detected

Open koldomon opened this issue 3 years ago • 5 comments

today I made the update for visual studio 17.4 and installed the tool via "dotnet tool install microsoft.odata.cli -g" everything seems fine, I didn't get any errors, but when I try to run the tool I get the following exception:

Unhandled exception. System.InvalidOperationException: No instances of MSBuild could be detected. Try calling RegisterInstance or RegisterMSBuildPath to manually register one. at Microsoft.Build.Locator.MSBuildLocator.RegisterDefaults() at Microsoft.OData.Cli.Program.Main(String[] args) in D:\a\1\s\src\Microsoft.OData.Cli\Program.cs:line 10 at Microsoft.OData.Cli.Program.<Main>(String[] args)

I'm not sure if there is a relation between the VS update and this error.

koldomon avatar Nov 09 '22 08:11 koldomon

+1 to this, I'm seeing the same issue using the raw command line tool. odata-cli Unhandled exception. System.InvalidOperationException: No instances of MSBuild could be detected. Try calling RegisterInstance or RegisterMSBuildPath to manually register one. at Microsoft.Build.Locator.MSBuildLocator.RegisterDefaults() at Microsoft.OData.Cli.Program.Main(String[] args) in D:\a\1\s\src\Microsoft.OData.Cli\Program.cs:line 10 at Microsoft.OData.Cli.Program.<Main>(String[] args)

WillEastbury avatar Dec 19 '22 11:12 WillEastbury

Solved it -> Install .NET 5.0 SDK.

WillEastbury avatar Jul 17 '23 10:07 WillEastbury

@koldomon Was this issue resolved?

KenitoInc avatar Feb 22 '24 12:02 KenitoInc

I just had the same error and installing .NET Core 6 SDK fixed the error. Link to install: https://dotnet.microsoft.com/en-us/download/dotnet/6.0

Notes: I had .NET Core 8 SDK installed already, but .NET Core 6 SDK was required in additional for this tool to work. The .NET Core 6 SDK and .NET Core 8 SDK can be installed side by side on the same machine. I'm using odata-cli version 0.3.1 installed via: dotnet tool install --global Microsoft.OData.Cli --version 0.3.1

batetech avatar Jul 11 '24 17:07 batetech

Installing the SDK v6 also solved the problem for me with version 0.3.1.

However, I'd say that closing this ticket at least requires adding a better error message, such as "Unable to find an MSBuild instance, ensure .NET SDK version N is installed", with perhaps some link to the download page / ms documentation / winget instructions or anything that would hint the user towards the correct requirement.

ArwynFr avatar Aug 10 '24 15:08 ArwynFr