我试图在安装了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 "$(SourceDir)*.*" /s"/>
</Target>
<Target Name="RestorePackages" DependsOnTargets="UnsetReadonly">
<Exec Command=""$(MSBuildThisFileDirectory)Nuget-Publishing\NuGet.exe" restore "%(Solution.Identity)"" />
</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