How to resolve NAnt not restoring package?

1k Views Asked by At

I am trying to build a project using NAnt, however, the project restore's error is: "\2.2.107\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(208,5): error NETSDK1064: Package Microsoft.EntityFrameworkCore.Analyzers, version 2.2.4 was not found. It might have been deleted since NuGet restore. Otherwise, NuGet restore might have only partially completed, which might have been due to maximum path length restrictions."

I tried this solution: Jenkins not picking up the nuget restored packages

This was unsuccessful.

<target name="restore" description="Restore the nuget packages">
    <exec program="${project::get-base-directory()}\.nuget\nuget.exe">
        <arg value="restore"/>
        <arg value="${project::get-base-directory()}\solution.sln"/>
    </exec>
  </target>

  <target name="build" description="Build Solution" depends="clean,restore">
    <call target="build-all"/>
  </target>

  <target name="build-all" description="Build the web and library solutions">
     <exec program="msbuild.exe">
        <arg value="solution.sln"/>
        <arg value="/m"/>
        <arg value="/p:VisualStudioVersion=14.0"/>
        <arg value="/p:Configuration=Release"/>
        <arg value="/t:Clean"/>
        <arg value="/p:Configuration=Release"/>
      </exec>
      <exec program="msbuild.exe">
        <arg value="solution.sln"/>     
        <arg value="/p:VisualStudioVersion=14.0"/>
        <arg value="/p:Configuration=Release"/>
        <arg value="/m"/>
        <arg value="/t:Build"/>
      </exec>
     </target>
1

There are 1 best solutions below

0
rageit On

Just for a reference: I had a .NET (not core) project which used package references. I added a argument in the msbuild exec to restore the nuget package and also specified nuget package path. I had pathing issue since the project got converted from 32-bit build to 64-bit build - it was inconsistently referencing between C:\Windows\system32\config\systemprofile.nuget\packages and C:\Windows\SysWOW64\config\systemprofile.nuget\packages.

<exec program="${MSBuildPath}" workingdir="${build.dir}" failonerror="true" >
  <arg value="/v:d"/>
  <arg value="/p:VisualStudioVersion=15.0"/>
  <arg value="/toolsversion:15.0"/>
  <arg value="/p:Configuration=release"/>
  <arg value="/p:Platform=Mixed Platforms"/>
  <arg value="/restore"/>
  <arg value="/restoreProperty:RestorePackagesPath=${NuGetPackagesPath}"/>
  <arg value="/fileLogger"/>
  <arg value="${project.name}.sln"/>
</exec>