.net Microsoft.Bcl.Build NuGet 包有什么作用?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22824804/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 12:42:27  来源:igfitidea点击:

What does the Microsoft.Bcl.Build NuGet package do?

.netnuget.net-4.5

提问by crimbo

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

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

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 包的项目。

除非您收到指示您添加引用的构建警告,否则不要直接引用此包。

From looking at the Microsoft.Bcl.Build.targetsfile, 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.

从查看Microsoft.Bcl.Build.targets文件来看,它似乎管理绑定重定向和包引用。看起来此功能中的某些功能仅在 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)?

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

回答by crimbo

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

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

  • 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.
  • EnsureBindingRedirects- 确定哪些引用被选择用于绑定重定向,并使用它们更新 app.config
  • BclBuildValidateNugetPackageReferences- 此目标验证当前项目中安装的任何 Nuget 包是否也在当前项目中安装了它们的依赖项(传递依赖项)。

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.

所以基于这个评估,我决定这个功能只在开发环境中需要,当添加/删除/更新 NuGet 依赖项时;并且它可以在 CI 环境中被忽略,在那里它会导致问题。

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:

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

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

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

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

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.

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

Edit 2018-02-01:

编辑 2018-02-01:

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

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

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

回答by Matthew Verstraete

It is basically a way for older packages that targeted older .Net to build and compile with no problems on new .Nets

它基本上是针对旧 .Net 的旧包构建和编译而在新 .Net 上没有问题的一种方式

If you go to http://blogs.msdn.com/b/bclteam/p/bclbuild.aspxyou will see two announcements linking to http://blogs.msdn.com/b/dotnet/archive/2013/11/13/pcl-and-net-nuget-libraries-are-now-enabled-for-xamarin.aspxand https://devblogs.microsoft.com/dotnet/improved-package-restore/that should explain it.

如果您访问http://blogs.msdn.com/b/bclteam/p/bclbuild.aspx,您将看到两个公告链接到http://blogs.msdn.com/b/dotnet/archive/2013/11/ 13/pcl-and-net-nuget-libraries-are-now-enabled-for-xamarin.aspxhttps://devblogs.microsoft.com/dotnet/improved-package-restore/应该解释一下。