【问题标题】:Setup of azure-pipelines.yml "No web project was found in the repository" with ASP.NET Core使用 ASP.NET Core 设置 azure-pipelines.yml “在存储库中未找到 Web 项目”
【发布时间】:2019-04-23 08:38:15
【问题描述】:

我需要帮助来设置我的 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'

日志

##[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.config 文件。
  • 好吧,这里 web.config 不存在,但我不想要它。 ASP.NET Core,我不需要。所以我没有得到错误,因为这不是错误......对吗?不对?那么我错过了什么?而且,顺便说一句,我刚刚再次检查,我的工件中有一个 web.config :-s

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


【解决方案1】:

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

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

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

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

【讨论】:

  • 我不知道你可以把表情符号放进去,但谢谢你?
猜你喜欢
  • 2022-07-07
  • 2019-09-11
  • 1970-01-01
  • 2017-08-15
  • 1970-01-01
  • 2018-03-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多