Dot-Net-Core

如何在 Azure DevOps Pipeline 中指定解決方案文件

  • September 17, 2018

我在配置 Azure DevOps Dotnet 核心建構過程時遇到問題。

我有一個簡單的 dotnet 核心項目,我試圖在 Azure DevOps 環境中建構它。

該項目位於我的倉庫中的一個子文件夾中,但我無法弄清楚如何指定管道應該如何找到我的 csproj 文件。 MSDN 文件建議您可以指定它,但沒有範例,我的所有嘗試都遇到了錯誤。

使用標準 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.

上面連結的文件建議使用基於“任務”的語法而不是腳本,我假設在文件中輸入的列出順序與下面列出的範例相同。

如果使用 ,則script在單詞後指定 csproj 文件build

- 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'

引用自:https://stackoverflow.com/questions/52364661