如何在 Azure DevOps Pipeline 中指定解决方案文件
How to specify Solution file in Azure DevOps Pipeline
我在配置 Azure DevOps Dotnet 核心构建过程时遇到问题。
我有一个简单的 dotnet 核心项目,我试图在 Azure DevOps 环境中构建它。
该项目位于我的存储库中的子文件夹中,但我不知道如何指定管道应如何找到我的 csproj 文件。 The MSDN documentation 建议您可以指定它,但没有示例,我的所有尝试都遇到了错误。
使用标准 dotnet CLI 模板构建管道时,创建的 YAML 是:
# ASP.NET Core
# Build and test ASP.NET Core web applications targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://docs.microsoft.com/vsts/pipelines/languages/dotnet-core
pool:
vmImage: 'Ubuntu 16.04'
variables:
buildConfiguration: 'Release'
steps:
- script: dotnet build --configuration $(buildConfiguration)
displayName: 'dotnet build $(buildConfiguration)'
但是遇到错误:
MSBUILD : error MSB1003: Specify a project or solution file.
The current working directory does not contain a project or solution file.
上面链接的文档建议使用基于 "task" 的语法而不是脚本,我假设在文档中输入的顺序与下面列出的示例相同。
如果您使用 script
,请在 build
字后指定 csproj 文件:
- script: dotnet build myrepo/test/test.csproj --configuration $(buildConfiguration)
使用 Azure DevOps Pipeline 的最佳方式是为构建管道使用任务,在 Dotnet Core yaml 构建任务中,您在 inputs
部分指定文件:
- task: DotNetCoreCLI@2
inputs:
command: 'build'
projects: 'myrepo/test/test.csproj'
我在配置 Azure DevOps Dotnet 核心构建过程时遇到问题。
我有一个简单的 dotnet 核心项目,我试图在 Azure DevOps 环境中构建它。
该项目位于我的存储库中的子文件夹中,但我不知道如何指定管道应如何找到我的 csproj 文件。 The MSDN documentation 建议您可以指定它,但没有示例,我的所有尝试都遇到了错误。
使用标准 dotnet CLI 模板构建管道时,创建的 YAML 是:
# ASP.NET Core
# Build and test ASP.NET Core web applications targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://docs.microsoft.com/vsts/pipelines/languages/dotnet-core
pool:
vmImage: 'Ubuntu 16.04'
variables:
buildConfiguration: 'Release'
steps:
- script: dotnet build --configuration $(buildConfiguration)
displayName: 'dotnet build $(buildConfiguration)'
但是遇到错误:
MSBUILD : error MSB1003: Specify a project or solution file.
The current working directory does not contain a project or solution file.
上面链接的文档建议使用基于 "task" 的语法而不是脚本,我假设在文档中输入的顺序与下面列出的示例相同。
如果您使用 script
,请在 build
字后指定 csproj 文件:
- script: dotnet build myrepo/test/test.csproj --configuration $(buildConfiguration)
使用 Azure DevOps Pipeline 的最佳方式是为构建管道使用任务,在 Dotnet Core yaml 构建任务中,您在 inputs
部分指定文件:
- task: DotNetCoreCLI@2
inputs:
command: 'build'
projects: 'myrepo/test/test.csproj'