fsprojects / Paket

A dependency manager for .NET with support for NuGet packages and Git repositories.
https://fsprojects.github.io/Paket/
MIT License
1.99k stars 520 forks source link

Dotnet restore fails for container running on Linux, but succeeds on Windows. #3953

Open voroninp opened 3 years ago

voroninp commented 3 years ago

I have docker file with build process:

FROM mcr.microsoft.com/dotnet/sdk:3.1-buster as build
WORKDIR /Repo
COPY . .
RUN dotnet tool restore -v diag
RUN dotnet restore src -v diag
RUN dotnet build --no-restore -c Release -v diag src
RUN dotnet paket pack --interproject-references keep-major ../out

This works on Windows, but fails on Linux: (and in GitLab pipeline)

cloudflare-fsharp-api-package/.paket/Paket.Restore.targets(171,5): error MSB3073: The command "mono --runtime=v4.0.30319 "/builds/migamake/migamake-hurl/cloudflare-fsharp-api-package/.paket/paket.exe" restore" exited with code 127.

I have no idea how host can affect MSBuild running within docker container.

voroninp commented 3 years ago

I found the reason:

If paket.exe exists locally, for some reason dotnet restore in docker running on Linux resolves to .paket/paket.exe via Paket.Restore.targets.

panuva-sympa commented 2 years ago

Workaround, to modify .paket\Paket.Restore.targets in two locations:

row 32:

    <PaketBootStrapperCommand Condition=" '$(OS)' != 'Windows_NT' ">$(MonoPath) --runtime=v4.0.30319 "$(PaketBootStrapperExePath)"</PaketBootStrapperCommand>

to

    <PaketBootStrapperCommand Condition=" '$(OS)' != 'Windows_NT' ">dotnet paket</PaketBootStrapperCommand>

and

row 99:

      <_PaketCommand Condition=" '$(_PaketCommand)' == '' AND '$(OS)' != 'Windows_NT' AND '$(_PaketExeExtension)' == '.exe' ">$(MonoPath) --runtime=v4.0.30319 "$(PaketExePath)"</_PaketCommand>

to

      <_PaketCommand Condition=" '$(_PaketCommand)' == '' AND '$(OS)' != 'Windows_NT' AND '$(_PaketExeExtension)' == '.exe' ">dotnet paket</_PaketCommand>
cricarba commented 1 year ago

@voroninp were you able fix it?

voroninp commented 1 year ago

@cricarba , no, as far as I remember.