【问题标题】:How to restore nuget packages referenced by PCL (with project.json) on TFS 2013 Build Server如何在 TFS 2013 Build Server 上恢复 PCL(使用 project.json)引用的 nuget 包
【发布时间】:2016-07-27 03:35:13
【问题描述】:

我需要什么

我正在尝试在安装了 VS2015 Update1 的 TFS 2013 构建服务器上构建 PCL 库(使用 project.json)。

有什么问题

PCL 库的 Nuget 包(Mirosoft.NETCore 和 Microsoft.NETCore.Portable.Compatibility)未恢复。

我遇到了类似的错误

 Properties\AssemblyInfo.cs (9): The type or namespace name 'AssemblyTitle' could not be found (are you missing a using directive or an assembly reference?)
 Properties\AssemblyInfo.cs (17): Predefined type 'System.String' is not defined or imported
 Properties\AssemblyInfo.cs (29): Predefined type 'System.String' is not defined or imported
 Properties\AssemblyInfo.cs (30): Predefined type 'System.String' is not defined or imported

 C:\Users\MHABLDSvc\AppData\Local\Temp\.NETPortable,Version=v5.0.AssemblyAttributes.cs (4): Predefined type 'System.String' is not defined or imported
 C:\Users\MHABLDSvc\AppData\Local\Temp\.NETPortable,Version=v5.0.AssemblyAttributes.cs (4): The type or namespace name 'FrameworkDisplayName' could not be found (are you missing a using directive or an assembly reference?)
 C:\Users\MHABLDSvc\AppData\Local\Temp\.NETPortable,Version=v5.0.AssemblyAttributes.cs (4): Predefined type 'System.String' is not defined or imported

我尝试过的:

第一次尝试是在 $slnDir$.nuget\nuget.exe 中启用自动包还原。这在 Visual Studio 中有效,但在 TFS 构建期间无效。

所以我更改了 TFS 构建定义以构建我的 build.proj 而不是 .sln 文件。

它恢复 .NET 4.6 类库的 nuget 包,但不是我的 PCL 库

build.proj

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0"
         DefaultTargets="Build"
         xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <Target Name="UnsetReadonly">
    <Exec Command="attrib -r &quot;$(SourceDir)*.*&quot; /s"/>
  </Target>

  <Target Name="RestorePackages" DependsOnTargets="UnsetReadonly">
    <Exec Command="&quot;$(MSBuildThisFileDirectory)Nuget-Publishing\NuGet.exe&quot; restore &quot;%(Solution.Identity)&quot;" />
  </Target>

  <Target Name="Clean">
    <MSBuild Targets="Clean" 
             Projects="@(Solution)" />
  </Target>



  <Target Name="Build" DependsOnTargets="RestorePackages">

    <MSBuild Targets="Build" 
             Projects="@(Solution)"
             UseResultsCache="True" StopOnFirstFailure="true" Properties="Verbosity=Minimal"  />

  </Target>    
</Project>

nuget.exe restore 说:packages.config 中列出的所有包都已安装。但是,我的问题是从 project.json 打包的

【问题讨论】:

  • nuget restore 的输出是什么?它可以从 cmd 工作吗?您使用的是最新版本的 nuget.exe 吗?
  • 我使用的是 nuge.exe 3.3.0。从命令行它给出相同的结果:packages.config 中列出的所有包都已安装
  • 它似乎适用于最新的 3.4.0 beta!

标签: tfs msbuild nuget tfsbuild


【解决方案1】:

这已在 NuGet 3.4 中解决。

相关问题:

Cannot install NuGet package depending on Microsoft.NETCore into .NET Framework 4.6 console application project #1883

不确定,但 project.json 上的 commit 可能已修复它。

【讨论】:

    猜你喜欢
    • 2015-04-26
    • 2015-12-27
    • 2018-05-29
    • 2016-07-11
    • 1970-01-01
    • 2021-04-04
    • 1970-01-01
    • 2015-04-29
    • 2017-06-14
    相关资源
    最近更新 更多