简体   繁体   中英

How to mark a file as an embedded resource in Visual Studio Code?

I'm writing ac# library, and trying out 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.

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

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

Had the same issue, for more descriptive way is to add this to your 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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM