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 buildwhich only compiles code, not publish deployable artifacts. Switch to usingdotnet publishinstead, with explicit parameters like:
Make sure thedotnet publish YourSolution.sln -c Release -o %system.teamcity.build.workingDir%\publishConfiguration namein your TeamCity build step is set toRelease(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 enterMyApp.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:
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.dir %system.teamcity.build.workingDir% /s - Test the command manually on the agent: Log into the TeamCity agent server, navigate to the build working directory, and run the
dotnet publishcommand 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 --versionin a command step to verify.
内容的提问来源于stack exchange,提问作者buckeyen8ive
相关产品推荐
相关产品推荐

