You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

DevOps:TeamCity构建.NET Core应用遇到问题求助

Troubleshooting .NET Core Build Issues in TeamCity (Deploying to Octopus)

Hey there, let's work through this TeamCity + .NET Core build problem step by step— I've dealt with similar quirks before, so here's what I'd check first:

1. Fixing "Build succeeds but no artifacts generated" when using .sln

  • Verify build configuration and command: By default, TeamCity might run a basic dotnet build which only compiles code, not publish deployable artifacts. Switch to using dotnet publish instead, with explicit parameters like:
    dotnet publish YourSolution.sln -c Release -o %system.teamcity.build.workingDir%\publish
    
    Make sure the Configuration name in your TeamCity build step is set to Release (not Debug, which doesn't generate optimized publish artifacts).
  • Check project output paths: Open your .NET Core project properties (in Visual Studio), go to the Build tab, and confirm the "Output directory" is set to a predictable location. Sometimes custom paths can cause TeamCity to miss the generated files.
  • Ensure artifacts are published in TeamCity: After building, you need to add an "Artifact paths" entry in your build configuration to tell TeamCity which files to capture. For example, if you published to publish/**, add that path so TeamCity picks up all the publish artifacts.

2. Fixing "MSBUILD : error MSB1009: Project file does not exist" when using .csproj

  • Double-check the project file path: TeamCity uses the agent's working directory as the base path, so make sure your csproj path is relative to that. If your project lives in src/MyApp/MyApp.csproj, don't just enter MyApp.csproj—use the full relative path: src/MyApp/MyApp.csproj.
  • Validate the file exists on the agent: Add a temporary "Command Line" build step before the .NET Core step to run:
    dir %system.teamcity.build.workingDir% /s
    
    This will list all files in the working directory (and subfolders) so you can confirm the csproj is actually present. Sometimes VCS checkout rules might exclude the project folder, or a branch mismatch causes missing files.
  • Test the command manually on the agent: Log into the TeamCity agent server, navigate to the build working directory, and run the dotnet publish command directly with the csproj path. If this fails, the issue is with the project or agent environment, not TeamCity configuration.

Bonus Troubleshooting Tips

  • Enable verbose logs: In your TeamCity build configuration, turn on "Verbose" logging for the build steps. This will show detailed MSBuild output, which often reveals hidden path issues or configuration problems.
  • Confirm .NET SDK version: Even though you said the agent has the SDK configured, double-check that the version matches what your project requires. Use dotnet --version in a command step to verify.

内容的提问来源于stack exchange,提问作者buckeyen8ive

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 06:49:59