Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile only the current project without checking referenced projects

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.

like image 639
Jan Zich Avatar asked May 10 '26 17:05

Jan Zich


2 Answers

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.

like image 58
Adriaan Stander Avatar answered May 12 '26 07:05

Adriaan Stander


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

like image 39
PanJanek Avatar answered May 12 '26 07:05

PanJanek