【发布时间】:2020-01-31 12:17:57
【问题描述】:
我有一个包含内容文件的 nuget。它是一个json file,并在打包nuget 时在nuspec 文件中表示。
在常规 wpf 应用程序中安装 nuget 时,我遇到了几个构建错误。看来Visual Studio 正在尝试编译.json file。想知道是否有人知道可能导致这种情况的原因。正如您将在 nuspec sn-p 中看到的,我在 nuspec 中有 BuildAction=None
ContentFile.json(1,1,1,2):错误 CS1022:类型或命名空间定义,或预期文件结尾
ContentFile.json(4,16,4,26):错误 CS1001:需要标识符
ContentFile.json(4,37,4,45):错误 CS1001:需要标识符
【问题讨论】:
-
为此,您应该在
<file>节点下添加<file src="**\Resources\ContentFile.json" (the reative path of the file in the current project folder) target="ContentFiles/any/any" />。此外,<contentfiles>节点下的files include="xxxxx"是相对于nuget 包内contentFiles 文件夹的路径。所以在这一点上,应该是<files include="any/any/ContentFiles.json" buildAction="None" copyToOutput="true" flatten="false" /> -
那么在你打包这个项目然后安装到另一个项目之后,别忘了clean the nuget cache。
-
嗨,这个问题有更新的吗?请按照我的指导解决您的问题,如果对您有帮助,请考虑accepting it。如果您的问题仍然存在,请随时告诉我们。这只是一个提醒。
标签: json nuget nuget-package visual-studio-2019