views:

74

answers:

2

When I hit Compile Project (SHIFT+F6) in Visual Studio 2008, Visual Studio always seems to check the referenced projects/libraries first. It is understandable, because they have to be compiled first, but currently I happen to spend most of my time working actively only with the top level project (it's an ASP.NET application referencing a number of libraries), and the referenced libraries are sitting there and don't need to be checked every time.

When I do a full rebuild, it takes about 15 seconds (on a warmed up machine). When I make a change in the ASP.NET project, Visual Studio spends about 10 seconds just checking the referenced libraries.

Is there a way to "tell" Visual Studio: "Please believe me, I know the referenced libraries are there, don’t check them"? in which case I would be fine with getting compilation errors in case my assumption was wrong.

Note: I suspect that C/C++ developers could be amused by this because they usually measure compilation times in minutes and often in hours. On the other hand, in C/C++ one can compile only a single file.

+3  A: 

Right click the solution, select properties.

Under Configuration Properties->Configuration you can select which projects should be built.

You can switch off the items you do not want to build. This is a bit more permanent solution and might cause some pains later, when you do make changes to other projects and forget to recompile/switch build back on.

Sorry, i forgot that i had these in my Macro IDE

Sub SetAllCompile()
        Dim scs As EnvDTE.SolutionContexts = DTE.Solution.SolutionBuild.ActiveConfiguration.SolutionContexts
        Dim sc As EnvDTE.SolutionContext
        For Each sc In scs
            sc.ShouldBuild = True
        Next
    End Sub

Sub SetNoneCompile()
    Dim scs As EnvDTE.SolutionContexts = DTE.Solution.SolutionBuild.ActiveConfiguration.SolutionContexts
    Dim sc As EnvDTE.SolutionContext
    For Each sc In scs
        sc.ShouldBuild = False
    Next
End Sub

Sub SetInvertCompile()
    Dim scs As EnvDTE.SolutionContexts = DTE.Solution.SolutionBuild.ActiveConfiguration.SolutionContexts
    Dim sc As EnvDTE.SolutionContext
    For Each sc In scs
        sc.ShouldBuild = Not sc.ShouldBuild
    Next
End Sub

Sub SetSelectedCompile()
    Dim scs As EnvDTE.SolutionContexts = DTE.Solution.SolutionBuild.ActiveConfiguration.SolutionContexts
    Dim sc As EnvDTE.SolutionContext
    For Each sc In scs
        sc.ShouldBuild = False
    Next
    Dim selItem As SelectedItem
    For Each selItem In DTE.SelectedItems
        For Each sc In scs
            Try
                If (sc.ProjectName = selItem.Project.UniqueName) Then
                    sc.ShouldBuild = True
                End If
            Catch
            End Try
        Next
    Next
End Sub

You can use thes in the Macro IDE, add them to a custom tool bar and use with the solution explorer.

astander
+1 You could also create a custom configuration to allow you to quickly switch between compiling the top project + all of the sub projects
Jared Russell
True. I forgot about this option. But as I said, it could be a bit painful to create and manage configurations for all projects in a solution.
Jan Zich
Try the MacroIDE, you can use this from the solution exploere. I can send you a text file containing this if you require.
astander
+1  A: 

You can compile the whole solution, and then unload libraries projects (right click menu on the project in solution explorer).

PanJanek
Amazing, this actually works! I would have never guessed. I usually unload libraries which I don’t need, but I have always diligently kept libraries which were referenced.
Jan Zich