Friday, April 27, 2018

Visual Studio Tip–Add existing on steroids

If you want to add multiple files to a traditional Visual Studio project(not .NET Core), the default procedure is the following:

  • Right click on your project. Choose Add –> Existing Item…

image

  • Choose one or more items from the ‘Add Existing Item’ dialog and click Add.

image

A faster alternative instead of using ‘Add existing’ is the following trick:

  • Right click on your project and choose Unload project

image

  • Right click on the unloaded project and choose Edit csproj file.

image

  • Now add the following line to the MSBuild file:

<Compile Include="**\*.cs" />

  • Visual Studio will load all .cs files it found.

1 comment:

Filip Van Bouwel said...

Show all items in solution explorer, right click a folder (containing all *.cs files) and select 'include in project' also works.