使用 MSBuild 的 Bamboo 中的 Nuget 包还原问题

Nuget Packages Restore issue in Bamboo with MSBuild

我正在使用 Bamboo 和 MSBuild 并启用了恢复包。

当我 运行 它不会恢复所有的包,当我看到日志时它会恢复一些包,但不是所有项目都在解决方案中...我需要在 MS Build 脚本中修复什么吗?

完整错误日志: http://justpaste.it/oq2p

错误日志:

02-Nov-2015 10:08:55    Infrastructure\InMemoryMultipartStreamProvider.cs(14,52): error CS0246: The type or namespace name 'MultipartStreamProvider' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\Administrator\bamboo-home\xml-data\build-dir\API-STAG-JOB1\SmartDesk.BusinessObjects\SmartDesk360.BusinessObjects.csproj]
02-Nov-2015 10:08:55    Infrastructure\InMemoryMultipartStreamProvider.cs(30,32): error CS0115: 'InMemoryMultipartStreamProvider.GetStream(HttpContent, HttpContentHeaders)': no suitable method found to override [C:\Users\Administrator\bamboo-home\xml-data\build-dir\API-STAG-JOB1\SmartDesk.BusinessObjects\SmartDesk360.BusinessObjects.csproj]
02-Nov-2015 10:08:55    Infrastructure\InMemoryMultipartStreamProvider.cs(41,36): error CS0115: 'InMemoryMultipartStreamProvider.ExecutePostProcessingAsync()': no suitable method found to override [C:\Users\Administrator\bamboo-home\xml-data\build-dir\API-STAG-JOB1\SmartDesk.BusinessObjects\SmartDesk360.BusinessObjects.csproj]
02-Nov-2015 10:08:55    Done Building Project "C:\Users\Administrator\bamboo-home\xml-data\build-dir\API-STAG-JOB1\SmartDesk.BusinessObjects\SmartDesk360.BusinessObjects.csproj" (default targets) -- FAILED.
02-Nov-2015 10:08:55    Project "C:\Users\Administrator\bamboo-home\xml-data\build-dir\API-STAG-JOB1\API.SmartDesk360.com\SmartDesk360.API.csproj" (2) is building "C:\Users\Administrator\bamboo-home\xml-data\build-dir\API-STAG-JOB1\SmartDesk360.Core\SmartDesk360.Core.csproj" (6) on node 1 (default targets).
02-Nov-2015 10:08:55    RestorePackages:
02-Nov-2015 10:08:55      "C:\Users\Administrator\bamboo-home\xml-data\build-dir\API-STAG-JOB1\.nuget\NuGet.exe" install "C:\Users\Administrator\bamboo-home\xml-data\build-dir\API-STAG-JOB1\SmartDesk360.Core\packages.config" -source ""  -NonInteractive -RequireConsent -solutionDir "C:\Users\Administrator\bamboo-home\xml-data\build-dir\API-STAG-JOB1\ "
02-Nov-2015 10:08:55      Restoring NuGet packages...
02-Nov-2015 10:08:55      To prevent NuGet from downloading packages during build, open the Visual Studio Options dialog, click on the Package Manager node and uncheck 'Allow NuGet to download missing packages'.
02-Nov-2015 10:08:55      All packages listed in packages.config are already installed.
02-Nov-2015 10:08:55    Project "C:\Users\Administrator\bamboo-home\xml-data\build-dir\API-STAG-JOB1\SmartDesk360.Core\SmartDesk360.Core.csproj" (6) is building "C:\Users\Administrator\bamboo-home\xml-data\build-dir\API-STAG-JOB1\SmartDesk360.DataLayer\SmartDesk360.DataLayer.csproj" (7) on node 1 (default targets).
02-Nov-2015 10:08:55    RestorePackages:
02-Nov-2015 10:08:55      "C:\Users\Administrator\bamboo-home\xml-data\build-dir\API-STAG-JOB1\.nuget\NuGet.exe" install "C:\Users\Administrator\bamboo-home\xml-data\build-dir\API-STAG-JOB1\SmartDesk360.DataLayer\packages.config" -source ""  -NonInteractive -RequireConsent -solutionDir "C:\Users\Administrator\bamboo-home\xml-data\build-dir\API-STAG-JOB1\ "
02-Nov-2015 10:08:55      Restoring NuGet packages...
02-Nov-2015 10:08:55      To prevent NuGet from downloading packages during build, open the Visual Studio Options dialog, click on the Package Manager node and uncheck 'Allow NuGet to download missing packages'.
02-Nov-2015 10:08:55      All packages listed in packages.config are already installed.
02-Nov-2015 10:08:55    Done Building Project "C:\Users\Administrator\bamboo-home\xml-data\build-dir\API-STAG-JOB1\SmartDesk360.DataLayer\SmartDesk360.DataLayer.csproj" (default targets) -- FAILED.
02-Nov-2015 10:08:55    Project "C:\Users\Administrator\bamboo-home\xml-data\build-dir\API-STAG-JOB1\SmartDesk360.Core\SmartDesk360.Core.csproj" (6) is building "C:\Users\Administrator\bamboo-home\xml-data\build-dir\API-STAG-JOB1\SmartDesk360.FileManager\SmartDesk360.FileManager.csproj" (8) on node 1 (default targets).
02-Nov-2015 10:08:55    RestorePackages:
02-Nov-2015 10:08:55      "C:\Users\Administrator\bamboo-home\xml-data\build-dir\API-STAG-JOB1\.nuget\NuGet.exe" install "C:\Users\Administrator\bamboo-home\xml-data\build-dir\API-STAG-JOB1\SmartDesk360.FileManager\packages.config" -source ""  -NonInteractive -RequireConsent -solutionDir "C:\Users\Administrator\bamboo-home\xml-data\build-dir\API-STAG-JOB1\ "
02-Nov-2015 10:08:56      Restoring NuGet packages...
02-Nov-2015 10:08:56      To prevent NuGet from downloading packages during build, open the Visual Studio Options dialog, click on the Package Manager node and uncheck 'Allow NuGet to download missing packages'.
02-Nov-2015 10:08:56      All packages listed in packages.config are already installed.
02-Nov-2015 10:08:56    Done Building Project "C:\Users\Administrator\bamboo-home\xml-data\build-dir\API-STAG-JOB1\SmartDesk360.FileManager\SmartDesk360.FileManager.csproj" (default targets) -- FAILED.
02-Nov-2015 10:08:56    Project "C:\Users\Administrator\bamboo-home\xml-data\build-dir\API-STAG-JOB1\SmartDesk360.Core\SmartDesk360.Core.csproj" (6) is building "C:\Users\Administrator\bamboo-home\xml-data\build-dir\API-STAG-JOB1\SmartDesk360.Mailer\SmartDesk360.Mailer.csproj" (9) on node 1 (default targets).
02-Nov-2015 10:08:56    GenerateTargetFrameworkMonikerAttribute:
02-Nov-2015 10:08:56    Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
02-Nov-2015 10:08:56    CoreCompile:
02-Nov-2015 10:08:56    Skipping target "CoreCompile" because all output files are up-to-date with respect to the input files.
02-Nov-2015 10:08:56    CopyFilesToOutputDirectory:
02-Nov-2015 10:08:56      SmartDesk360.Mailer -> C:\Users\Administrator\bamboo-home\xml-data\build-dir\API-STAG-JOB1\SmartDesk360.Mailer\bin\Debug\SmartDesk360.Mailer.dll
02-Nov-2015 10:08:56    Done Building Project "C:\Users\Administrator\bamboo-home\xml-data\build-dir\API-STAG-JOB1\SmartDesk360.Mailer\SmartDesk360.Mailer.csproj" (default targets).
02-Nov-2015 10:08:56    Done Building Project "C:\Users\Administrator\bamboo-home\xml-data\build-dir\API-STAG-JOB1\SmartDesk360.Core\SmartDesk360.Core.csproj" (default targets) -- FAILED.
02-Nov-2015 10:08:56    Done Building Project "C:\Users\Administrator\bamboo-home\xml-data\build-dir\API-STAG-JOB1\API.SmartDesk360.com\SmartDesk360.API.csproj" (default targets) -- FAILED.
02-Nov-2015 10:08:56    Project "C:\Users\Administrator\bamboo-home\xml-data\build-dir\API-STAG-JOB1\API.SmartDesk360.com.sln" (1) is building "C:\Users\Administrator\bamboo-home\xml-data\build-dir\API-STAG-JOB1\Tests.SmartDesk360.com\Tests.SmartDesk360.com.csproj" (10) on node 1 (default targets).
 "C:\Program Files (x86)\NuGet\nuget.exe" restore ${bamboo.build.working.directory}\MySolution.sln"

我希望这能解决问题

因此,如果您的 repositories.config 文件包含如下内容:

<?xml version="1.0" encoding="utf-8"?>
<repositories>
  <repository path=".\MyCsProj\packages.config" />
</repositories>

您的 MyCsProj\packages.config 文件如下所示:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="SuperCoolPackage" version="4.3.2.1" targetFramework="net452" />
</packages>

Nuget 将查找如下目录:

.\packages\SuperCoolPackage.4.3.2.1\

无论“.\packages\SuperCoolPackage.4.3.2.1\”目录中是否有实际的二进制文件,Nuget ~thinks~/assumes they are there by the name of the folder.

所以有时候,虽然文件夹“.\packages\SuperCoolPackage.4.3.2.1\”存在,但它可能没有任何您需要的实际二进制文件的子文件。

您需要重新阅读有关在源代码管理中存储文件的最新建议。

https://docs.nuget.org/consume/package-restore

To promote a cleaner developer environment while also reducing repository size, NuGet offers a Package Restore feature that will install all referenced packages before a project is built, thereby ensuring that all dependencies are available to a project without requiring them to be stored in source control.

这就是您想要的源代码管理。

.\packages\repositories.config

此“.\packages\”下没有子文件夹

那么你会运行

nuget.exe 在构建过程中恢复 MySolution.sln。

因为这个“.\packages\”下没有子文件夹,它会下载它们。 (并在本地缓存它们,所以只有第一次真的很痛苦)

最大的触发点(恕我直言)

.\packages\SuperCoolPackage.4.3.2.1\

在源代码管理中。根据我上面提到的 nuget url,我建议不要在源代码管理中包含任何这些子文件夹。

如果您有 .\packages\SuperCoolPackage.4.3.2.1\ ... 要么将其从源代码管理中删除.........要么编写 msbuild 代码以删除 [=58 之前的所有子文件夹=]正在执行 nuget.exe 恢复命令。