powershellbuildvisual-studio-2012post-build-eventbuild-events

Visual Studio 2012 slow build because of pre-build and post-build events


I have troubles with Visual Studio 2012 build, it runs extremely slow. It worked fine some time ago, I have no idea what happened. I enabled diagnostic build output, and saw this:

3>Target Performance Summary:
...
3>     1093 ms  ResolveComReferences                       1 calls
3>     2741 ms  ResolveAssemblyReferences                  1 calls
3>     3725 ms  CoreCompile                                1 calls
3>    314117 ms  PreBuildEvent                              1 calls
3>
3>Task Performance Summary:
...
3>     1092 ms  ResolveComReference                        1 calls
3>     2741 ms  ResolveAssemblyReference                   1 calls
3>     3724 ms  Csc                                        1 calls
3>    314117 ms  Exec                                       1 calls
3>
3>Build succeeded.
3>
3>Time Elapsed 00:05:22.93

The pre-build event:

Powershell -File "$(ProjectDir)Prepare4Tests.ps1"

The script file:

# Close all IE instances
if($env:COMPUTERNAME -ne 'W8ALEXAB')
{
    Get-Process | Where { $_.Name -Eq 'iexplore' } | Kill;
}

# Delete test files generated by agent that are more than 7 days old.
$paths = @("C:\Users\tsservice\AppData\Local\VSEQT\QTAgent", "C:\Windows\ServiceProfiles\NetworkService\AppData\Local\VSEQT\QTController");
foreach($path in $paths)
{
    if(Test-Path $path)
    {
        $items = @(Get-ChildItem $path | Where {$_.lastwritetime -lt (Get-date).AddDays(-8)});
        for($i = 0; $i -lt $items.Length; $i++)
        {
            $itemPath = join-path $path  $items[$i] -Resolve;
            "Deleting item: " + $itemPath;
            Remove-Item $itemPath -force;
        }
    }
}

Same problem with another project which contains post-build event which executes another powershell script.

If I launch the script directly from command prompt it runs fast with no problems. Also on rebuild, netstat.exe is always launching, no idea why. Any help will be greatly appreciated and any ideas are welcome!

P.S. Also other guys from our team don't have such problem, so it's definitely something on my side. Here is the full build log:

https://gist.github.com/4064296

Update 12/11/12: Tried to put checkpoints, as I said previously, powershell script itself is working like a charm

3>  Task Parameter:Command=Powershell -File "D:\Projects\NGNMS\Dev\NMSClient\NMSClient.UT\Prepare4Tests.ps1" (TaskId:72)
3>  Powershell -File "D:\Projects\NGNMS\Dev\NMSClient\NMSClient.UT\Prepare4Tests.ps1" (TaskId:72)
3>  Checkpoint 1 11/12/2012 13:08:07 (TaskId:72)
3>  Checkpoint 2 11/12/2012 13:08:07 (TaskId:72)
3>  Checkpoint 3 11/12/2012 13:08:07 (TaskId:72)
3>Done executing task "Exec". (TaskId:72)

Solution

  • Installed PowerShell 3.0, reinstalled VS 2012, nothing helped. So I just formatted disk C and installed Windows 8, now it works great :)