Excellent question. This is a classic and often frustrating problem. The fact that all steps are slightly longer is a huge clue. It points away from a bug in a specific build script and towards a systemic, underlying issue with the server's environment.
Let's break down the investigation into a logical, layered approach, starting with the most likely culprits.
The Systematic Troubleshooting Plan
We'll work from the outside in, from the OS and hardware level to the build environment itself.
Layer 1: The Prime Suspects (Security & Power)
These are the most common causes for system-wide slowdowns on new server builds, especially with modern operating systems.
1. Antivirus / Security Software (90% Probability this is the issue)
Windows Defender on modern Windows Server is far more aggressive and capable than on older versions. It performs real-time scanning, behavior monitoring, and cloud-based analysis, which can significantly impact I/O-heavy operations like a build.
- Action: Configure exclusions in Windows Defender (or your third-party AV/EDR solution). You must exclude:
- Build Tool Executables:
msbuild.exe, dotnet.exe, csc.exe, vbc.exe, node.exe, npm.cmd, etc.
- Build Agent Directories: The root folder for your build agent (e.g.,
C:\agent\_work).
- Source Code Directories: The folder where your source code is checked out.
- Package Cache Directories:
- NuGet:
%USERPROFILE%\.nuget\packages
- npm:
%APPDATA%\npm-cache or C:\Users\<user>\AppData\Local\npm-cache
- Maven:
%USERPROFILE%\.m2
- How to Test: For a single, controlled test run, you can temporarily disable real-time protection to see if the build time returns to normal. Do not leave it disabled. If this fixes it, you have your culprit, and you just need to fine-tune the exclusions.
2. Power Plan
Servers often default to a "Balanced" power plan to save energy. For a build server, this is detrimental as it can prevent the CPU from running at its maximum clock speed.
- Action: Change the Power Plan to High Performance.
- Go to
Power Options in the Control Panel (or run powercfg.cpl).
- Select "High Performance". If it's not visible, click "Show additional plans".
- You can also do this via command line:
powercfg /s 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
Layer 2: The Core System (Hardware & Drivers)
You mentioned the "same configuration," but let's verify this at the deepest level.
1. Is it a Virtual Machine?
If this is a VM, the hypervisor configuration is critical.
- vCPU Allocation: Is the number of vCPUs the same? Are they backed by the same number of physical cores?
- Dynamic Memory: Is dynamic memory enabled? A build process can have spiky memory usage, and if the hypervisor is slow to allocate more RAM, it can cause slowdowns. Use a static memory allocation for the build server if possible.
- Host Contention: Is the new VM running on a more heavily loaded hypervisor host than the old one? Check the host's CPU and disk I/O load.
2. Storage I/O Performance
Builds are incredibly disk-intensive (reading thousands of source files, writing intermediate object files, linking binaries).
- Drivers: Ensure the latest vendor-specific storage controller drivers are installed. Don't rely on the default Microsoft-provided drivers, which can sometimes be less performant.
- Benchmarking: Run a disk benchmark tool like CrystalDiskMark or Microsoft's DiskSpd on both the old and new servers. Compare the read/write speeds and IOPS. This will give you objective data.
- Write Caching: Check that disk write caching is enabled on the volume where the build occurs. (In Disk Management -> Properties of the disk -> Policies tab).
3. CPU and Chipset Drivers
- Action: Install the latest chipset drivers directly from the hardware vendor (e.g., Intel, AMD) or server manufacturer (e.g., Dell, HP). This ensures the CPU, memory controller, and PCIe bus are all operating optimally.
Layer 3: The Operating System & Network
1. Performance Monitor (PerfMon)
This is your most powerful tool for diagnosis. You need to capture a baseline from both the old and new servers during a build.
- Action:
- Open Performance Monitor (
perfmon.exe).
- Create a new "Data Collector Set".
- Add the following counters to watch during a build:
Processor\% Processor Time (for _Total and all individual cores)
System\Processor Queue Length (A sustained value > 2 per core can indicate a CPU bottleneck)
Memory\Available MBytes (Is it running out of memory?)
Paging File\% Usage (Is it swapping to disk heavily?)
LogicalDisk\% Idle Time (for the build drive. If this is low, the disk is busy)
LogicalDisk\Avg. Disk Queue Length (A sustained value > 2 indicates a disk bottleneck)
Network Interface\Bytes Total/sec (To see if network activity is a factor)
- Run this capture during a full build on the new server and (if possible) the old server. Compare the graphs. You are looking for a clear bottleneck: CPU maxed out, disk queue length high, or available memory dropping to zero.
2. Network Performance
Builds frequently download dependencies from NuGet, npm, or other artifact repositories.
- DNS: Is DNS resolution slower? Use
Test-NetConnection <your-package-source> to check the time it takes to connect.
- Firewall/Proxy: Are there any differences in the Windows Firewall configuration or corporate proxy/firewall rules that the new server is subject to? Slower package restores would affect many steps.
- NIC Settings: Compare the advanced settings on the network adapter (Large Send Offload, Receive Side Scaling, etc.) between the two servers.
Layer 4: The Build Environment
1. Tool Versions
Double-check that the versions of all critical build tools are identical.
- .NET SDK version (
dotnet --version)
- MSBuild version
- Node.js version (
node -v)
- Java version (
java -version)
- Any other compilers or tools.
A minor version update in a tool could introduce performance regressions or have different default behaviors.
Summary Action Plan
- Start Here (Highest Likelihood): Configure Antivirus Exclusions and set the Power Plan to High Performance. Run a build. If the time is back to normal, you're done.
- Get Objective Data: If step 1 doesn't work, use Performance Monitor to capture a full build. Analyze the logs for CPU, Memory, or Disk bottlenecks.
- Benchmark the Disk: Run CrystalDiskMark or
diskspd on both servers to get a definitive comparison of I/O performance.
- Verify Drivers: Update storage and chipset drivers to the latest vendor versions, not the Microsoft in-box ones.
- Check the Network: Use
Test-NetConnection to your artifact repositories to rule out network/DNS latency.
- Compare Build Logs: Do a diff on the verbose build logs from the old and new servers. Look for any new warnings or steps that might give a clue.
By following this methodical process, you will be able to isolate the layer causing the system-wide slowdown and fix it. My money is on the antivirus/Defender configuration.