英文:
Azure deploy failed 'dotnet publish' project file does not exist
问题
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\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.
英文:
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\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.
答案1
得分: 0
以下更改解决了我的问题:
- 在
dotnet publish
的run
行上,将正斜杠更改为反斜杠 - 在整个文档中,将
${{env.DOTNET_ROOT}}
替换为${{env.GITHUB_WORKSPACE}}
- 在
dotnet publish
的run
行上,用引号括起路径
新的部分文件:
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
英文:
The following changes fixed my problem:
- Change forward slash to backslash on
run
line ofdotnet publish
- Swap
${{env.DOTNET_ROOT}}
with${{env.GITHUB_WORKSPACE}}
throughout document - Surround path with quotes on
run
line ofdotnet 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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论