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

时间:2018-03-25 18:38:39

标签: c# visual-studio-code

我正在编写一个c#库,并尝试使用Visual Studio Code。我一般都喜欢我所看到的东西,但有些东西我觉得很沮丧,在Visual Studio标准版本中非常容易...例如,将文件标记为嵌入式资源。

这可能没有一些复杂的伏都教吗?我需要安装扩展程序吗?这对我来说并不明显。

2 个答案:

答案 0 :(得分:2)

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

<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. 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)

答案 1 :(得分:0)

有同样的问题,更详细的方法是将其添加到您的 csproj

  <ItemGroup>
    <Content Include="Resources\resource.pfx" />
  </ItemGroup>

您也可以在恢复时删除和重新添加

  <ItemGroup>
    <Content Remove="Resources\resource.pfx" />
  </ItemGroup>
  <ItemGroup>
    <Content Include="Resources\resource.pfx" />
  </ItemGroup>