Stylecop is interfering with EfBundle creation in docker image in gitlab CI - asp.net-core

I have stylecop configured in my project and when I run
RUN dotnet ef migrations bundle --project
{CSPROJ_PATH}.csproj -r alpine.3.7-x64 --self-contained --configuration Bundle -o /build/migrationbundle --verbose
to create ef bundle for my docker image in gitlab CI, I get stylecop errors and it fails to create EF bundle.enter image description here
How can I generate EF bundle while creating docker image in gitlab CI or how can I disable stylecop for only generating efbundle step in gitlab CI

Related

Apply EF migrations in GitHub workflow

I have a GitHub repository for my Asp Net Core project with EF Core 3.0. I added the following workflow to run each time on updating the develop branch
name: Develop Build
on:
push:
branches:
- develop
pull_request:
branches:
- develop
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v1
- name: Setup .NET Core
uses: actions/setup-dotnet#v1
with:
dotnet-version: 3.0.102-servicing-014397
- name: Build with dotnet
run: dotnet build --configuration Release
- name: Test with dotnet
run: dotnet test --configuration Release
- name: Update database
run: dotnet ef database update --c DataContext --p MyProj --s MyProjFactory
The last line returns with an error:
Could not execute because the specified command or file was not found.
Possible reasons for this include:
* You misspelled a built-in dotnet command.
* You intended to execute a .NET Core program, but dotnet-ef does not exist.
* You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
##[error]Process completed with exit code 1.
How can I apply the latest migrations to the target database using this workflow?
I also had to add commands to install EF tool and to restore all tools to make my workflow work correctly:
- name: Update database
run: |
dotnet tool install --global dotnet-ef
dotnet tool restore
dotnet ef database update -c DataContext -p MyProj -s MyProjFactory
env:
ASPNETCORE_ENVIRONMENT: Development
You might want to run your workflow in a windows environment, i.e. using windows-latest rather than ubuntu-latest. You can see the software installed on windows here.
For Windows Server 2019, it says:
PATH: contains location of dotnet.exe
There is no mention of dotnet being on the PATH for the Linux environments

dotnet publish with absolute path do not respect output

Repro
On windows with git bash:
I created some asp net core web app with razor pages. Now I would like to publish it to directory.
dotnet publish -o C:\temp\myApp
Temp directory exists, wheras MyApp not exists yet.
Problem
dotnet publish to ..\currentProjectDirectory\tempmyApp
Why its happens? I have also tried to run git bash with admin permissions, but it has not helped.
You use git bash. It means you should use linux-style path:
dotnet publish -o /c/temp/myApp

Continuous Deployment not working

I need to continually build a create-react-app application and deploy it to Amazon S3 bucket.
I have written the following CircleCi config.yml:
version: 2
jobs:
build:
docker:
- image: circleci/node:7.10
steps:
- checkout
- run: npm install
- run: npm run build
deployment:
prod:
branch: circle-config-test
commands:
- aws s3 sync build/ s3://http://www.typing-coacher.net.s3-website.eu-central-1.amazonaws.com/ --delete
What I think should happens:
I have a docker container, I install the application, build it and the files are resting ready in build folder.
I am running the command listed in CircleCi docs and the build files are moving from the docker machine to s3 bucket.
To deploy a project to S3, you can use the following command in the
deployment section of circle.yml:
aws s3 sync <path-to-files> s3://<bucket-URL> --delete
What actually happens:
Application is being install and build files are being created, but nothing happen with deployment. it doesn't even appear on the builds console.
What Am i missing?
disclaimer: CircleCI Developer Advocate
Everything from the deployment: line and down shouldn't be there. That's syntax for CircleCI 1.0 while the rest of your config file is CircleCI 2.0.
You can either:
Create a new step and check for the branch name with Bash. If it's circle-config-test, then run the deployment commands. You'll also need to install the AWS CLI in that build.
Using [CircleCI Workflows], create a deployment job with a branch filter for circle-config-test. You can use any image that contains the AWS CLI or install it yourself. The CI Builds: AWS Docker image contains this for you.

How to run build in local machine with drone.io

Does the build have to run on the drone.io server? Can I run the build locally? Since developers need to pass the build first before pushing code to github, I am looking for a way to run the build on developer local machine. Below is my .drone.yml file:
pipeline:
build:
image: node:latest
commands:
- npm install
- npm test
- npm run eslint
integration:
image: mongo-test
commands:
- mvn test
It includes two docker containers. How to run the build against this file in drone? I looked at the drone cli but it doesn't work in my expected way.
#BradRydzewski comment is the right answer.
To run builds locally you use drone exec. You can check the docs.
Extending on his answer, you must execute the command in the root of your local repo, exactly where your .drone.yml file is. If your build relies on secrets, you need to feed these secrets through the command line using the --secret or --secrets-file option.
When running a local build, there is no cloning step. Drone will use your local git workspace and mount it in the step containers. So, if you checkout some other commit/branch/whatever during the execution of the local build, you will mess things up because Drone will see those changes. So don't update you local repo while the build is running.

Simple(st) Dockerfile for Dotnet Core Aspnet 1.1

Why does my Dockerfile in OSX below get stuck on dotnet restore and does not make it to dotnet run?
(it works when I execute the commands manually)
Step 8 : RUN dotnet restore
---> Running in 3ef8b4c1d107
Dockerfile:
FROM microsoft/dotnet
VOLUME /Documents/Docker/dnc
EXPOSE 80
ENV "ASPNETCORE_URLS=http://+:80"
RUN mkdir app
RUN cd app
RUN dotnet new -t web
RUN dotnet restore
RUN dotnet run
With the help of another SO post I found out I was missing a WORKDIR.
The correct code is:
FROM microsoft/dotnet
VOLUME /Documents/Docker/dnc
EXPOSE 80
ENV "ASPNETCORE_URLS=http://+:80"
RUN mkdir app
# RUN cd app <- turned out was not necessary.
WORKDIR /app
RUN dotnet new -t web
RUN dotnet restore
RUN dotnet run