从Azure构建管道中排除项目 [英] Exclude projects from Azure build pipeline

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

问题描述

我有一个解决方案,其中有许多未完成的项目.当我在本地构建解决方案时,显然没有构建卸载的项目.在Configuration Manager中,我什至无法选择已卸载项目的配置,平台,构建和部署选项.

现在,我已经创建了一个Azure管道,该管道还可以构建解决方案.但是卸载的项目仍在构建中.

如何排除正在构建管道中的项目?

解决方案

现在,我已经创建了一个Azure管道,该管道还可以构建解决方案.但是卸载的项目仍在构建中.

Azure Devops Pipeline和VS IDE都将调用 msbuild.exe 进行构建.使用msbuild构建解决方案时,它实际上正在运行命令 msbuild xx.sln/t:build ... .

检查 xx.sln 文件(解决方案文件)的内容,我们可以发现它定义了有关解决方案中项目的定义.这就是为什么如果您构建解决方案,则会构建所有这些项目.这是构建整个解决方案时的预期行为.样本.sln文件:

在构建整个解决方案时,将卸载的项目排除在外是VS IDE的魔力.IDE将检查已卸载的项目,并在构建整个解决方案时将其跳过,它具有以下优点:IDE中的正在卸载项目行为不会修改您的解决方案文件.(对于 Git版本控制下的解决方案很重要).

总结:预计构建解决方案将构建所有项目.当我们在VS中卸载项目时,此操作不会影响我们的源解决方​​案文件或项目文件.VS将自动跳过卸载的项目,这是IDE的独特功能.(卸载是VS中的 UI操作,对.sln/.xxproj文件没有影响)

要排除要在Azure Devops中构建的项目,请执行以下操作:

1.在构建整个解决方案时指定要构建的项目.(它不会更改任何文件,因此不会影响版本控制)

您可以检查

2. 从解决方案配置中排除项目(不建议),或者创建不包含特定项目的新配置(推荐).解决方案配置是在解决方案文件(sln)中定义的,因此这种方式将对Source Control产生影响.

从解决方案配置中排除项目(不推荐):

创建一个排除特定项目的新配置:

相关文档

我们可以使用 customrelease 配置在devops中构建解决方案,该配置排除了 release 配置,而排除了 ProjectA ProjectB 其中包含所有项目.

所有这些变通办法在发布前都已经在我这边进行了测试.

I have a solution which I have a number of unloaded projects. When I build the solution locally the unloaded projects are obviously not built. In Configuration Manager, I can't even select configuration, platform, build and deploy options for the unloaded projects.

Now I have created an Azure Pipeline which also builds the solution. But the unloaded projects are still being built.

How can I exclude building projects in my pipeline?

解决方案

Now I have created an Azure Pipeline which also builds the solution. But the unloaded projects are still being built.

Both Azure Devops Pipeline and VS IDE would call msbuild.exe to build. When building a solution using msbuild, it actually is running command msbuild xx.sln /t:build ....

Check the content of xx.sln file (solution file) we can find it defines definitions about the projects within the solution. That's why if you build the solution, all these projects will be built. This is expected behavior when building whole solution. Sample .sln file:

And it's VS IDE's magic to exclude unloaded projects when building whole solution. The IDE will check the unloaded projects and skip them when building whole solution, it has advantage that the unloading project behavior in IDE won't modify your solution file. (It's important for solution under Git version control).

To sum up: It's expected that building solution will build all projects. When we unload the projects in VS, this action won't affect our source solution file or project file. VS will automatically skip the unloaded projects, which is the unique feature of IDE. (Unload is a UI action in VS, it has no effect on .sln/.xxproj file)

To exclude projects to build in Azure Devops:

1.Specify projects to build when building whole solution. (It doesn't change any file, so that it won't affect Version control)

You can check this answer and corresponding document. My devops task setting (no need to specify Build target):

2.Exclude projects from solution configuration (Not recommended) or create a new configuration that excludes specific projects (Recommended). The solution configuration is defined in solution file (sln), so this way would makes effect on Source control.

Exclude projects from solution configuration(Not recommended):

Create a new configuration that excludes specific projects:

Related document here. I suggest you can do the changes via VS IDE, and then push the commits to remote repo. It's complex if you're not familiar with msbuild and sln file, so I doesn't suggest doing that yourself. Let IDE do the job for you.

Once the remote repo get the changes:

We can build the solution in devops with customrelease configuration which excludes ProjectA and ProjectB instead of release configuration which contains all projects.

All these workarounds had been tested on my side before posting them.

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

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