NuGet / setup-nuget

MIT License
76 stars 17 forks source link

Corrupted nuget.exe downloads onto a Windows runner #126

Closed rajkumar-bharathi closed 8 months ago

rajkumar-bharathi commented 8 months ago

I have a self-hosted runner (runner-1) on a Windows 10 machine (machine-1) where I use the setup-nuget action in the following workflow:

name: Nuget Test
on:
  workflow_dispatch:

jobs:
  Nuget-Workflow:
    runs-on: 'runner-1'
    steps:
    - name: Checkout
      uses: actions/checkout@v4.1.0

    - name: Set up nuget.exe
      uses: nuget/setup-nuget@v1

    - name: Install nuget package
       run: nuget install ...........................

In the setup step, a nuget.exe file gets downloaded with the following hierarchy: C:\runners\runner-1\_work\_tool\nuget.exe\6.9.1\x64\nuget.exe The corresponding log is: Installed nuget.exe version 6.9.1

For the package install step, there is an error in the log: The system cannot execute the specified program. Error: Process completed with exit code 1.

When I located this file in the above machine, I see that the size of nuget.exe is 7KB. I opened a command prompt at that location and tried running the same executable. I get the same error - The system cannot execute the specified program.

I got a second machine which also has Windows-10, where I configured another runner and tried running a workflow. There the nuget install works as expected. Upon inspection, I see that the size of nuget.exe is 8257KB. This looks correct.

My questions here are:

  1. What is causing a corrupted nuget executable to get downloaded in the first machine? The log does not indicate any error in the setup step but a corrupted file is seen.

  2. The second machine has the same configuration as the first one. So, why is there a difference in behavior between the two machines?

  3. Is there some environmental setting which is a requirement for this action to work correctly and that happens to be missing in machine-1?

jeffkl commented 8 months ago

This GitHub action relies heavily on libraries for tasks like downloading files. We've recently released a v2 version which uses newer libraries. Can you try the latest?

    - name: Set up nuget.exe
      uses: nuget/setup-nuget@v2
rajkumar-bharathi commented 8 months ago

@jeffkl Thanks for the quick response.

After a little more digging, it turns out that the nuget.exe is actually not an executable but rather a html file. When I opened it in a text editor, there is a text stating - "Website Blocked". With help from the IT team, I got to know that policies were changed recently which blocked downloading exe files on the machine. When the URL: https://dist.nuget.org/win-x86-commandline/v6.9.1/nuget.exe was run in a browser, there was the same block. I finally got an exception for this machine and nuget download was allowed.

As per your suggestion, I'll upgrade to use version v2 going forward.