Microsoft.Bcl.Build NuGet 包有什么作用? [英] What does the Microsoft.Bcl.Build NuGet package do?

查看:22
本文介绍了Microsoft.Bcl.Build NuGet 包有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找不到关于此的任何文档 - 来自 Microsoft.Bcl.Build Nuget 页面 没有提供太多帮助:

I'm unable to find any documentation on this - the links from the Microsoft.Bcl.Build Nuget page don't provide much help:

此包提供构建基础结构组件,以便可以成功构建引用特定 Microsoft 包的项目.

This package provides build infrastructure components so that projects referencing specific Microsoft packages can successfully build.

除非您收到指示您添加引用的构建警告,否则请勿直接引用此包.

Do not directly reference this packages unless you receive a build warning that instructs you to add a reference.

Microsoft.Bcl.Build.targets 文件来看,它看起来像是管理绑定重定向和包引用.看起来其中一些功能仅在 Visual Studio 中运行时使用.

From looking at the Microsoft.Bcl.Build.targets file, it looks like it manages binding redirects and package references. It looks like some of this functionality is used only when running in Visual Studio.

谁能提供有关此软件包的更多信息?在我们的构建服务器环境中很痛苦,完全从源代码构建时可以忽略它吗代码(例如构建服务器环境)?

Can anyone provide any more information on what this package does? It's a pain in our build server environment, can it be ignored when building entirely from source code (eg build server environment)?

推荐答案

Microsoft.Bcl.Build.targets来看,它有一堆项目配置目标,例如:

From looking at Microsoft.Bcl.Build.targets, it has a bunch of project configuration targets, eg:

  • EnsureBindingRedirects - 确定哪些引用被选择用于绑定重定向,并使用它们更新 app.config
  • BclBuildValidateNugetPackageReferences - 此目标验证当前项目中安装的任何 Nuget 包是否也在当前项目中安装了它们的依赖项(传递依赖项).
  • EnsureBindingRedirects - Determine which references are opted in for binding redirects, and update the app.config with them
  • BclBuildValidateNugetPackageReferences - This target validates that any Nuget packages installed in the current project also have their dependencies (transitive dependencies) installed in the current project.

因此基于此评估,我决定仅在开发环境中添加/删除/更新 NuGet 依赖项时才需要此功能;并且它可以在 CI 环境中被忽略,因为它会导致问题.

So based on this evaluation, I decided that this functionality is only needed in a dev environment, when adding/removing/updating NuGet dependencies; and that it could be ignored in a CI environment, where it's causing problems.

所以我想在我的 *.csproj 文件中保留依赖项,但在运行 CI 构建时忽略它.我通过在包含以下块的构建环境目标文件(例如 builder.targets)上添加条件导入来做到这一点:

So I want to keep the dependency in my *.csproj files, but ignore it when running a CI build. I did that by adding a conditional import on a build environment targets file (eg builder.targets), which includes this block:

<!-- Skip Microsoft.Bcl.Build functionality when building only from Source. -->
<PropertyGroup>
  <BclBuildImported>Ignore</BclBuildImported>
</PropertyGroup>

这会导致在 CI 环境中忽略目标,但在开发环境中激活它们.我已经运行了一个多星期,到目前为止没有任何问题......

This has the net effect of ignoring the targets in a CI environment, but activating them in a development environment. I've had this running for over a week, and no problems so far...

我仍然很想知道是否有人对此软件包有更好的信息,表明这样做是个坏主意.到目前为止,我认为这是一个好主意.

I'd still love to know if anyone has better information on this package that indicates that doing this is a bad idea. So far I'm of the opinion that it's a good idea.

编辑 2018-02-01:

注意ignore参数也可以在命令行传递,跳过Microsoft.Bcl.Build.targets逻辑:

Note that the ignore parameter can also be passed on the command-line, to skip the Microsoft.Bcl.Build.targets logic:

msbuild (targets, etc) /p:BclBuildImported=Ignore

这篇关于Microsoft.Bcl.Build NuGet 包有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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