Skip to content

Having .NET 8.0 SDK installed causes mpc tool to not work #1831

Description

@readmaniak

Bug description

Having .NET 8.0 SDK causes mpc to fail.

Repro steps

Clean Win11. Installing newest Visual Studio Community 2022, or updating older VS 2022 to the newest available (.NET 8.0 SDK comes with it, and older SDK gets automatically uninstalled). Run in the cmd:

E:\ProjectName\ProjectName.Server\ProjectName.Shared>dotnet tool run mpc -i ./ProjectName.Shared.csproj -o ../../ProjectName.Client/Assets/Scripts/Generated/MessagePack.Generated.cs

Arguments do not matter tho, because failure in the mpc happens before the arguments are parsed.

Expected behavior

Expected mpc to work

Actual behavior

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 MessagePack.Generator.MessagepackCompiler.Main(String[] args) in D:\a\1\s\src\MessagePack.Generator\MessagepackCompiler.cs:line 25
at MessagePack.Generator.MessagepackCompiler.

(String[] args)

  • Version used: newest mpc tool at the moment of writing this bug report.
  • Runtime: .NET SDKs installed: 8.0.300

Additional context

Obviously, this is due to .NET 8.0 not being supported yet. Error message, however, is not very intuitive, and some people might not figure out what goes wrong.

So, generally, it worked fine while I had .NET 7.0. Once I updated VS, mpc started failing. Did a bit of digging into MSBuildLocator repository, found that it was only locating .net 8.0, which does not match to mpc environment. Simply adding .net 8.0 into the TargetFrameworks of MessagePack.Generator and updating the globals.json accordingly seems to fix the issue, while not causing any bugs in code-generation of my project.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions