After answering on this question I thought it would be nice to collect some tips & tricks for working with MSVS solutions and projects.
Here is my list:
How to avoid saving new projects automatically to reduce garbage in file system.
Uncheck Tools->Options->Projects and Solutions->Save new projects when created
How to add common file to multiple projects without copying it to project’s directory.
Right click on a project, select Add->Existing Item->Add as link (press on small arrow on Add button)
How to add project to solution without including it in the build process
Right click on solution, select Add->New solution folder.
Right click on created folder, select Add->Add existing project
How to edit project file from Visual Studio?
Right click on project and select Unload Project, right click on unloaded project and select Edit. Or install Power Commands and select Edit Project File
How to group files in the project tree (like auto-generated files for WinForms controls)
Open project file for editing.
Change
<Compile Include="MainFile.cs" /> <Compile Include="SecondaryFile.cs" /> To <Compile Include="SecondaryFile.cs "> <DependentUpon> MainFile.cs </DependentUpon> </Compile>
Do you have anything else to add?
Quickly Reopen the Closed Files – Visual Studio 2022Right-click on Tab, and select “Restore Closed Tab“. Alternatively, you can use the keyboard shortcut Ctrl+K, Ctrl+Z to reopen the closed file. Restore Closed Tab will bring up the last closed files without losing your focus on any other part of Visual Studio IDE.
A project is contained within a solution. Despite its name, a solution isn't an "answer". It's simply a container for one or more related projects, along with build information, Visual Studio window settings, and any miscellaneous files that aren't associated with a particular project.
You might have extensions installed that slow Visual Studio down. For help on managing extensions to improve performance, see Change extension settings to improve performance. Similarly, you might have tool windows that slow Visual Studio down.
Choose Rebuild Solution to "clean" the solution and then build all project files and components. Choose Clean Solution to delete any intermediate and output files. With only the project and component files left, new instances of the intermediate and output files can then be built.
First rule of working with Visual Studio:
I'm a huge fan of using msbuild to build my solutions with the /m option so that it builds using multiple cores. It can drastically decrease your build time.
Scott Hanselman posted on how to add it to your tools list at http://www.hanselman.com/blog/HackParallelMSBuildsFromWithinTheVisualStudioIDE.aspx.
I usually just run 'msbuild /m' from the command prompt or PowerShell, though.
Another tip that is sometimes useful is taking advantage of the pre- and post-build events to add additional logic before or after a build. To see these, go to the Properties for a Project, click on the Compile tab, and then choose "Build Events..."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With