由于我不太明白的错误而无法构建 - "ReferencePath" 没有为元数据 "CopyLocal" 定义值
Unable to build due to an error I do not quite understand - "ReferencePath" does not define a value for metadata "CopyLocal"
我最近一直在更新一个项目,但由于以下错误(修剪了一些路径以使其更短),我无法构建该项目进行测试:
The item "C:\Users..blah..\packages\System.Runtime.WindowsRuntime.4.6.0-preview4.19212.13\build\net461....\ref\netstandard2.0\System.Runtime.WindowsRuntime.dll" in item list "ReferencePath" does not define a value for metadata "CopyLocal". In order to use this metadata, either qualify it by specifying %(ReferencePath.CopyLocal), or ensure that all items in this list define a value for this metadata.
我在网上搜索了其他解决方案,但没有找到导致此问题的答案。
就实际错误而言,我假设我可以在编辑器中加载我的项目文件,并将 %(ReferencePath.CopyLocal) 附加到 "CopyLocal" 具有空值的任何字段, 但似乎并非如此
我什至不确定我需要查看哪个文件!
我找到的唯一解决方案是创建一个具有相同文件结构的新项目,并将引用和导入结构比作新的驱动器盘符。
然后用这个新的 proj 文件替换旧的 proj 文件并再次手动更新驱动器号以指向正确的位置
在我看来,这个错误实际上是错误的,并且是重新加载某些 Nuget 包导致损坏的副产品
但是,这远非最佳,所以如果有人有更好的解决方案而不涉及这样做,请随时 post!
当我尝试从 DotNet 4.5 项目迁移到 DotNet 4.6.2 项目时,我遇到了这个问题。当我从 package.config 迁移到 PackageReference.
时,这个问题得到了解决
在项目解决方案中右击'References' -> select 'Migrate from package.config to PackageReference'.
我遇到了类似的问题。我通过删除 obj、bin 和 .vs 文件等缓存文件解决了这个问题。希望这对遇到类似问题的人有所帮助
我 运行 在尝试使用 Auth0 WinForm SDK 制作 MS Office 插件时遇到了这个问题。我得到的错误是:
C:\Program Files (x86)\Microsoft Visual Studio19\Professional\MSBuild\Microsoft\VisualStudio\v16.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets(226,9): error MSB4096: The item "C:\Users\XXXXXXX\.nuget\packages\system.runtime.windowsruntime.6.0\buildTransitive\net461\..\..\ref\netstandard2.0\System.Runtime.WindowsRuntime.dll" in item list "ReferencePath" does not define a value for metadata "CopyLocal". In order to use this metadata, either qualify it by specifying %(ReferencePath.CopyLocal), or ensure that all items in this list define a value for this metadata.
要解决此问题,我必须根据错误消息编辑引用文件中的第 226 行。在我的例子中,该文件是:
C:\Program Files (x86)\Microsoft Visual Studio19\Professional\MSBuild\Microsoft\VisualStudio\v16.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets
我更改了这一行:
<_CopyLocalFalseRefPaths Include="@(ReferencePath)" Condition="'%(CopyLocal)' == 'false'" />
为此:
<_CopyLocalFalseRefPaths Include="@(ReferencePath.CopyLocal)" Condition="'%(CopyLocal)' == 'false'" />
我从这里得到了这个解决方案:https://marcelegger.net/referencepath-does-not-define-a-value-for-metadata-copylocal
将@(ReferencePath)替换为@(ReferencePath.CopyLocal) 也适用于我,但由于授权问题,我不得不将文件保存在另一个目录中,并将其复制到正确的目录中。
这似乎是 msbuild 处理对空项目组中元数据的引用的方式的变化。编辑目标文件通常不切实际,但我有 .csproj 文件的解决方法。在开头附近添加以下内容:
<ItemDefinitionGroup>
<ReferencePath>
<CopyLocal>false</CopyLocal>
</ReferencePath>
</ItemDefinitionGroup>
这将 'CopyLocal' 定义为 'ReferencePath' 的默认元数据并且似乎对我有用。
我最近一直在更新一个项目,但由于以下错误(修剪了一些路径以使其更短),我无法构建该项目进行测试:
The item "C:\Users..blah..\packages\System.Runtime.WindowsRuntime.4.6.0-preview4.19212.13\build\net461....\ref\netstandard2.0\System.Runtime.WindowsRuntime.dll" in item list "ReferencePath" does not define a value for metadata "CopyLocal". In order to use this metadata, either qualify it by specifying %(ReferencePath.CopyLocal), or ensure that all items in this list define a value for this metadata.
我在网上搜索了其他解决方案,但没有找到导致此问题的答案。
就实际错误而言,我假设我可以在编辑器中加载我的项目文件,并将 %(ReferencePath.CopyLocal) 附加到 "CopyLocal" 具有空值的任何字段, 但似乎并非如此
我什至不确定我需要查看哪个文件!
我找到的唯一解决方案是创建一个具有相同文件结构的新项目,并将引用和导入结构比作新的驱动器盘符。
然后用这个新的 proj 文件替换旧的 proj 文件并再次手动更新驱动器号以指向正确的位置
在我看来,这个错误实际上是错误的,并且是重新加载某些 Nuget 包导致损坏的副产品
但是,这远非最佳,所以如果有人有更好的解决方案而不涉及这样做,请随时 post!
当我尝试从 DotNet 4.5 项目迁移到 DotNet 4.6.2 项目时,我遇到了这个问题。当我从 package.config 迁移到 PackageReference.
时,这个问题得到了解决在项目解决方案中右击'References' -> select 'Migrate from package.config to PackageReference'.
我遇到了类似的问题。我通过删除 obj、bin 和 .vs 文件等缓存文件解决了这个问题。希望这对遇到类似问题的人有所帮助
我 运行 在尝试使用 Auth0 WinForm SDK 制作 MS Office 插件时遇到了这个问题。我得到的错误是:
C:\Program Files (x86)\Microsoft Visual Studio19\Professional\MSBuild\Microsoft\VisualStudio\v16.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets(226,9): error MSB4096: The item "C:\Users\XXXXXXX\.nuget\packages\system.runtime.windowsruntime.6.0\buildTransitive\net461\..\..\ref\netstandard2.0\System.Runtime.WindowsRuntime.dll" in item list "ReferencePath" does not define a value for metadata "CopyLocal". In order to use this metadata, either qualify it by specifying %(ReferencePath.CopyLocal), or ensure that all items in this list define a value for this metadata.
要解决此问题,我必须根据错误消息编辑引用文件中的第 226 行。在我的例子中,该文件是:
C:\Program Files (x86)\Microsoft Visual Studio19\Professional\MSBuild\Microsoft\VisualStudio\v16.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets
我更改了这一行:
<_CopyLocalFalseRefPaths Include="@(ReferencePath)" Condition="'%(CopyLocal)' == 'false'" />
为此:
<_CopyLocalFalseRefPaths Include="@(ReferencePath.CopyLocal)" Condition="'%(CopyLocal)' == 'false'" />
我从这里得到了这个解决方案:https://marcelegger.net/referencepath-does-not-define-a-value-for-metadata-copylocal
将@(ReferencePath)替换为@(ReferencePath.CopyLocal) 也适用于我,但由于授权问题,我不得不将文件保存在另一个目录中,并将其复制到正确的目录中。
这似乎是 msbuild 处理对空项目组中元数据的引用的方式的变化。编辑目标文件通常不切实际,但我有 .csproj 文件的解决方法。在开头附近添加以下内容:
<ItemDefinitionGroup>
<ReferencePath>
<CopyLocal>false</CopyLocal>
</ReferencePath>
</ItemDefinitionGroup>
这将 'CopyLocal' 定义为 'ReferencePath' 的默认元数据并且似乎对我有用。