TFS 2015构建失败求助:本地正常服务器报错退出码-1073741790
Hey there, let’s break down why your TFS 2015 build is failing with exit code -1073741790 (which maps to 0xC0000022—a permission/access-related error) while your code runs perfectly locally. Here are the most likely fixes to check:
Key Troubleshooting Steps
1. Verify Build Service Account Permissions
This is the top culprit for this error. TFS runs builds under a dedicated service account (often NT AUTHORITY\NETWORK SERVICE or a custom domain account), which usually has fewer permissions than your local user account:
- Confirm the service account has read access to your TFS source repository.
- Ensure it has read/write permissions to the build agent’s working directory (where sources are checked out and builds run).
- If your build accesses external resources (like databases, file shares, or private NuGet feeds), make sure the service account has the necessary permissions for those too.
2. Fix NuGet Package Restore Problems
From common TFS build issues, this error often pops up during package restore:
- Check that your build definition is configured with the correct NuGet sources, and the build service account can reach them (no firewall/proxy blocks for private feeds).
- Try manually running
nuget restoreon the build server using the build service account’s identity—this will reveal if there’s a permission issue with fetching packages.
3. Align Build Agent Environment with Local Setup
Mismatched environments between your local machine and the TFS build agent can cause silent failures:
- Confirm the build agent has the same .NET Framework version and Visual Studio version installed as your local machine (TFS 2015 defaults to VS 2015, so if you’re using a newer version locally, this could break things).
- Install any required SDKs, runtime libraries, or third-party tools on the build agent that your solution depends on.
- Double-check environment variables (like
PATHorMSBuildpaths) to ensure they match your local setup.
4. Resolve File Locking/Cleanup Issues
The 0xC0000022 error can also happen if files are locked or leftover from previous builds:
- Enable the Clean workspace option in your TFS build definition to ensure the working directory is wiped clean before each build.
- Check for lingering processes on the build agent that might be locking files from prior builds (kill any stuck MSBuild or devenv.exe processes).
5. Validate MSBuild Configuration
Make sure your TFS build uses the same MSBuild settings as your local build:
- Match the target platform (x86/x64) and build configuration (Debug/Release) between your local setup and the TFS build definition.
- If your solution has multiple projects, confirm the build order and project dependencies are correctly configured in TFS—sometimes automated build order differs from local builds.
Bonus Tip
Enable Diagnostic-level logging in your TFS build definition (under the "Logging" tab) and re-run the build. This will generate detailed logs that show exactly which step is failing, making it easier to pinpoint the root cause.
内容的提问来源于stack exchange,提问作者Prudhvi Bharadwaj

