I have a .NET API running on Azure that I am attempting to upgrade from .NET Core 3.1 to .NET 7.0. When I attempted to deploy my updated .csproj file with the <TargetFramework>
update and <PackageReference>
version updates, the deploy to Azure (via push to remote master branch) failed on the dotnet publish
step. I recently updated my GitHub action yaml file to update actions/setup-dotnet@v3
and actions/checkout@v3
and the jobs section of that file now looks like this
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Set up .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.x'
include-prerelease: true
- name: Build with dotnet
run: dotnet build --configuration Release
- name: dotnet publish
run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v2
with:
name: .net-app
path: ${{env.DOTNET_ROOT}}/myapp
The error I get in Azure is the following
Run dotnet publish -c Release -o C:\Program Files\dotnet/myapp
dotnet publish -c Release -o C:\Program Files\dotnet/myapp
shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
env:
DOTNET_ROOT: C:\Program Files\dotnet
MSBuild version 17.5.1+f6fdcf537 for .NET
MSBUILD : error MSB1009: Project file does not exist.
Switch: Files\dotnet/myapp
Error: Process completed with exit code 1.
I am very inexperienced with dev ops and I would be happy to provide more detail if needed.
The following changes fixed my problem:
run
line of dotnet publish
${{env.DOTNET_ROOT}}
with ${{env.GITHUB_WORKSPACE}}
throughout documentrun
line of dotnet publish
New file partial:
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Set up .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.x'
include-prerelease: true
- name: Build with dotnet
run: dotnet build --configuration Release
- name: dotnet publish
run: dotnet publish -c Release -o "${{env.GITHUB_WORKSPACE}}\myapp"
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
with:
name: .net-app
path: ${{env.GITHUB_WORKSPACE}}\myapp