简体   繁体   English

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

[英]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.

相关问题 是否可以通过代码中的名称引用Visual Studio中的嵌入式文件资源? - Can an embedded file resource in Visual Studio be referenced by name in code? 在Visual Studio中使用嵌入式资源的代码或命令 - Code or command to use embedded resource in Visual Studio 如何以编程方式使自动生成的文件成为Visual Studio中的嵌入式资源? - How to programmatically make an autogenerated file an embedded resource in visual studio? 大文件作为Visual Studio 2012中的嵌入式资源 - Large file as embedded resource in Visual Studio 2012 如何在visual studio中添加资源文件 - How to add a resource file in visual studio 如何在Visual Studio 2015中使用资源文件 - How to use a resource file in Visual Studio 2015 强制Visual Studio重建嵌入式资源 - Force Visual Studio Rebuild on Embedded Resource Changed Visual Studio 插件显示资源文件中的文本而不是代码 - Visual Studio plugin to show the text from a resource file instead of the code 如何使用 Visual Studio Code 在 dotnet 构建中包含资源文件 - How to include Resource files in dotnet build with Visual Studio Code 如何使用Visual Studio项目资源中的Excel文件 - How to use Excel file from visual studio project resource
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM