.NET Core embedded resources + Gitlab: ERROR: No files to upload
.NET Core embedded resources + Gitlab: ERROR: No files to upload
我正在研究以下 .NET Core 解决方案:
我正在使用下面的 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
被定义为嵌入式资源,我试图强制将文件复制到输出,但我仍然遇到同样的错误。
我不确定为什么这个 post 被否决了,但有趣的是,Rider 2019.3.1 似乎有一个错误。
出现问题是因为即使文件在 Rider aka pascal 大小写中显示为 GetOrderRelatedInfoForAccountingEntryCreation.sql
,它实际上在磁盘上写为驼峰大小写(即 getOrderRelatedInfoForAccountingEntryCreation.sql
),请看图。
将磁盘上实际文件的名称调整为 pascal 后,一切正常。
我正在研究以下 .NET Core 解决方案:
我正在使用下面的 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
被定义为嵌入式资源,我试图强制将文件复制到输出,但我仍然遇到同样的错误。
我不确定为什么这个 post 被否决了,但有趣的是,Rider 2019.3.1 似乎有一个错误。
出现问题是因为即使文件在 Rider aka pascal 大小写中显示为 GetOrderRelatedInfoForAccountingEntryCreation.sql
,它实际上在磁盘上写为驼峰大小写(即 getOrderRelatedInfoForAccountingEntryCreation.sql
),请看图。
将磁盘上实际文件的名称调整为 pascal 后,一切正常。