我的 C# .Net Framework 4.8 应用程序上突然出现以下警告。 我已删除所有 bin 和 obj 文件夹,并尝试从包中删除并安装 DotNetCompilerPlat,但该消息不断出现。有什么想法吗?
\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.4.1.0\build\net472\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.targets(13,9): message : MSB4120: Item 'RoslynCompilerFiles' definition within target references itself via (qualified or unqualified) metadatum 'RecursiveDir'. This can lead to unintended expansion and cross-applying of pre-existing items. More info: https://aka.ms/msbuild/metadata-self-ref
\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.4.1.0\build\net472\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.targets(13,9): message : MSB4120: Item 'RoslynCompilerFiles' definition within target references itself via (qualified or unqualified) metadatum 'Filename'. This can lead to unintended expansion and cross-applying of pre-existing items. More info: https://aka.ms/msbuild/metadata-self-ref
\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.4.1.0\build\net472\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.targets(13,9): message : MSB4120: Item 'RoslynCompilerFiles' definition within target references itself via (qualified or unqualified) metadatum 'Extension'. This can lead to unintended expansion and cross-applying of pre-existing items. More info: https://aka.ms/msbuild/metadata-self-ref
(我已经从错误中删除了具体的目录信息)
单击错误会显示下面的 XML,但这是包的一部分,因此我不知道它是如何突然显示为警告的。
<Target Name="SetRoslynCompilerFiles" >
<Message Text="Using Roslyn from '$(RoslynToolPath)' folder" />
<ItemGroup>
<RoslynCompilerFiles Include="$(RoslynToolPath)\*">
<Link>roslyn\%(RecursiveDir)%(Filename)%(Extension)</Link> <---- Error line
</RoslynCompilerFiles>
</ItemGroup>
</Target>
完整的 xml 可以在这里找到:
\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.4.1.0\build\net472\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.targets
确保项目中的所有 NuGet 包都是最新的,尤其是 Microsoft.CodeDom.Providers.DotNetCompilerPlatform 包。您可以通过右键单击“解决方案资源管理器”中的项目并选择“管理 NuGet 包”来执行此操作。将所有软件包更新到最新版本。
或者您可以尝试暂时删除该包:作为调试目的的临时措施,您可以尝试暂时从项目中删除 Microsoft.CodeDom.Providers.DotNetCompilerPlatform 包,看看警告是否消失。如果警告消失,则可能表明该软件包版本存在特定问题。