{"id":11087,"date":"2025-01-26T17:02:53","date_gmt":"2025-01-26T17:02:53","guid":{"rendered":"https:\/\/putridparrot.com\/blog\/?p=11087"},"modified":"2025-01-26T17:02:53","modified_gmt":"2025-01-26T17:02:53","slug":"nesting-files-in-visual-studio","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/nesting-files-in-visual-studio\/","title":{"rendered":"Nesting files in Visual Studio"},"content":{"rendered":"<p>It&#8217;s, sometimes, useful to nest files within our solution within Visual Studio 2022 &#8211; we see this automatically with appsettings.json or .designer.cs files etc. <\/p>\n<p>We can however make Visual Studio nest any files, so for example, create a file named .filenesting.json within your project&#8217;s folder, here&#8217;s an example which nests some  .generated.cs files which I am using as my custom auto-generated code<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n{\r\n  &quot;help&quot;: &quot;https:\/\/go.microsoft.com\/fwlink\/?linkid=866610&quot;,\r\n  &quot;root&quot;: true,\r\n\r\n  &quot;dependentFileProviders&quot;: {\r\n    &quot;add&quot;: {\r\n      &quot;extensionToExtension&quot;: {\r\n        &quot;add&quot;: {\r\n          &quot;.generated.cs&quot;: &#x5B;\r\n            &quot;.cs&quot;\r\n          ]\r\n        }\r\n      }\r\n    }\r\n  }\r\n}\r\n<\/pre>\n<p><em>Note: you will need to unload and reload your project to get Visual Studio to use the filenesting.<\/em><\/p>\n<p>In this example if you have a MyLib.cs file a MyLib.generated.cs file the generated one will shows as a child\/nested folder of the non-generated file.<\/p>\n<p>You can actually use Visual Studio itself to create these files by <\/p>\n<ul>\n<li>Within the solution explorer of VS 2022<\/li>\n<li>Click the drop down arrow on the File Nesting button (which looks like a folder nested tree)<\/li>\n<li>Click Add Custom Settings\/li>\n<li>Supply a name for your file settings<\/li>\n<li>If you select the Default template it will generate a file with lots of nestings that you can add to<\/li>\n<\/ul>\n<p>By default using Visual Studio will create your files with the Users AppData folders.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s, sometimes, useful to nest files within our solution within Visual Studio 2022 &#8211; we see this automatically with appsettings.json or .designer.cs files etc. We can however make Visual Studio nest any files, so for example, create a file named .filenesting.json within your project&#8217;s folder, here&#8217;s an example which nests some .generated.cs files which I [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[50],"tags":[],"class_list":["post-11087","post","type-post","status-publish","format-standard","hentry","category-visual-studio"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/11087","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=11087"}],"version-history":[{"count":5,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/11087\/revisions"}],"predecessor-version":[{"id":11242,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/11087\/revisions\/11242"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=11087"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=11087"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=11087"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}