如何在TFS 2013 Build Server

时间:2016-04-06 15:48:59

标签: tfs msbuild nuget tfsbuild

我需要什么

我试图在安装了VS2015 Update1的TFS 2013 Build Server上构建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 Build。

所以我更改了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

打包的

1 个答案:

答案 0 :(得分:1)

这在NuGet 3.4中得到了解决。

相关问题:

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

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