[英]How to mark a file as an embedded resource in Visual Studio Code?
I'm writing ac# library, and trying out Visual Studio Code.我正在编写 ac# 库,并尝试使用 Visual Studio Code。 I'm generally liking what I'm seeing, but there are some things that I'm finding frustrating, that are really easy in Visual Studio standard version... for example, marking a file as an embedded resource.
我通常喜欢我所看到的,但有些事情让我感到沮丧,这在 Visual Studio 标准版本中真的很容易……例如,将文件标记为嵌入式资源。
Is this possible without some complicated voodoo?如果没有一些复杂的巫毒教,这可能吗? Is there an extension I need to install?
我需要安装扩展程序吗? It's not obvious to me.
这对我来说并不明显。
You have to edit the .csproj and change the node that represents your file to您必须编辑 .csproj 并将代表您的文件的节点更改为
<EmbeddedResource Include="Resources\yourEmbeddedResource.json" />
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.如果您的 c#-library-project 使用旧的项目类型,您应该为您的文件找到内容节点或无节点,因为此项目类型需要在 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)
你可能需要添加这个节点(记得把它包裹在一个项目组中)
Had the same issue, for more descriptive way is to add this to your csproj有同样的问题,更多描述性的方法是将它添加到你的 csproj
<ItemGroup>
<Content Include="Resources\resource.pfx" />
</ItemGroup>
You could also Remove and Re Add whenever you restore您还可以在恢复时删除和重新添加
<ItemGroup>
<Content Remove="Resources\resource.pfx" />
</ItemGroup>
<ItemGroup>
<Content Include="Resources\resource.pfx" />
</ItemGroup>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.