-
Notifications
You must be signed in to change notification settings - Fork 90
Open
Description
I've been trying to load a csproj using new Microsoft.Build.Evaluation.Project("project.csproj", null, null");
and it throws this exception:
The specified SDK "Microsoft.NET.Sdk.WindowsDesktop" could not be found.
Source: Microsoft.Build
Error: MSB4236
MSBuild.CouldNotResolveSdk
The loaded csproj looks like this:
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<TargetFramework>net471</TargetFramework>
<UseWPF>true</UseWPF>
</PropertyGroup>
</Project>
And the host application registers the MSBuild location with:
Microsoft.Build.Locator.MSBuildLocator.RegisterDefaults();
I've noticed different behavior depending on whether the host application is compiled against Net472 or against NetCoreApp31:
On Net472
- The
Microsoft.NET.Sdk.WindowsDesktop
projects succeeds to load. MSBuildPath
of Locator Instance points to: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin"
On NetCoreApp3.1
- The
Microsoft.NET.Sdk.WindowsDesktop
projects throw an exception on load. MSBuildPath
of Locator instance points to: "C:\Program Files\dotnet\sdk\2.2.300"
On Net4xx:
So I believe this is the reason because it works on Net4 and not on NetCore.
Is there a way to solve this issue and make the "Microsoft.NET.Sdk.WindowsDesktop" projects to load while the host app is NetCoreApp?
Metadata
Metadata
Assignees
Labels
No labels