The “—output” option isn’t supported when building a solution.

huangapple go评论64阅读模式
英文:

The "--output" option isn't supported when building a solution

问题

以下是翻译好的部分:

  • 创建一个新的 .NET 7 Web Api App 在 Visual Studio 中。这将创建一个示例的 Weatherforecast API 应用程序,并且在 VS 中本地正常运行。
  • 创建一个新的 GitHub 存储库,并将我的 .sln 文件以及项目文件夹发布到这个存储库中。

在 Azure 中:

  • 在我的主资源组中创建一个新的 Web App 服务。

  • 在创建过程中,链接到我的 GitHub 帐户,并选择项目文件夹和 .sln 文件所在的存储库和主分支。

  • 现在存储库中创建了工作流文件,并且部署将启动,但几分钟后失败,显示以下错误:

    "—output" 选项不支持在构建解决方案时使用。

我看不到如何禁用此选项,下面是工作流文件的内容:

name: 构建和部署 ASP.Net Core 应用程序到 Azure Web App - muzztest

on:
  push:
    branches:
      - main
  workflow_dispatch:

jobs:
  build:
    runs-on: windows-latest

    steps:
      - uses: actions/checkout@v2

      - name: 设置 .NET Core
        uses: actions/setup-dotnet@v1
        with:
          dotnet-version: '7.x'
          include-prerelease: true

      - name: 使用 dotnet 进行构建
        run: dotnet build --configuration Release

      - name: dotnet 发布
        run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp

      - name: 上传部署工作的存档
        uses: actions/upload-artifact@v2
        with:
          name: .net-app
          path: ${{env.DOTNET_ROOT}}/myapp

  deploy:
    runs-on: windows-latest
    needs: build
    environment:
      name: 'Production'
      url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

    steps:
      - name: 从构建作业下载存档
        uses: actions/download-artifact@v2
        with:
          name: .net-app

      - name: 部署到 Azure Web App
        id: deploy-to-webapp
        uses: azure/webapps-deploy@v2
        with:
          app-name: 'muzztest'
          slot-name: 'Production'
          publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_4F1CE8C3BB3A4BA59C822347153C6D43 }}
          package: .

您要采取什么措施来解决上述问题?

英文:

I am attempting to deploy a simply Web Api App to Azure to help me familiarise myself with Azure services and Github Actions for deployment. Below are the steps I have undertaken

1 - Create a new .NET 7 Web Api App in Visual Studio. This creates a boilerplate Weatherforecast API app and runs as expected locally through VS.
2- Create a new github repository and publish my .sln file along with the project folder to this repository

In Azure :

  • Create new Web App service in my main resource group

  • During creation link to my github account and select the repository and main branch where my project folder and .sln file reside.

  • Now workflow file is created in the repository and deplyoment will initiate, but after a few minutes it fails with the error:

    The "--output" option isn't supported when building a solution.

I cannot see how to disable this option, below if the workflow file:

name: Build and deploy ASP.Net Core app to Azure Web App - muzztest

on:
  push:
    branches:
      - main
  workflow_dispatch:

jobs:
  build:
    runs-on: windows-latest

    steps:
      - uses: actions/checkout@v2

      - name: Set up .NET Core
        uses: actions/setup-dotnet@v1
        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

  deploy:
    runs-on: windows-latest
    needs: build
    environment:
      name: 'Production'
      url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

    steps:
      - name: Download artifact from build job
        uses: actions/download-artifact@v2
        with:
          name: .net-app

      - name: Deploy to Azure Web App
        id: deploy-to-webapp
        uses: azure/webapps-deploy@v2
        with:
          app-name: 'muzztest'
          slot-name: 'Production'
          publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_4F1CE8C3BB3A4BA59C822347153C6D43 }}
          package: .

What can I do to resolve the stumbling block above?

答案1

得分: 10

这是由于在构建解决方案时,.NET 7 支持的标志发生了变化。

现在,不再使用 -o DIR--output DIR,而需要使用 --property:PublishDir=DIR

请查看:https://learn.microsoft.com/en-us/dotnet/core/compatibility/sdk/7.0/solution-level-output-no-longer-valid 以获取更多信息。特别是建议操作部分会很有帮助。

英文:

This is due to changes in the supported flags for .NET 7 when building solutions.

Instead of -o DIR or --output DIR you now need to use --property:PublishDir=DIR

Please see: https://learn.microsoft.com/en-us/dotnet/core/compatibility/sdk/7.0/solution-level-output-no-longer-valid for further info. Especially the Recommended action section is helpful.

答案2

得分: 2

我成功解决了这个问题,至少在短期内,方法是在我的工作流 YAML 文件中指定一个较旧的 SDK 版本,如下所示:

- name: 设置 .NET Core
  uses: actions/setup-dotnet@v1
  with:
    dotnet-version: '7.0.103'
    include-prerelease: true

这样允许构建过程现在在 Azure Web 应用服务上成功完成。

英文:

I managed to fix this, at least for the short term by specifying an older sdk version in my workflow yaml file as follows:

  - name: Set up .NET Core
    uses: actions/setup-dotnet@v1
    with:
      dotnet-version: '7.0.103'
      include-prerelease: true

This allows the build process to now complete succesfully on Azure Web App services

huangapple
  • 本文由 发表于 2023年2月24日 02:33:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/75548945.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定