-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
MSBuildWorkspace.Create() fails when pointing to the .NET 7 SDK from a .NET 6 project #29108
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
To add to this, when I run the The output I get from C:\Program Files\dotnet\sdk\6.0.100
C:\Program Files\dotnet\sdk\5.0.100
C:\Program Files\dotnet\sdk\2.1.811
C:\Program Files\dotnet\sdk\2.1.521
C:\Program Files\dotnet\sdk\2.1.402
C:\Program Files\dotnet\sdk\2.1.202
C:\Program Files\dotnet\sdk\1.1.14
C:\Program Files\dotnet\sdk\1.1.10 Running the same command from a .NET 7 project adds the following SDK: C:\Program Files\dotnet\sdk\7.0.100 |
The reason you don't see the 7.0 SDK when run from a 6.0 project using Locator is that Locator uses the runtime version of the executing application to limit the set of returned SDKs to presumable-compatible ones. You will need to retarget your application to net7.0 in order to use the 7.0 SDK toolchain. |
Thanks @baronfel, that makes sense as to why the SDK does not show up in my list. What about when I manually target the .NET 7 SDK using |
No, that won't work because by the time you're loading the MSBuild binaries from the 7.0 SDK (which have a dependency on 7.0 dlls) you're already running on a 6.0 .NET Runtime. That's why in your initial report the MSBuild libraries were erroring trying to load System.Runtime. |
Ok, thanks. I'll mark this issue as closed, then, since my assumption about being able to load newer SDKs was incorrect. |
Describe the bug
When referencing the the .NET 7 SDK via the
MSBuildLocator
prior to the call toMSBuildWorkspace.Create()
in a .NET 6 project, the.Create()
call fails as it is unable to load .NET 7 runtime assemblies.Note
It is possible that this functions as intended... i.e. that you cannot create an MSBuild workspace using a newer SDK than the one that the project is compiled with. If that is the case, please close this issue. However, I have not been able to find any documentation that says explicitly that this should not work.
To Reproduce
Run the following code in a .NET 6 console application. (needs the
Microsoft.Build.Locator
andMicrosoft.CodeAnalysis.Workspaces.MSBuild
packages)Exceptions
Further technical details
The text was updated successfully, but these errors were encountered: