且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Visual Studio Code 中将文件标记为嵌入资源?

更新时间:2022-02-23 10:59:32

您必须编辑 .csproj 并将代表您的文件的节点更改为

You have to edit the .csproj and change the node that represents your file to

<EmbeddedResource Include="Resources\yourEmbeddedResource.json" />

如果您的 c#-library-project 使用旧的项目类型,您应该为您的文件找到一个内容节点或无节点,因为此项目类型需要在 csproj 中添加的所有文件.如果您有更新且更短的项目类型,您的文件可能不会被列出,因为这种类型会自动收集它的项目文件.你可能需要添加这个节点(记得把它包裹在一个 itemgroup 中)

If your c#-library-project uses the older project-type you should find a content-node or none-node for your file because this project type needs all files added in the csproj. If you have the newer and far mor shorter project-type your file may not be listed because this type auto collects it's project files. You may have to add this node (remember to wrap it inside an itemgroup)