如何在 TFS 2013 构建服务器上恢复 PCL(使用 project.json)引用的 nuget 包
How to restore nuget packages referenced by PCL (with project.json) on TFS 2013 Build Server
我需要什么
我正在尝试在安装了 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 class 库的 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
打包的
这已在 NuGet 3.4 中得到解决。
相关问题:
不确定,但是 project.json
上的 commit 可能已经修复了它。
我需要什么
我正在尝试在安装了 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 class 库的 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
这已在 NuGet 3.4 中得到解决。
相关问题:
不确定,但是 project.json
上的 commit 可能已经修复了它。