Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tips and tricks for working with Microsoft Visual Studio solutions and project [closed]

Tags:

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?

like image 744
aku Avatar asked Sep 05 '08 14:09

aku


People also ask

How do I open recently closed in Visual Studio?

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.

What is the difference between a project and a solution in Visual Studio?

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.

Why is Visual Studio 2022 so slow?

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.

How do I clean up and rebuild a Visual Studio project?

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.


2 Answers

First rule of working with Visual Studio:

  • Install ReSharper
like image 65
Rinat Abdullin Avatar answered Oct 23 '22 02:10

Rinat Abdullin


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..."

like image 26
David Mohundro Avatar answered Oct 23 '22 02:10

David Mohundro