0
Follow
0
View

Can not get Roslyn to work with .NET 5 project

dkam1816 注册会员
2023-01-24 22:40

Add reference to Microsoft.Build.Locator

I used the next packages:


    
    
    
    

Then register the instance of MSBuild using MSBuildLocator:

//add this line before using MSBuildWorkspace
MSBuildLocator.RegisterDefaults();  //select the recent SDK
using var workspace = MSBuildWorkspace.Create();

You Can control the version of MsBuild:

var visualStudioInstances = MSBuildLocator.QueryVisualStudioInstances();
//select NET5, or whatever by modifying Version.Major 
var instance = visualStudioInstances.FirstOrDefault(x => x.Version.Major.ToString() == "5");
MSBuildLocator.RegisterInstance(instance);  

About the Author

Question Info

Publish Time
2023-01-24 22:40
Update Time
2023-01-24 22:40

Related Question

GetX更新一个小部件列表

为什么我不必为我的自定义REST动作指定“GET”的动词()?

GET API调用在R中提取PDF

Realloc() causes leaks that I cannot find

java.lang.ClassNotFoundException:没有找到类

Edit files online using Office 365 using WOPI not working - Java

下一个js getServerSideProps, 404错误未找到

使用getter和Object.values()"超过最大调用堆栈大小"

scanf输入数字后跳过了下面的gets

重写Nuget包依赖项,以便使用该依赖项的更高版本