Microsoft.Bcl.Build.targets" cannot be imported again

 warning MSB4011: "C:\workspace\Company\Finland\tow\develop\Source\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" cannot be imported again. It was already imported at "C:\workspace\Company\Finland\tow\develop\Source\EdenredFI.WOT.MAP.API\EdenredFI.WOT.MAP.API.csproj (87,3)". This is most likely a build authoring error. This subsequent import will be ignored. 

The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

 

https://devblogs.microsoft.com/dotnet/improved-package-restore/

 

NuGet 2.7 makes this a lot easier:

  1. You no longer need to enable package restore explicitly – when building in VS all packages are restored automatically.
  2. Running package restore on a build machine is now super easy. You only need to check-in NuGet.exe (nothing else) and you can put it wherever you want. It can even be in a well-known location on your build server and excluded from every solution if desired. Prior to the build you simply run nuget.exe restore pathtomysolution.sln.

Also, the NuGet team is talking to all major providers of build/CI servers (incl. TFS) so that at some point the second step can be handled automatically by the build servers. For more details, have a look at the NuGet 2.7 release notes and the new Package Restore documentation.

 

Summary

The new version of Microsoft.Bcl.Build will ensure that solutions containing our packages will load successfully even if packages aren’t restored yet. This affects all .NET NuGet packages that depend on it, such as Microsoft.Net.Http, Microsoft.Bcl, and Microsoft.Bcl.Async.

Microsoft.Bcl.Build will give an actionable error message in cases the package was missing by asking you to build again.

When coupled with NuGet 2.7 where package restore is automatic in Visual Studio and isn’t implemented through MSBuild, the experience is transparent and smooth. However, this doesn’t address build server scenarios yet so you still need run nuget.exe restore solution.sln prior to build, or check-in the .targets file if preferred.

posted @ 2021-08-12 15:18  ChuckLu  阅读(200)  评论(0编辑  收藏  举报