asp.net-core - 使用 ASP.NET Core 设置 azure-pipelines.yml "No web project was found in the repository"

标签 asp.net-core azure-devops azure-pipelines

我需要帮助来设置我的 azure-pipelines.yml 构建文件,因为我在任何地方都找不到任何好的教程、示例或其他类型的帮助。

我遵循 Microsoft https://docs.microsoft.com/en-us/azure/devops/pipelines/languages/dotnet-core?view=azure-devops 的本教程但是尽管他们提供了所有信息,但我仍然会出错。

azure-pipelines.yml

# ASP.NET Core
# Build and test ASP.NET Core projects targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core

trigger:
- master

pool:
  vmImage: 'Ubuntu-16.04'

variables:
  buildConfiguration: 'Release'

steps:
# - script: dotnet build --configuration $(buildConfiguration)
#   displayName: 'dotnet build $(buildConfiguration)'

- task: DotNetCoreInstaller@0
  inputs:
    version: '2.2.202' # replace this value with the version that you need for your project

- script: dotnet restore

- task: DotNetCoreCLI@2
  displayName: Build
  inputs:
    command: build
    projects: '**/*.csproj'
    arguments: '--configuration Release' # Update this to match your need

# do this after you've built your app, near the end of your pipeline in most cases
# for example, you do this before you deploy to an Azure web app on Windows
- task: DotNetCoreCLI@2
  inputs:
    command: publish
    publishWebProjects: True
    arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
    zipAfterPublish: True

- task: PublishBuildArtifacts@1
  inputs:
    ArtifactName: 'drop'

日志

enter image description here
##[section]Starting: DotNetCoreCLI
==============================================================================
Task         : .NET Core
Description  : Build, test, package, or publish a dotnet application, or run a custom dotnet command. For package commands, supports NuGet.org and authenticated feeds like Package Management and MyGet.
Version      : 2.150.1
Author       : Microsoft Corporation
Help         : [More Information](https://go.microsoft.com/fwlink/?linkid=832194)
==============================================================================
##[error]No web project was found in the repository. Web projects are identified by presence of either a web.config file or wwwroot folder in the directory.
##[error]Project file(s) matching the specified pattern were not found.
##[section]Finishing: DotNetCoreCLI

为什么会出现这些错误,我做错了什么?

附加信息
- 我可以从 Visual Studio 构建和发布到我的 Azure Web 应用程序。我的 API 正在运行。我只是不能把它作为 CI/CD 的一部分来做。
- 我不明白这个错误,因为我不明白为什么 DotNetCore 请求 web.config。

最佳答案

只有当我给它提供到我的 Web API 的路径时它才对我有用(将 **/*WebApi.csproj 设置为您自己的位置)。

但同样重要的是,我必须通过 向构建代理保证它不是网络项目|将 publishWebProjects 设置为 false .

- task: DotNetCoreCLI@2
  displayName: '📗📗📗 Publish 📗📗📗'
  inputs:
    command: publish
    projects: '**/*WebApi.csproj'
    publishWebProjects: False
    arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
    zipAfterPublish: True

:发布定义中是否需要表情符号?
一个 : 是的,表情符号是必要的。 (实际上,不。但它不会比必须将 publishWebProjects 设置为 false 更愚蠢。)

关于asp.net-core - 使用 ASP.NET Core 设置 azure-pipelines.yml "No web project was found in the repository",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55807281/

相关文章:

azure-pipelines - 在 Azure Pipelines yaml 文件中使用带有模板的嵌套参数

c# - ASP.NET Core 自定义验证属性本地化

c# - 如何解决 SQL 在代码优先迁移部署 Azure 期间找不到数据类型 BLOB

node.js - Azure 管道中的数据库迁移

azure - 在 Azure DevOps 管道中 check out 存储库时,Cypress 找不到服务器

python - azure 管道中的 pip install azure-functions 因 pip 验证任务而失败

c# - 如何使用 powershell 为构建服务器构建、发布 ASP.NET 核心项目?

c# - 将 ASP.NET Core 日志异步重定向到特定的 NLog 文件

c# - .NetFramework4.6.1 项目引用 .NetStandard2.0 上的 VSTS 构建任务失败

azure-devops - 使 aws-sdk node_module 可用于我的 Azure DevOps 扩展