Search code examples
nugetvisual-studio-2022cicd.net-7.0

Restore x64 NuGet packages via PowerShell


I've got .NET 7.2 WEB API project, which was build with x64 Visual Studio 2022 v17.2 - v17.4. Now I try to set up CI/CD pipeline, for what I use .yml with following code:

    - 'C:\nuget.exe restore server.csproj'
    - '& "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild" server.csproj'

Constantly getting error:

error NETSDK1064: Package Microsoft.EntityFrameworkCore.Analyzers, version 7.0.2 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.

What I've tried is:

  • I enabled Win32 long paths as it suggested here
  • I've created new WeatherForecast project and new repo with name tst, so path certainly cannot be shorter

Nothing gives any success

As far as I understand, the problem is that I use x32 NuGet CLI with x64 VS 2022 builder. Bit depth does not match. As far as my project uses .NET 7, I cannot use VS 2019. Also I cannot find x64 NuGet CLI - official site provides only x32 versions

I need some way to restore packages and then build the project from YML file. What surprised me is that I can sequentially run all commands from .yml in cmd.exe and as a result I will get build with no errors. I tried to $ whoami prior to any of .yml command and it gives me that it's SYSTEM user, which by the way got full access to IIS's wwwroot folder, but the error triggers prior deployment step, so I have no clue how it could be related

I'm stuck, got no idea what to do, but guess that solution is quite simple, I'm to blurry now. SOers please help me

Solution

Great thanks to @mu88!

In accordance to his suggestions yml took that form:

  - 'dotnet restore service.csproj -v n'
  - 'dotnet service.csproj'

And everything works as it supposed to


Solution

  • After some investigation (see the comment section) we found out that using dotnet build instead of msbuild solves the problem.