Skip to content

Instantly share code, notes, and snippets.

Last active March 15, 2021 06:34
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Visual Studio Project Type to Replace the Solution Items Folder

Visual Studio Project Type to Replace the Solution Items Folder

When adding miscellaneous items to a visual studio solution, the files end up getting added under this Solution Items folder. What's particularly terrible about this is it's total disconnect from the underlying file system. These files define a shared project that will automatically add all items in its project directory to itself while maintaining the underlying file structure. Currently I'm using this for the convenience of being able to access related files, such as configuration and scripts, easily from within visual studio. I think that this type of project also allows every other project to reference these files, but I'll need to look into this bit more. I'll update this readme if any unexpected use cases are found.


When adding files via the file system visual studio doesn't immediately display them, which is lame. Reloading the project makes them visible, but obviously that defeats the entire purpose. We're trying to be lazy here damnit! It's a real shame since this exact same syntax works in normal c# projects, which I would use for this purpose, except for having to update the build configuration to remove it from the build. hmm... might be worth, I really don't want to have to reload each time I add a file -- it's silly.

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="">
<MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' &lt; '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<PropertyGroup Label="Configuration">
<Content Include="$(MSBuildThisFileDirectory)**\*.*" />
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="">
<PropertyGroup Label="Globals">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<PropertyGroup />
<Import Project="project-name.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment