我在项目中有此软件包:
<PackageReference Include="Microsoft.CodeAnalysis" Version="2.8.2" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="1.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="2.8.2" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.8.2" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="2.8.2" />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="2.8.2" />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="2.8.2" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="2.8.2" />
我将此.csproj文件移动为2017格式,然后在构建解决方案时出现错误:
错误CS0104:“项目”之间存在不明确的引用 “ Microsoft.CodeAnalysis.Project”和“ Some.Namespace.Project”
当然,此错误是因为上述软件包中的一个移至父项目,并且与同名类冲突。
我的问题是,我应该设置哪些资产(IncludeAssets
,ExcludeAssets
,PrivateAssets
),具有什么价值和包装?
目前,.csproj文件如下所示:
<PackageReference Include="Microsoft.CodeAnalysis" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="1.1.0">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
但是我认为这不是最佳和精确的选择。
答案 0 :(得分:1)
这里最好的办法是创建一个全新的空白项目。请参考2.8.2版本,然后将csproj文件中的内容与实际解决方案进行比较。删除真实解决方案中不在虚拟文件中的所有引用。很有可能名称空间已经发生了变化,但是至少一旦您正确地获得了引用,名称空间就不会那么困难。