Monday, October 04, 2010

Manually adding Resources Files to Visual Studio Projects

Suppose you're moving files between projects and you have to move a Settings or Resource File.  If you drag these files between projects, you’ll notice that Visual Studio doesn’t preserve the relationships between the designer files:


Since these are embedded resources, you’ll need a few extra steps to get things sorted out:

  1. Right-click on the Project and choose Unload Project.  Visual Studio may churn for a few seconds.
  2. Once unloaded, Right-click on the project file and choose Edit <Project-Name>.
  3. Locate your resource files and setup them up to be embedded resources with auto-generated designer files:
  <None Include="Resources\Settings.settings">
  <Compile Include="Resources\Settings.Designer.cs">
  <EmbeddedResource Include="Resources\Resources.resx">
  <Compile Include="Resources\Resources.Designer.cs">


submit to reddit


Unknown said...

I think the correct way would be to include only the .resx file, set the file properties and let the VS regenerate the .designer.cs file automatically.

bryan said...

Sure, that works too. But you'll end up with Settings1.Designer.cs in source control.