zoukankan      html  css  js  c++  java
  • 在CI (Jenkins) 从机(服务器)上使用bat批处理执行自动构建任务时,输出NuGet还原失败的解决方案

    编译环境:Jenkins+MSBuilds

    1.搜索本次构建的解决方案中的所有csproj后缀文件,打开后找到这一段代码,并且删除掉。如果没有,直接忽略跳过。

    <Import Project="$(SolutionDir).nugetNuGet.targets" Condition="Exists('$(SolutionDir).nugetNuGet.targets')" />
    <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
      ...
    </Target>

    这里因为在Visual Studio 2015中(对应的MSbuild版本是V14.0),已不再需要这一段代码配置。

    2.增加命令:nuget.exe update -Self

    echo Start initialize build parameters
    
    ::set DotNetFrameworkPath=%windir%Microsoft.NETFramework
    ::if exist %windir%SysWOW64 set DotNetFrameworkPath=%windir%Microsoft.NETFramework64
    
    
    set SolutionName=Uniqlo
    set Configuration=Debug
    set LogLevel=normal
    
    set SolutionPath=%~dp0..src
    set SolutionFile=%SolutionPath%%SolutionName%.sln
    
    set NugetExe=%SolutionPath%.nugetNuGet.exe
    set NugetArgs=restore "%SolutionFile%"
    
    set MSBuildPath=C:Program Files (x86)MSBuild14.0Bin
    set MSBuildExe=%MSBuildPath%MSBuild.exe
    set MSBuildArgs=/t:Rebuild /p:Configuration=%Configuration%;VisualStudioVersion=14.0;TargetFrameworkVersion=4.6.1 /verbosity:%LogLevel% /l:FileLogger,Microsoft.Build.Engine;encoding=utf-8;append=true;logfile=build\%SolutionName%_%Configuration%_Build.log
    
    echo Initialize build parameters completed.
    
    echo NuGet Start ReStoreing...
    "%NugetExe%" update -Self
    "%NugetExe%" %NugetArgs%
    echo NuGet ReStore completed.
    
    echo MSBuild Start building...
    "%MSBuildExe%" %MSBuildArgs% "%SolutionFile%"
    echo MSBuild Build completed.

    本解决方案同样适用于在本地机器中使用VS2015编译出现NuGet还原包失败的情况。

    如有此情况,在搜索并使用其它方案未果,排除其它原因(例如网络问题,被墙等),可以使用本解决方案试试。

  • 相关阅读:
    VMware vSphere 服务器虚拟化之二十四 桌面虚拟化之手动池管理物理机
    重思人性自我修养
    初窥Linux 之 数据流重定向
    MTD设备驱动
    wubi安装ubuntu后,增加swap大小,优化swap的使用参数-----------让ubuntu健步如飞,为编译android源码准备
    【deep learning学习笔记】最近读的几个ppt(四)
    computer专业术语总结
    弃用个人博客站重返CSDN缘由
    Hadoop1.0.4伪分布式安装
    谈谈我2013上半年在公司内部培训的经历
  • 原文地址:https://www.cnblogs.com/VAllen/p/Nuget-Restore-Faild-On-The-Jenkins.html
Copyright © 2011-2022 走看看