3

Inside Visual Studio 2022, I have a "Shared Project" and I want to add a "Resource File (*.resx)", but it's not listed inside the available elements.

But if I try to add it to a "Windows Forms App", it works as well.

How can I add a "Resource File (*.resx)" to a "Shared Project"?

  • That's not possible. The intention of a shared project is [to share code](https://stackoverflow.com/questions/30634753/what-is-the-difference-between-a-shared-project-and-a-class-library-in-visual-st). Just code, such a project does not generate an assembly. Resources are embedded in an assembly. No assembly => no resources. – Hans Passant Oct 26 '22 at 20:51
  • Btw, you're asking [XY-questions](https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem). – Hans Passant Oct 26 '22 at 20:52
  • @HansPassant I would expect a resource file added to a shared project to be embedded as a resource in any project that referenced that shared project. Shared projects just add MSBuild items to the referencing project. – Drew Noakes Oct 29 '22 at 22:17

2 Answers2

0

The resources file for the shared project in VS2022 is different.

It starts with extension .resw. Look for it.

Right click project -> Add -> New item

You can find the file template .resw.

Pavan Chandaka
  • 11,671
  • 5
  • 26
  • 34
0

This is probably a bug in the item template for resource files. Can you use the "Provide feedback" link in VS and create a ticket about this so it'll get fixed? If you link it here I'll make sure it gets to the right team (I work at MS).

For a workaround, can you create a .resx file in a regular (non-shared) project, then move it to your shared project?

Drew Noakes
  • 300,895
  • 165
  • 679
  • 742
  • 1
    I've [forwarded](https://developercommunity.visualstudio.com/t/I-cant-add-a-Resource-File-resx-to/10182595?) this problem like you suggested. –  Oct 27 '22 at 10:10