使用TFS

时间:2017-06-30 07:05:11

标签: .net msbuild tfs2015 nuget-package-restore

我遇到了一个问题,在TFS构建定义的msbuild过程中没有恢复一些NuGet包。

我的解决方案中总共有九个NuGet包,我可以看到九个中的七个从packages文件夹中恢复,但是其他两个从未恢复,甚至没有尝试恢复。软件包列在packages.config中,并且构建目录中存在相应的文件夹。

我已尝试添加此MS document中提到的其他NuGet Restore,并且我尝试手动运行NuGet命令但未成功。

其他详情:

  • 解决方案适用于没有项目文件的.Net网站
  • NuGet.exe版本为2.8.60318.667
  • TFS 2015
  • msbuild.exe 14.0.23107
  • 定位.Net Framework 4.0(但已尝试过4.5,但结果相同)
  • AWSSDK.Core和AWSSDK.DynamoDBv2尚未恢复。

packages.config的内容:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="AWSSDK.Core" version="3.3.15" targetFramework="net40" requireReinstallation="true" />
  <package id="AWSSDK.DynamoDBv2" version="3.3.4.14" targetFramework="net40" requireReinstallation="true" />
  <package id="Microsoft.Bcl" version="1.1.10" targetFramework="net40" requireReinstallation="true" />
  <package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net40" />
  <package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net40" />
  <package id="RestSharp" version="105.2.3" targetFramework="net40" requireReinstallation="true" />
  <package id="StackExchange.Redis" version="1.1.603" targetFramework="net40" requireReinstallation="true" />
  <package id="Twilio" version="4.7.2" targetFramework="net40" />
  <package id="Twilio.Lookups" version="1.1.0" targetFramework="net40" />
</packages>

从TFS输出:

> Build started 6/29/2017 11:51:47 PM.
>      1>Project "B:\site_agent\_work\4d978bf9\Site\Site.sln" on node 1 (default targets).
>      1>ValidateSolutionConfiguration:
>          Building solution configuration "Debug|Any CPU". B:\site_agent\_work\4d978bf9\Site\site.metaproj(0,0): Warning MSB3268:
> The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the
> currently targeted framework. ".NETFramework,Version=v4.5". To resolve
> this problem, either remove the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll"
> or retarget your application to a framework version which contains
> "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
>      1>Project "B:\site_agent\_work\4d978bf9\Site\Site.sln" (1) is building "B:\site_agent\_work\4d978bf9\Site\site.metaproj" (2) on node
> 1 (default targets).
>      2>B:\site_agent\_work\4d978bf9\Site\site.metaproj : warning MSB3268: The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the
> currently targeted framework. ".NETFramework,Version=v4.5". To resolve
> this problem, either remove the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll"
> or retarget your application to a framework version which contains
> "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
> B:\site_agent\_work\4d978bf9\Site\site.metaproj(0,0): Warning MSB3268:
> The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Threading.Tasks, Version=4.0.0.0,
> Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be
> resolved in the currently targeted framework.
> ".NETFramework,Version=v4.5". To resolve this problem, either remove
> the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll"
> or retarget your application to a framework version which contains
> "System.Threading.Tasks, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
>      2>B:\site_agent\_work\4d978bf9\Site\site.metaproj : warning MSB3268: The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Threading.Tasks, Version=4.0.0.0,
> Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be
> resolved in the currently targeted framework.
> ".NETFramework,Version=v4.5". To resolve this problem, either remove
> the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll"
> or retarget your application to a framework version which contains
> "System.Threading.Tasks, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
> B:\site_agent\_work\4d978bf9\Site\site.metaproj(0,0): Warning MSB3268:
> The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Threading.Tasks, Version=4.0.0.0,
> Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be
> resolved in the currently targeted framework.
> ".NETFramework,Version=v4.5". To resolve this problem, either remove
> the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll"
> or retarget your application to a framework version which contains
> "System.Threading.Tasks, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
>      2>B:\site_agent\_work\4d978bf9\Site\site.metaproj : warning MSB3268: The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Threading.Tasks, Version=4.0.0.0,
> Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be
> resolved in the currently targeted framework.
> ".NETFramework,Version=v4.5". To resolve this problem, either remove
> the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll"
> or retarget your application to a framework version which contains
> "System.Threading.Tasks, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
> B:\site_agent\_work\4d978bf9\Site\site.metaproj(0,0): Warning MSB3268:
> The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the
> currently targeted framework. ".NETFramework,Version=v4.5". To resolve
> this problem, either remove the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll"
> or retarget your application to a framework version which contains
> "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
>      2>B:\site_agent\_work\4d978bf9\Site\site.metaproj : warning MSB3268: The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the
> currently targeted framework. ".NETFramework,Version=v4.5". To resolve
> this problem, either remove the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll"
> or retarget your application to a framework version which contains
> "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
> B:\site_agent\_work\4d978bf9\Site\site.metaproj(0,0): Warning MSB3268:
> The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\StackExchange.Redis.1.1.603\lib\net40\StackExchange.Redis.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the
> currently targeted framework. ".NETFramework,Version=v4.5". To resolve
> this problem, either remove the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\StackExchange.Redis.1.1.603\lib\net40\StackExchange.Redis.dll"
> or retarget your application to a framework version which contains
> "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
>      2>B:\site_agent\_work\4d978bf9\Site\site.metaproj : warning MSB3268: The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\StackExchange.Redis.1.1.603\lib\net40\StackExchange.Redis.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the
> currently targeted framework. ".NETFramework,Version=v4.5". To resolve
> this problem, either remove the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\StackExchange.Redis.1.1.603\lib\net40\StackExchange.Redis.dll"
> or retarget your application to a framework version which contains
> "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
> B:\site_agent\_work\4d978bf9\Site\site.metaproj(0,0): Warning MSB3268:
> The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\StackExchange.Redis.1.1.603\lib\net40\StackExchange.Redis.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Threading.Tasks, Version=4.0.0.0,
> Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be
> resolved in the currently targeted framework.
> ".NETFramework,Version=v4.5". To resolve this problem, either remove
> the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\StackExchange.Redis.1.1.603\lib\net40\StackExchange.Redis.dll"
> or retarget your application to a framework version which contains
> "System.Threading.Tasks, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
>      2>B:\site_agent\_work\4d978bf9\Site\site.metaproj : warning MSB3268: The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\StackExchange.Redis.1.1.603\lib\net40\StackExchange.Redis.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Threading.Tasks, Version=4.0.0.0,
> Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be
> resolved in the currently targeted framework.
> ".NETFramework,Version=v4.5". To resolve this problem, either remove
> the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\StackExchange.Redis.1.1.603\lib\net40\StackExchange.Redis.dll"
> or retarget your application to a framework version which contains
> "System.Threading.Tasks, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\site\Bin\AjaxControlToolkit.dll" to
> "site\\Bin\AjaxControlToolkit.dll".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll"
> to "site\\Bin\Microsoft.Threading.Tasks.Extensions.Desktop.dll".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.xml"
> to "site\\Bin\Microsoft.Threading.Tasks.Extensions.Desktop.xml".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.1.1.10\lib\net40\System.IO.dll"
> to "site\\Bin\System.IO.dll".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.1.1.10\lib\net40\System.IO.xml"
> to "site\\Bin\System.IO.xml".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.1.1.10\lib\net40\System.Threading.Tasks.dll"
> to "site\\Bin\System.Threading.Tasks.dll".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.1.1.10\lib\net40\System.Threading.Tasks.xml"
> to "site\\Bin\System.Threading.Tasks.xml".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\packages\Twilio.4.7.2\lib\3.5\Twilio.Api.dll"
> to "site\\Bin\Twilio.Api.dll".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\packages\Twilio.4.7.2\lib\3.5\Twilio.Api.pdb"
> to "site\\Bin\Twilio.Api.pdb".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\packages\Twilio.4.7.2\lib\3.5\Twilio.Api.xml"
> to "site\\Bin\Twilio.Api.xml".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\packages\Twilio.Lookups.1.1.0\lib\3.5\Twilio.Lookups.dll"
> to "site\\Bin\Twilio.Lookups.dll".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\packages\Twilio.Lookups.1.1.0\lib\3.5\Twilio.Lookups.pdb"
> to "site\\Bin\Twilio.Lookups.pdb".
>          C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v
> /localhost_55535 -p site\ -u -f

2 个答案:

答案 0 :(得分:0)

如果可以通过TFS构建恢复其他软件包。您可以尝试仅恢复两个特定软件包而不是九个。

造成这种情况的原因可能是由于某人意外地检查了项目中的packages文件夹中的某些点,因此看起来来自本地Nuget文件夹的内容正被复制出项目中的packages文件夹。

如果是这样,请从TFS中删除packages文件夹,然后重试。

答案 1 :(得分:0)

似乎没有解决方案中的项目文件,除非您将.refresh文件添加到bin文件夹,否则它不会自动从packages目录恢复dll。一旦我这样做,所有的包dll都被从包目录中的各自文件夹中复制出来,以便在调用msbuild开始编译之前解压缩到bin文件夹。

解决方案摘要:

  • 将bin文件夹中的.refresh文件添加到TFS
  • 确保将packages文件夹及其内容签入TFS
  • 不要将bin文件夹中的实际dll添加到TFS
  • 将TFS构建步骤设置为Restore NuGet packages。
  • 确保您在网站代码的根目录中有一个packages.config