name: ASP.NET Core Web API Deploy
on:
push:
branches:
- master
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x # or the version you're using
- name: Build and publish
run: dotnet publish -c Release -o ./publish
- name: Stop IIS Website
run: |
Import-Module WebAdministration
Stop-WebSite -Name "practicecicdgithub" -ErrorAction SilentlyContinue
- name: Deploy to IIS
run: |
$publishFolder = "${{ github.workspace }}/publish"
$siteName = "practicecicdgithub"
$destinationFolder = "D:\PublishPracticeAPIs"
# Copy published files to the target folder
Copy-Item -Path $publishFolder -Destination $destinationFolder -Recurse -Force
# Import the WebAdministration module
Import-Module WebAdministration
# Create a new website
New-WebApplication -Name $siteName -Site 'Default Web Site' -PhysicalPath
$destinationFolder
- name: Recycle application pool
run: |
$appPoolName = "DefaultAppPool" # Replace with the name of your application pool
Invoke-Command -ScriptBlock { Import-Module WebAdministration; Restart-WebAppPool -Name
$args[0] } -ArgumentList $appPoolName
I have successfully built the pipeline in GitHub actions, which is also building successfully on each push in the master branch. But these above commands are not making publish folder and neither can I get DLLs. It means this is working fine but my code is not getting updated on the success build.

Vijay Pratap SinghPosted Jun 27, 2023, 10:44 AM
I have already verified the build output and copied files this is giving me the path that I am unable to find in my local system. I see that it is not creating any folder of the publish dlls.
It shows me this directory which is not even available in my system but getting published successfully.
Directory: D:\a\PracticeCICDGithub\PracticeCICDGithub\publish
Deepak RawatPosted Jun 27, 2023, 6:28 AM
Verify the build output: Before the
dotnet publishcommand, add a step to check if the build process is generating the necessary output files. You can add the following command after thedotnet publish -c Release -o ./publishstep:Verify the copy step: Ensure that the
Copy-Itemcommand is correctly copying the files from thepublishfolder to the destination folder. You can add a step to verify the copied files: