Question

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)
Was it helpful?

Solution 2

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

OTHER TIPS

I'd suggest that you add some simple tracing to try and work out where the problem is.

But put a Write-Host "Checkpoint 1 $(get-date -DisplayHint Time)" right at the start of the script and then put others in between the key sections.

My guess is that the problem is that Get-Process takes longer than you expect. One possibility is that loading you default profile/modules is taking that long.

For what it is worth, we use powershell scripts in MSBuild/VS projects and don't have this sort of problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top