sensslen / nuget-license

.NET Core tool to print or save all the licenses of a project
Apache License 2.0
47 stars 9 forks source link

MSBuild - No instances of MSBuild could be detected. #112

Closed Diddlik closed 2 hours ago

Diddlik commented 3 hours ago

I get this error message when I try to start nuget-license. I have already tried with VS 2022 as well as with 2023 Preview.

PS C:\Data\Coding\DGO_new Repo\DGO_NG\Solution> nuget-license -i DGO.sln
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 NuGetUtility.Wrapper.MsBuildWrapper.MsBuildAbstraction.RegisterMsBuildLocatorIfNeeded() in D:\a\nuget-license\nuget-license\src\NuGetUtility\Wrapper\MsBuildWrapper\MsBuildAbstraction.cs:line 46
   at NuGetUtility.Wrapper.MsBuildWrapper.MsBuildAbstraction..ctor() in D:\a\nuget-license\nuget-license\src\NuGetUtility\Wrapper\MsBuildWrapper\MsBuildAbstraction.cs:line 18
   at NuGetUtility.Program.OnExecuteAsync(CancellationToken cancellationToken) in D:\a\nuget-license\nuget-license\src\NuGetUtility\Program.cs:line 109
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.InvokeAsync(MethodInfo method, Object instance, Object[] arguments)
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.OnExecute(ConventionContext context, CancellationToken cancellationToken)
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.<>c__DisplayClass0_0.<<Apply>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken)
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync[TApp](CommandLineContext context, CancellationToken cancellationToken)
   at NuGetLicenseCore.Program.Main(String[] args) in D:\a\nuget-license\nuget-license\src\NuGetLicenseCore\Program.cs:line 14
   at NuGetLicenseCore.Program.<Main>(String[] args)
sensslen commented 3 hours ago

Which operating System are you on? What is the output of dotnet --list-sdks? In order to use nuget-license, you need to have a dotnet SDK installed. Installing visual studio does not necessarily install that - it depends on which payload you install.

Diddlik commented 3 hours ago

dotnet --list-sdks 9.0.100-rc.2.24474.11 [C:\Program Files\dotnet\sdk]

And I have windows 11

Diddlik commented 2 hours ago

I reinstalled .net 8 sdk and now it works.

sensslen commented 2 hours ago

nuget-license is not yet available for .net 9. I'm having trouble with the dotnet format command --> See https://github.com/sensslen/nuget-license/pull/110