New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OpenProjectAsync: The SDK 'Microsoft.NET.Sdk' specified could not be found. #44586
Comments
cc @jmarolf |
This is related to microsoft/MSBuildLocator#88. There is a dependency that is not being re-directed by the msbuild locator. In |
How can I fix this issue? (Wait for a fix in |
@HamedFathi microsoft/MSBuildLocator#88 applies to projects using custom SDKs, but does not apply to Microsoft.NET.Sdk. It looks like your code above is not installing the MSBuild Locator. You will need to update your project to use it. See the following for details: |
Thanks, Based on your guidance I added these <PackageReference Include="Microsoft.Build.Locator" Version="1.2.6" />
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="16.5.0" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build.Framework" Version="16.5.0" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build" Version="16.5.0" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="16.5.0" ExcludeAssets="runtime" /> And MSBuildLocator.RegisterDefaults(); // HERE
var workspace = MSBuildWorkspace.Create(); It seems that problem fixed! but I got another error
Did I miss something else? |
I haven't seen that error before. @jmarolf ? |
@jmarolf Any help?! |
Basically MSBuild is trying to load the dll that contains your tasks and is unable to. The reason it gives is that it cannot find a Though it could be that the msbuild target that you are trying to load is fundamentally incompatible with .NET Core. |
Sorry, Actually, I am looking for a simple console-based project to read/analyze another (class-based) project by Roslyn. |
is the project you are analyzer a .NET Core or .NET Standard project? |
@HamedFathi this is what a simple console based project should look like
|
Thanks for the amazing answer, but I got another error! (based on your snippet) so I added the following packages too
Works perfectly, Thanks |
Version Used:
Steps to Reproduce:
I created a simple console application via
dotnet new console
Then I wrote a block of code in another application to get the compilation result by Roslyn
Expected Behavior:
Load all projects without error.
Actual Behavior:
The length of
Documents
is 0 so I wrote another block of code to find out what was the problemThe error is (VS):
and in Rider:
How to fix this issue?
The text was updated successfully, but these errors were encountered: