When analysing .NET framework projects, which version of MSBuild do I need? #71530
-
I have a code analysis app running on .NET 7 which attempts to load a solution with .NET framework 4.8 projects:
When the projects fail to load the .NET SDK, I've added the following line to locate MSBuild:
But this throws "No instances of MSBuild could be detected" My question is given I have Visual Studio 2022 installed, how can MSBuild not be located? And if Roslyn needs it, which instance of MSBuild do I need to download for Roslyn to locate and use for 4.8 projects? My MSBuild with VS2022 lives here: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin It fails to find it even with the below:
Note: In Installed Apps I have Microsoft .NET SDK 8.0.100 (x64) from Visual Studio |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Try upgrading to the 4.9.0-2.final NuGet packages, which remove the need to use MSBuildLocator; we'll do the extra work for you behind the scenes. The reason why this wouldn't have worked is because there's limitations where the .NET Core MSBuilds can't be loaded in to a .NET Framework process or vice versa -- so your .NET Core app can't use the VS one. The changes in our new packages mean we'll actually launch a separate process behind the scenes to make this all work. |
Beta Was this translation helpful? Give feedback.
Try upgrading to the 4.9.0-2.final NuGet packages, which remove the need to use MSBuildLocator; we'll do the extra work for you behind the scenes.
The reason why this wouldn't have worked is because there's limitations where the .NET Core MSBuilds can't be loaded in to a .NET Framework process or vice versa -- so your .NET Core app can't use the VS one. The changes in our new packages mean we'll actually launch a separate process behind the scenes to make this all work.