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

GitLab构建.NET Core 7 MVC应用时Artifacts未找到问题排查

解决GitLab构建.NET Core 7 MVC应用时的Artifacts路径警告问题

问题原因

GitLab CI的artifacts.paths要求使用相对于当前工作目录的路径,你配置的$CI_PROJECT_DIR/bin/Release/net7.0是绝对路径,相当于在工作目录(/builds/xmoor/Xmoor-Payroll-Management)下重复查找完整绝对路径,自然找不到匹配文件。

解决方案

1. 修正Artifacts路径为相对路径

将artifacts.paths中的绝对路径改为相对路径,去掉$CI_PROJECT_DIR前缀:

build:
  stage: build
  image: mcr.microsoft.com/dotnet/sdk:7.0
  script:
    - dotnet build $solution --configuration Release --no-restore
  artifacts:
    paths:
      - bin/Release/net7.0

2. 验证Build输出路径是否正确

如果修改路径后仍有问题,可在脚本中添加目录检查命令,确认编译后的文件是否生成在预期位置:

build:
  stage: build
  image: mcr.microsoft.com/dotnet/sdk:7.0
  script:
    - dotnet build $solution --configuration Release --no-restore
    # 查看编译输出目录的文件结构
    - ls -la bin/Release/net7.0
    # 查找指定目录下的编译产物
    - find . -name "*.dll" -path "*bin/Release/net7.0*"
  artifacts:
    paths:
      - bin/Release/net7.0

3. 确认$solution变量的正确性

确保$solution变量指向正确的项目或解决方案文件,若变量未正确定义,可直接写死路径避免问题:

script:
  - dotnet build Xmoor-Payroll-Management.sln --configuration Release --no-restore

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.27 04:12:37