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还原包失败的情况。

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

  • 相关阅读:
    反向代理实例
    nginx常用命令和配置
    nginx的安装
    Can Live View boot up images acquired from 64bit OS evidence?
    What is the behavior of lnk files?
    EnCase v7 search hits in compound files?
    How to search compound files
    iOS 8.3 JB ready
    Sunglasses
    现代福尔摩斯
  • 原文地址:https://www.cnblogs.com/VAllen/p/Nuget-Restore-Faild-On-The-Jenkins.html
Copyright © 2011-2022 走看看