。NET Core嵌入式资源+ Gitlab:错误:没有要上传的文件

问题描述 投票:-1回答:1

我正在下面的.NET Core解决方案中工作:

.NET Core Solution

并且我正在使用下面的Gitlab CI定义:

.gitlab-ci.yml

image: docker:stable
services:
  - docker:dind

stages:
  - test
  - build
  - deploy-db
  - deploy

variables:
  DOCKER_REGISTRY: "our.registry.eu"
  IMAGE_NAME: "${DOCKER_REGISTRY}/membercreditor"

  # secrets are on GitLab environment variables (settings > ci/cd)

  RANCHER_ENV: 1a10
  RANCHER_STACK: api
  RANCHER_SVC: membercreditor

  RANCHER_DEV_KEY: a dev key
  RANCHER_DEV_URL: http://our.dev.rancher.io:8080
  RANCHER_PREPROD_KEY: a preprod key
  RANCHER_PREPROD_URL: http://our.preprod.rancher.io:8080
  RANCHER_PROD_KEY: a prod key
  RANCHER_PROD_URL: http://our.prod.rancher.io:8080

.test:
  stage: test
  image: mcr.microsoft.com/dotnet/core/sdk:3.1-alpine
  script:
    - dotnet test ./Rm.MemberCreditor.Api.Tests/ -l:junit /p:CollectCoverage=true /p:Include="[Rm.*]*" /p:CoverletOutput=./TestResults/
    - dotnet test ./Rm.MemberCreditor.Domain.Tests/ -l:junit /p:CollectCoverage=true /p:Include="[Rm.*]*" /p:CoverletOutput=./TestResults/ /p:MergeWith=../Rm.MemberCreditor.Api.Tests/TestResults/coverage.json
    - dotnet test ./Rm.MemberCreditor.IntegrationTests/ -l:junit /p:CollectCoverage=true /p:Include="[Rm.*]*" /p:CoverletOutput=./TestResults/ /p:MergeWith=../Rm.MemberCreditor.Domain.Tests/TestResults/coverage.json
  coverage: '/Total[ |]+(\d+[,.]\d+)%/'
  artifacts:
    reports:
      junit: ./*.Tests/TestResults/*.xml

.build:
  stage: build
  tags:
    - dind
  script:
    - docker build -t $IMAGE_NAME:$APP_VERSION -f Dockerfile .
    - docker login $DOCKER_REGISTRY -u svc_finance_revmgt -p $SVC_FINANCE_REVMGT_TOKEN
    - docker push $IMAGE_NAME:$APP_VERSION

.deploy-db:
  stage: deploy-db
  image: mcr.microsoft.com/dotnet/core/sdk:3.1-alpine
  script:
    - export CONNECTIONSTRINGS__MEMBERCREDITOR=$CONNECTIONSTRINGS__MEMBERCREDITOR
    - export SECRETS__CS_MEMBERCREDITOR=$SECRETS__CS_MEMBERCREDITOR
    - dotnet tool restore
    - dotnet ef database update -p ./Rm.MemberCreditor.Data.Migrations -s ./Rm.MemberCreditor.Api -v

.deploy:
  stage: deploy
  image: cdrx/rancher-gitlab-deploy
  script:
    - upgrade --rancher-key $RANCHER_KEY
      --rancher-secret $RANCHER_SECRET
      --rancher-url $RANCHER_URL
      --environment $RANCHER_ENV
      --stack $RANCHER_STACK
      --service $RANCHER_SVC
      --new-image $IMAGE_NAME:$APP_VERSION

###########################
### Merge Requests
###########################

test-merge-request:
  extends: .test
  only:
    refs:
      - merge_requests

###########################
### Integration
###########################

test-integration:
  extends: .test
  environment:
    name: integration
  only:
    - develop

build-integration:
  extends: .build
  environment:
    name: integration
  dependencies:
    - test-integration
  before_script:
    - APP_VERSION=latest-integration
  only:
    - develop

deploy-db-integration:
  extends: .deploy-db
  environment:
    name: integration
  dependencies:
    - build-integration
  before_script:
    - export ASPNETCORE_ENVIRONMENT=Integration
  only:
    - develop

deploy-integration:
  extends: .deploy
  environment:
    name: integration
  dependencies:
    - deploy-db-integration
  before_script:
    - APP_VERSION=latest-integration
    - RANCHER_KEY=$RANCHER_DEV_KEY
    - RANCHER_SECRET=$RANCHER_DEV_SECRET
    - RANCHER_URL=$RANCHER_DEV_URL
  only:
    - develop

###########################
### UAT
###########################

test-uat:
  extends: .test
  environment:
    name: uat
  only:
    - master

build-uat:
  extends: .build
  environment:
    name: uat
  dependencies:
    - test-uat
  before_script:
    - APP_VERSION=latest-uat
  only:
    - master

deploy-db-uat:
  extends: .deploy-db
  environment:
    name: uat
  dependencies:
    - build-uat
  before_script:
    - export ASPNETCORE_ENVIRONMENT=Uat
  only:
    - master

deploy-uat:
  extends: .deploy
  environment:
    name: uat
  dependencies:
    - deploy-db-uat
  before_script:
    - APP_VERSION=latest-uat
    - RANCHER_KEY=$RANCHER_PREPROD_KEY
    - RANCHER_SECRET=$RANCHER_PREPROD_SECRET
    - RANCHER_URL=$RANCHER_PREPROD_URL
  only:
    - master

###########################
### Production
###########################

build-prod:
  extends: .build
  environment:
    name: production
  before_script:
    - APP_VERSION=$CI_COMMIT_TAG
  only:
    - /^\d+.\d+.\d+$/
  except:
    - /^(?:[^m]|m[^a]|ma[^s]|mas[^t]|mast[^e]|maste[^r]).*@/

deploy-db-prod:
  extends: .deploy-db
  environment:
    name: production
  dependencies:
    - build-prod
  before_script:
    - export ASPNETCORE_ENVIRONMENT=Production
  only:
    - /^\d+.\d+.\d+$/
  except:
    - /^(?:[^m]|m[^a]|ma[^s]|mas[^t]|mast[^e]|maste[^r]).*@/

deploy-prod:
  extends: .deploy
  environment:
    name: production
  when: manual
  dependencies:
    - deploy-db-prod
  before_script:
    - APP_VERSION=$CI_COMMIT_TAG
    - RANCHER_KEY=$RANCHER_PROD_KEY
    - RANCHER_SECRET=$RANCHER_PROD_SECRET
    - RANCHER_URL=$RANCHER_PROD_URL
  only:
    - /^\d+.\d+.\d+$/
  except:
    - /^(?:[^m]|m[^a]|ma[^s]|mas[^t]|mast[^e]|maste[^r]).*@/

[当Gitlab运行test-merge-request时,出现以下错误:

Fetching changes with git depth set to 50...
00:02
Initialized empty Git repository in /builds/finance/products/revenuemgmt/modules/membercreditor/.git/
Created fresh repository.
From https://our.org/finance/products/revenuemgmt/modules/membercreditor
 * [new ref]         refs/merge-requests/38/head -> refs/merge-requests/38/head
 * [new ref]         refs/pipelines/355543       -> refs/pipelines/355543
Checking out 603e9a2c as refs/merge-requests/38/head...
Skipping Git submodules setup

$ dotnet test ./Rm.MemberCreditor.Api.Tests/ -l:junit /p:CollectCoverage=true /p:Include="[Rm.*]*" /p:CoverletOutput=./TestResults/
00:12
FSC : error FS0078: Unable to find the file 'Legacy/Queries/GetOrderRelatedInfoForAccountingEntryCreation.sql' in any of /builds/finance/products/revenuemgmt/modules/membercreditor/Rm.MemberCreditor.Data [/builds/finance/products/revenuemgmt/modules/membercreditor/Rm.MemberCreditor.Data/Rm.MemberCreditor.Data.fsproj]

Uploading artifacts...
00:02
WARNING: ./*.Tests/TestResults/*.xml: no matching files 
ERROR: No files to upload                          
ERROR: Job failed: exit code 1

[GetOrderRelatedInfoForAccountingEntryCreation.sql被定义为嵌入式资源,我试图强制将文件复制到输出,但是仍然遇到相同的错误。

.net-core f# gitlab embedded-resource
1个回答
0
投票

我不确定为什么这篇文章被否决,但有趣的是,似乎Rider 2019.3.1中存在错误。

出现此问题是因为即使文件在Rider aka pascal情况下显示为GetOrderRelatedInfoForAccountingEntryCreation.sql,但实际上却是作为驼峰式情况(即getOrderRelatedInfoForAccountingEntryCreation.sql)写在磁盘上的,如图所示。

一旦将名称调整为磁盘上实际文件的pascal,一切正常。

© www.soinside.com 2019 - 2024. All rights reserved.