I have a simple github actions deployments:
build:
..
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Build with dotnet
working-directory: ./${{ matrix.value }}
run: dotnet build --configuration Release
- name: dotnet publish
working-directory: ./${{ matrix.value }}
run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/${{ matrix.value }}/${{ env.APP_NAME }}
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
with:
name: .net-ui
path: ${{env.DOTNET_ROOT}}/${{ matrix.value }}/${{ env.APP_NAME }}
when in the next job I’m going to deploy these changes via:
- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: ${{ env.AZURE_APP_NAME }}
package: ${{ env.AZURE_APP_PACKAGE_PATH }}
UPDATE: I just noticed that wwwroot
folder with css and js files are copied to azure. My server side files placed in the C:homesitewwwroot
:
C:homesitewwwroot>ls
Humanizer.dll
Microsoft.AspNetCore.Razor.Language.dll
Microsoft.Bcl.AsyncInterfaces.dll
..
web.config
wwwroot
and inner wwwroot
folder is:
C:homesitewwwrootwwwroot>ls # pay attention on doubled `wwwroot`
UI.styles.css
css
favicon.ico
js
lib
however lib
folder doesn’t have all files:
C:homesitewwwrootwwwrootlib>ls
bootstrap
jquery
jquery-validation
jquery-validation-unobtrusive
where locally I have also microsoft
folder with signalr
dependencies (dependency files themself are not under git though, but microsoft
folder is under the git => all this behavior is default though). I assume I need to restore this somehow.
Another strange part is that some files presented locally (/lib/jquery/dist/jquery.min.js
), are not copied on the azure server even though the folder where they are placed has been copied:
C:homesitewwwrootwwwrootlibjquery>ls
LICENSE.txt # pay attention no "dist" folder
Given the above, these files are not visible in the browser and gives this error:
GET https://azureapp.eastus-01.azurewebsites.net/lib/jquery/dist/jquery.min.js
[HTTP/1.1 404 Not Found 351ms
How can I fix handling static files (css/js)? Any help would be appreciated.
2
Answers
Check
.csproj
File. below line shoud be includedGitHub Actions workflow uses the correct dotnet publish command
update your
.csproj
file look somewhat like thisThe issue is with your
yml
filedotnet publish
step.My
dotnet publish
looks like below:All the static files which are under
wwwroot
local folder are handled with thedotnet publish
and included by default in the deployed folder.My
.csproj
looks simple and is default.My complete
Workflow
file:dist
folder when I rundotnet publish
command in local as well.Deployment:
Able to access the files which are under
site/wwwroot/wwwroot/lib/jquery/dist
folder.Check this MSDoc to access any static files from a specific folder.