Microsoft.CodeAnalysis.Workspaces.MSBuild 4.4.0
Microsoft.CodeAnalysis.CSharp.Workspaces 4.4.0
Microsoft.Build 17.4.0
Microsoft.Build.Tasks.Core 17.4.0
通过nuget依次安装上面四个package,一定要按顺序安装,因为每个package还有依赖的package,会发生依赖的package发生覆盖。
比如 安装abc三个包,a依赖d的v1,b依赖d的v2,c依赖d的v3,此时安装顺序就导致了d的版本发生变化。
最终所有package的版本
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Humanizer.Core" version="2.14.1" targetFramework="net472" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="6.0.0" targetFramework="net472" />
<package id="Microsoft.Build" version="17.4.0" targetFramework="net472" />
<package id="Microsoft.Build.Framework" version="17.4.0" targetFramework="net472" />
<package id="Microsoft.Build.Tasks.Core" version="17.4.0" targetFramework="net472" />
<package id="Microsoft.Build.Utilities.Core" version="17.4.0" targetFramework="net472" />
<package id="Microsoft.CodeAnalysis.Analyzers" version="3.3.3" targetFramework="net472" developmentDependency="true" />
<package id="Microsoft.CodeAnalysis.Common" version="4.4.0" targetFramework="net472" />
<package id="Microsoft.CodeAnalysis.CSharp" version="4.4.0" targetFramework="net472" />
<package id="Microsoft.CodeAnalysis.CSharp.Workspaces" version="4.4.0" targetFramework="net472" />
<package id="Microsoft.CodeAnalysis.Workspaces.Common" version="4.4.0" targetFramework="net472" />
<package id="Microsoft.CodeAnalysis.Workspaces.MSBuild" version="4.4.0" targetFramework="net472" />
<package id="Microsoft.IO.Redist" version="6.0.0" targetFramework="net472" />
<package id="Microsoft.NET.StringTools" version="17.4.0" targetFramework="net472" />
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
<package id="System.Collections.Immutable" version="6.0.0" targetFramework="net472" />
<package id="System.Composition" version="6.0.0" targetFramework="net472" />
<package id="System.Composition.AttributedModel" version="6.0.0" targetFramework="net472" />
<package id="System.Composition.Convention" version="6.0.0" targetFramework="net472" />
<package id="System.Composition.Hosting" version="6.0.0" targetFramework="net472" />
<package id="System.Composition.Runtime" version="6.0.0" targetFramework="net472" />
<package id="System.Composition.TypedParts" version="6.0.0" targetFramework="net472" />
<package id="System.Configuration.ConfigurationManager" version="6.0.0" targetFramework="net472" />
<package id="System.IO.Pipelines" version="6.0.3" targetFramework="net472" />
<package id="System.Memory" version="4.5.5" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
<package id="System.Reflection.Metadata" version="6.0.0" targetFramework="net472" />
<package id="System.Reflection.MetadataLoadContext" version="6.0.0" targetFramework="net472" />
<package id="System.Resources.Extensions" version="6.0.0" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net472" />
<package id="System.Security.AccessControl" version="6.0.0" targetFramework="net472" />
<package id="System.Security.Permissions" version="6.0.0" targetFramework="net472" />
<package id="System.Security.Principal.Windows" version="5.0.0" targetFramework="net472" />
<package id="System.Text.Encoding.CodePages" version="6.0.0" targetFramework="net472" />
<package id="System.Text.Encodings.Web" version="6.0.0" targetFramework="net472" />
<package id="System.Text.Json" version="6.0.0" targetFramework="net472" />
<package id="System.Threading.Tasks.Dataflow" version="6.0.0" targetFramework="net472" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
</packages>
如果版本不对,或者少安装了package,会导致MSBuildWorkspace.Create()报错,或者solution得到的projects不对,或者project的document不对