Microsoft.Bcl.BuildNuGet 包是做什么的?

我无法找到任何有关这方面的文档-从 编译 Nuget 页面的链接没有提供太多的帮助:

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

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

Microsoft.Bcl.Build.targets文件来看,它似乎管理绑定重定向和包引用。其中一些功能似乎只有在 VisualStudio 中运行时才会使用。

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

43992 次浏览

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

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

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

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

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.

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>

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.

Edit 2018-02-01:

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