.net core 如何在Azure DevOps管道中指定解决方案文件
我在配置Azure DevOps Dotnet核心构建过程时遇到问题 我有一个简单的dotnet核心项目,我正试图在azuredevops环境中构建它 该项目位于我的repo中的子文件夹中,但我无法确定如何指定管道如何查找我的csproj文件。建议您可以指定它,但没有示例,我的所有尝试都会遇到错误 使用标准dotnet CLI模板构建管道时,创建的YAML为:.net core 如何在Azure DevOps管道中指定解决方案文件,.net-core,azure-devops,azure-pipelines,azure-pipelines-build-task,.net Core,Azure Devops,Azure Pipelines,Azure Pipelines Build Task,我在配置Azure DevOps Dotnet核心构建过程时遇到问题 我有一个简单的dotnet核心项目,我正试图在azuredevops环境中构建它 该项目位于我的repo中的子文件夹中,但我无法确定如何指定管道如何查找我的csproj文件。建议您可以指定它,但没有示例,我的所有尝试都会遇到错误 使用标准dotnet CLI模板构建管道时,创建的YAML为: # ASP.NET Core # Build and test ASP.NET Core web applications target
# 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.
上面链接的文档建议使用基于“任务”的语法,而不是脚本,我假设在文档中输入的顺序与下面列出的示例相同。如果使用
脚本
则在构建
字后指定csproj文件:
- script: dotnet build myrepo/test/test.csproj --configuration $(buildConfiguration)
使用Azure DevOps管道的最佳方法是为构建管道使用任务,在Dotnet Core yaml构建任务中,您可以在输入
部分指定文件:
- task: DotNetCoreCLI@2
inputs:
command: 'build'
projects: 'myrepo/test/test.csproj'
谢谢我认为任务看起来是一个更好的选择,但是Azure Devops上的内置管道设计器出于某种原因使用dotnet构建脚本创建了一个YAML。在您的示例中,我已使用DotnetCoreCLI任务成功创建了一个构建任务。