从Azure DevOps中的dotnet pack任务中排除项目 [英] Excluding projects from dotnet pack task in Azure DevOps

查看:44
本文介绍了从Azure DevOps中的dotnet pack任务中排除项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个VS解决方案文件(.sln),其中包含.net标准库和测试项目.现在,该项目有一个针对.net Framework 4.7.2的集成测试项目.

我当前的构建管道执行以下操作网络构建网络包点网推送

使用dotnet包,我试图排除项目Integration.Tests.csproj.

我当前的文件夹结构如下

  CompanyName.Service \ CompanyName.Service.csprojCompanyName.Data \ CompanyName.Data.csprojIntegration.Tests \ Integration.Tests.csproj 

根据包含/排除路径中的帮助器工具提示,我们可以像以下操作一样

  **/*.csproj;-:**/*.Tests.csproj 

但是dotnet pack任务并没有忽略Integration.Tests.csproj.它尝试打包,但失败.我不确定自己做错了什么,或者这是否与任务有关.到目前为止,我还没有找到任何已知的问题.

注意:在将该项目包含在我的解决方案中之前,管道可以很好地将项目打包并发布到nuget.

解决方案

如果在Azure Devops中使用dotnet任务的版本(2.x),则应使用而不是<代码>-:.

因为排除模式已更改.这些模式已在NuGet任务的版本2中更新;如果您的模式包含-:,请改用:

作为测试,它在我这边工作正常.

我的文件夹设置:

注意:如果您仍然对该任务有疑问,请检查该错误是否是由于运行该任务时未打包而引起的.或者,您可以选择选项不构建:

但是您应该在打包项目之前先构建项目.

I have an VS solution file (.sln) which consists .net standard libraries and test projects. Now the project has an Integration test project that is targeted against .net Framework 4.7.2.

My current build pipeline does the following dotnet build dotnet pack dotnet push

With the dotnet pack, I am trying to excldude the project Integration.Tests.csproj.

My current folder structure looks like the following

CompanyName.Service\CompanyName.Service.csproj
CompanyName.Data\CompanyName.Data.csproj
Integration.Tests\Integration.Tests.csproj

According to the helper tooltip in the path to include/exclude we can do it like the following

**/*.csproj;-:**/*.Tests.csproj

However the dotnet pack task simply is not ignoring the Integration.Tests.csproj. It tries to pack it and it fails. I'm not sure what I am doing wrong or if this is an issue with the task. I haven't been able to locate any known issues on this so far.

Note: Prior to having that project in my solution, the pipeline was working fine with the projects being packed and published to nuget.

解决方案

If you are using the version (2.x) of the dotnet task in Azure Devops, you should use ! instead of -:.

Because the exclude pattern has changed. That these patterns were updated in version 2 of the NuGet task; if you have a pattern that contains -:, use ! instead:

Pack NuGet packages

As test, it works fine on my side.

My folder setup:

Note: If you still have issue with that task, please check the if the error comes from build not packing when you running that task. Or you can select the option Do not build:

But you should build the project before you packing it.

这篇关于从Azure DevOps中的dotnet pack任务中排除项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆