Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Publish ASP.NET Core to IIS with GITLAB CI/CD

I can run the web application by using dotnet run on the .gitlab-ci.yml script.

stages:
    - build
build:
    stage: build
    before_script:
        - 'dotnet restore'
    script:
        - echo "Building the My Application"
        - "dotnet publish Eitms.Decoder.sln -c release"
        - "cd C:\\MyFolderContaints\\Eitms.Decoder.Backend"
        - "dotnet run"
    only:
        - release

But how I can publish into the IIS? anyone can show the step?

Thanks

UPDATE

After view the script from HERE, still not success yet. Did I do something wrong here?

stages:
    - build    
    - deploy
build:
    stage: build
    before_script:
        - 'dotnet restore'
    script:
        - echo "Building the app"
        - "dotnet publish Eitms.Decoder.sln -c release"
    artifacts:
        untracked: true
    only:
        - release

deploy_staging:
    stage: deploy
    script:
        - echo "Deploy to IIS"
        - "dotnet publish Eitms.Decoder.Backend\\Eitms.Decoder.Backend.csproj -c release -o C:\\Secret Path\\PRODUCTION\\Secret Project"
    dependencies:
        - build
    only:
        - release
like image 975
Azri Zakaria Avatar asked Jan 24 '19 09:01

Azri Zakaria


1 Answers

I don't know is it still actual or not and also i never used GitLab CI but looking on provided scripts i think you need just to copy (using CMD commands like xcopy) files into IIS folder after publish like when you want to do same using CMD .bat file

Steps

  1. publish project
  2. stop appPool
  3. copy files
  4. start appPool

e.g (just for example)

 dotnet publish "Eitms.Decoder.Backend\\Eitms.Decoder.Backend.csproj" -c release -o "C:\\Secret Path\\PRODUCTION\\Secret Project"
 appcmd stop apppool /apppool.name:"Secret Project APP POOL"
 xcopy "C:\\Secret Path\\PRODUCTION\\Secret Project" "C:\\inetpub\\wwwroot\\Secret Project" /s /e
 appcmd start apppool /apppool.name:"Secret Project APP POOL"
like image 172
Simon Avatar answered Nov 14 '22 20:11

Simon