Azure Pipeline中DotNetCoreCLI任务变量识别异常:Clean任务正常但Restore任务报项目文件未找到
The issue here is the single quotes wrapping each project pattern in your multi-line projects input for the Restore task. When using YAML's multi-line pipe (|) syntax, each line is treated as a literal string. So instead of looking for **/Company.Web.csproj, Azure Pipelines is searching for '**/Company.Web.csproj' (including the single quotes), which doesn't exist in your repo.
Your Clean task works because it uses a single line—Azure Pipelines correctly parses the quoted string as a single pattern. But for multi-line entries, the quotes become part of the search pattern, leading to the "Project file(s) matching the specified pattern were not found" error.
Corrected Restore Task YAML
- task: DotNetCoreCLI@2 displayName: Restore inputs: command: custom custom: restore projects: | **/$(webProject).csproj **/$(dbProject).csproj
Why This Works
When you remove the single quotes from each line in the multi-line projects list:
- Each line is treated as an independent glob pattern.
- Azure Pipelines correctly substitutes the variables (
$(webProject)and$(dbProject)) into valid paths. - The glob patterns
**/Company.Web.csprojand**/Company.Database.csprojare properly recognized and matched against your project files.
You confirmed variables render correctly and replacing variables with literal text works—this fix aligns with that behavior by removing the unnecessary quotes that were breaking the pattern matching.
内容的提问来源于stack exchange,提问作者zep426

