brandedoutcast / publish-nuget

📦 GitHub action to automate publishing NuGet packages when project version changes
https://github.com/marketplace/actions/publish-nuget
MIT License
197 stars 101 forks source link

[BUG] Error: 😭 error: File does not exist (1). #76

Open VAllens opened 2 years ago

VAllens commented 2 years ago

The push was successful, but I received an exception:

Error: 😭 error: File does not exist (1).

My publish.yml:

name: NuGet Publish

on:
  pull_request:
    branches: [ main ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Setup .NET
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: 6.0.x
    - name: Restore Obfuscation.Fody project dependencies
      run: dotnet restore src/Obfuscation.Fody/Obfuscation.Fody.csproj
    - name: Restore Obfuscation.Fody.NuGet project dependencies
      run: dotnet restore src/Obfuscation.Fody.NuGet/Obfuscation.Fody.NuGet.csproj
    - name: Build Obfuscation.Fody project
      run: dotnet build src/Obfuscation.Fody/Obfuscation.Fody.csproj --no-restore --configuration Release
    - name: Build Obfuscation.Fody.NuGet project
      run: dotnet build src/Obfuscation.Fody.NuGet/Obfuscation.Fody.NuGet.csproj --no-restore --configuration Release
    - name: Pack Obfuscation.Fody.NuGet project
      run: dotnet pack src/Obfuscation.Fody.NuGet/Obfuscation.Fody.NuGet.csproj --no-build --configuration Release
    - name: publish nuget package on version change
      uses: rohith/publish-nuget@v2
      with:
        PROJECT_FILE_PATH: src/Obfuscation.Fody.NuGet/Obfuscation.Fody.NuGet.csproj
        PACKAGE_NAME: Obfuscation.Fody
        VERSION_FILE_PATH: Directory.Build.props
        NUGET_KEY: ${{secrets.NUGET_API_KEY}}

console log:

Project Filepath: src/Obfuscation.Fody.NuGet/Obfuscation.Fody.NuGet.csproj
Version Filepath: Directory.Build.props
Version Regex: /^\s*<Version>(.*)<\/Version>\s*$/m
Version: 1.0.0
Package Name: Obfuscation.Fody
✨ found new version (1.0.0) of Obfuscation.Fody
NuGet Source: https://api.nuget.org
executing: [dotnet build -c Release src/Obfuscation.Fody.NuGet/Obfuscation.Fody.NuGet.csproj]
Microsoft (R) Build Engine version 17.1.0+ae57d105c for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  All projects are up-to-date for restore.
  Obfuscation.Fody.NuGet -> /home/runner/work/Obfuscation.Fody/Obfuscation.Fody/src/Obfuscation.Fody.NuGet/bin/Release/Obfuscation.FodyHelper.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.94
executing: [dotnet pack  --no-build -c Release src/Obfuscation.Fody.NuGet/Obfuscation.Fody.NuGet.csproj -o .]
Microsoft (R) Build Engine version 17.1.0+ae57d105c for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Successfully created package '/home/runner/work/Obfuscation.Fody/Obfuscation.Fody/Obfuscation.Fody.1.0.0.nupkg'.
  OutputPackageDir: ../../packages
  NuPkgFiles: /home/runner/work/Obfuscation.Fody/Obfuscation.Fody/src/Obfuscation.Fody.NuGet/bin/Release/Obfuscation.Fody.1.0.0.nupkg
  Copy /home/runner/work/Obfuscation.Fody/Obfuscation.Fody/src/Obfuscation.Fody.NuGet/bin/Release/Obfuscation.Fody.1.0.0.nupkg to ../../packages successfully
Generated Package(s): Obfuscation.Fody.1.0.0.nupkg
executing: [dotnet nuget push *.nupkg -s https://api.nuget.org/v3/index.json -k *** --skip-duplicate -n 1]
Pushing Obfuscation.Fody.1.0.0.nupkg to 'https://www.nuget.org/api/v2/package'...
  PUT https://www.nuget.org/api/v2/package/
  Created https://www.nuget.org/api/v2/package/ 704ms
Your package was pushed.
error: File does not exist (1).

Usage: dotnet nuget push [arguments] [options]

Arguments:
  [root]  Specify the path to the package and your API key to push the package to the server.

Options:
  -h|--help                      Show help information
  --force-english-output         Forces the application to run using an invariant, English-based culture.
  -s|--source <source>           Package source (URL, UNC/folder path or package source name) to use. Defaults to DefaultPushSource if specified in NuGet.Config.
  -ss|--symbol-source <source>   Symbol server URL to use.
  -t|--timeout <timeout>         Timeout for pushing to a server in seconds. Defaults to 300 seconds (5 minutes).
  -k|--api-key <apiKey>          The API key for the server.
  -sk|--symbol-api-key <apiKey>  The API key for the symbol server.
  -d|--disable-buffering         Disable buffering when pushing to an HTTP(S) server to decrease memory usage.
  -n|--no-symbols                If a symbols package exists, it will not be pushed to a symbols server.
  --no-service-endpoint          Does not append "api/v2/package" to the source URL.
  --interactive                  Allow the command to block and require manual action for operations like authentication.
  --skip-duplicate               If a package and version already exists, skip it and continue with the next package in the push, if any.

Error: 😭 error: File does not exist (1).
/home/runner/work/_actions/rohith/publish-nuget/v2/index.js:23
        throw new Error(msg)
        ^

Error: error: File does not exist (1).
    at Action._printErrorAndExit (/home/runner/work/_actions/rohith/publish-nuget/v2/index.js:23:[15](https://github.com/VAllens/Obfuscation.Fody/runs/5226354030?check_suite_focus=true#step:9:15))
    at Action._pushPackage (/home/runner/work/_actions/rohith/publish-nuget/v2/index.js:73:18)
    at ClientRequest.<anonymous> (/home/runner/work/_actions/rohith/publish-nuget/v2/index.js:101:22)
    at Object.onceWrapper (events.js:300:26)
    at ClientRequest.emit (events.js:210:5)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:583:27)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:115:[17](https://github.com/VAllens/Obfuscation.Fody/runs/5226354030?check_suite_focus=true#step:9:17))
    at TLSSocket.socketOnData (_http_client.js:456:22)
    at TLSSocket.emit (events.js:[21](https://github.com/VAllens/Obfuscation.Fody/runs/5226354030?check_suite_focus=true#step:9:21)0:5)
    at addChunk (_stream_readable.js:[30](https://github.com/VAllens/Obfuscation.Fody/runs/5226354030?check_suite_focus=true#step:9:30)9:12)

here: https://github.com/VAllens/Obfuscation.Fody/runs/5226354030?check_suite_focus=true

AddictedCS commented 2 years ago

Got the same problem.

Retrodad0001 commented 2 years ago

Got the same issue.. Nothing has changed in my action script

capdiem commented 2 years ago

Same issue

capdiem commented 2 years ago

https://github.com/NuGet/Home/issues/11601 This seems to be a problem with nuget. I don't know what version of nuget the dotnet nuget command uses. If it is up-to-date every time, this problem may be solved with the update of the version of nuget.

thomaswormald commented 2 years ago

Same problem here. I have fixed it by removing references to this project and just pushing manually.

I previously had this in my workflow file:

    - name: Publish NuGet
      uses: brandedoutcast/publish-nuget@v2.5.5
      with:
        PROJECT_FILE_PATH: src/GrpcBrowser/GrpcBrowser.csproj
        PACKAGE_NAME: GrpcBrowser
        VERSION_FILE_PATH: src/GrpcBrowser/GrpcBrowser.csproj
        VERSION_REGEX: \s*<Version>(.*)<\/Version>\s*
        NUGET_KEY: ${{ secrets.NUGET_KEY }}

And I have replaced it with this:

    - name: Package
      run: dotnet pack -c Release -o . GrpcBrowser/GrpcBrowser.csproj
    - name: Publish
      run: dotnet nuget push *.nupkg -k ${{ secrets.NUGET_KEY }} -s https://api.nuget.org/v3/index.json
VAllens commented 2 years ago

Same problem here. I have fixed it by removing references to this project and just pushing manually.

I previously had this in my workflow file:

    - name: Publish NuGet
      uses: brandedoutcast/publish-nuget@v2.5.5
      with:
        PROJECT_FILE_PATH: src/GrpcBrowser/GrpcBrowser.csproj
        PACKAGE_NAME: GrpcBrowser
        VERSION_FILE_PATH: src/GrpcBrowser/GrpcBrowser.csproj
        VERSION_REGEX: \s*<Version>(.*)<\/Version>\s*
        NUGET_KEY: ${{ secrets.NUGET_KEY }}

And I have replaced it with this:

    - name: Package
      run: dotnet pack -c Release -o . GrpcBrowser/GrpcBrowser.csproj
    - name: Publish
      run: dotnet nuget push *.nupkg -k ${{ secrets.NUGET_KEY }} -s https://api.nuget.org/v3/index.json

Missing git tag

Retrodad0001 commented 2 years ago

Same problem here. I have fixed it by removing references to this project and just pushing manually. I previously had this in my workflow file:

    - name: Publish NuGet
      uses: brandedoutcast/publish-nuget@v2.5.5
      with:
        PROJECT_FILE_PATH: src/GrpcBrowser/GrpcBrowser.csproj
        PACKAGE_NAME: GrpcBrowser
        VERSION_FILE_PATH: src/GrpcBrowser/GrpcBrowser.csproj
        VERSION_REGEX: \s*<Version>(.*)<\/Version>\s*
        NUGET_KEY: ${{ secrets.NUGET_KEY }}

And I have replaced it with this:

    - name: Package
      run: dotnet pack -c Release -o . GrpcBrowser/GrpcBrowser.csproj
    - name: Publish
      run: dotnet nuget push *.nupkg -k ${{ secrets.NUGET_KEY }} -s https://api.nuget.org/v3/index.json

Missing git tag

Also checking if never version then check in else ignore?

Retrodad0001 commented 2 years ago

Also fixed it with doing it manual like @VAllens.. I used this (for .net):

`name: Release Master NuGet

on: push: branches: [ master ]

jobs: Release: name: Release to Nuget runs-on: ubuntu-latest timeout-minutes: 10

steps:
- name: Check out Repo
  uses: actions/checkout@v2

- name: Setup dotnet
  uses: actions/setup-dotnet@v1
  with:
    dotnet-version: 6.0.x

- name: Pack
  run: dotnet pack EasyDbMigrator\\EasyDbMigrator.csproj -c Release

- name: Publish to GitHub packages 
  run: dotnet nuget push /home/runner/work/EasyDbMigrator/EasyDbMigrator/EasyDbMigrator/bin/Release/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate`
VAllens commented 2 years ago

还修复了它,像@VAllens一样手动完成。我用了这个(对于.net):

'名称: 发布主 NuGet

on: 推: 分支: [ 主 ]

作业: 发布: 名称: 发布到 Nuget 运行:ubuntu 最新超时分钟数: 10

steps:
- name: Check out Repo
  uses: actions/checkout@v2

- name: Setup dotnet
  uses: actions/setup-dotnet@v1
  with:
    dotnet-version: 6.0.x

- name: Pack
  run: dotnet pack EasyDbMigrator\\EasyDbMigrator.csproj -c Release

- name: Publish to GitHub packages 
  run: dotnet nuget push /home/runner/work/EasyDbMigrator/EasyDbMigrator/EasyDbMigrator/bin/Release/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate`

Good job. Me too.

name: NuGet Publish

on:
  pull_request:
    types: [ closed ]
    branches: [ main ]

jobs:
  build:

    runs-on: ubuntu-latest
    if: github.event.pull_request.merged == true
    steps:
    - uses: actions/checkout@v2
    - name: Setup .NET
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: 6.0.x
    - name: Restore Obfuscation.Tasks project dependencies
      run: dotnet restore src/Obfuscation.Tasks/Obfuscation.Tasks.csproj
    - name: Build Obfuscation.Tasks project
      run: dotnet build src/Obfuscation.Tasks/Obfuscation.Tasks.csproj --no-restore --configuration Release
    - name: Pack Obfuscation.Tasks project
      run: dotnet pack src/Obfuscation.Tasks/Obfuscation.Tasks.csproj --no-build --configuration Release --include-symbols -p:SymbolPackageFormat=snupkg -o .
    - name: Publish package to NuGet
      run: dotnet nuget push *.nupkg --api-key ${{secrets.NUGET_API_KEY}} --source "https://api.nuget.org/v3/index.json" --skip-duplicate
    - name: publish package to GitHub
      run: dotnet nuget push *.nupkg --api-key ${{secrets.PUBLISH_TO_GITHUB_TOKEN}} --source "https://nuget.pkg.github.com/VAllens/index.json" --skip-duplicate
Kurpanik commented 2 years ago

Same issue here, however, the packaged was published successfully

Peter-B- commented 2 years ago

Same error message with the package being published successfully.

I recently changed from .net 5 to 6:

   steps:
    - name: Setup .NET
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: 5.0.x

to

   steps:
    - name: Setup .NET
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: 6.0.x

Maybe that triggered the error message.

YounesCheikh commented 2 years ago

For those having the same problem, It seems to be a dotnet 6 topic. The problem is with the option -n (no symbols). In previous versions of dotnet , using this parameter requires a value (true or false, 1 or 0). Since dotnet 6.0.102 -> 6.0.200 the value is not required anymore.

This is even written in the doc or on the help output for dotnet nuget push --help -n|--no-symbols If a symbols package exists, it will not be pushed to a symbols server.

More info here

Kurounin commented 2 years ago

You can use version 3.0.3 of this fork https://github.com/alirezanet/publish-nuget which among others includes a fix for this issue

wbaldoumas commented 2 years ago

You can use version 3.0.1 of this fork https://github.com/alirezanet/publish-nuget which among others includes a fix for this issue

There are a mountain of forks for this action. It would be really great if we identified and settled on one as the new "source of truth" for publishing to NuGet from GitHub Actions, since this repository seems to be abandoned.

YounesCheikh commented 2 years ago

You can use version 3.0.1 of this fork https://github.com/alirezanet/publish-nuget which among others includes a fix for this issue

There are a mountain of forks for this action. It would be really great if we identified and settled on one as the new "source of truth" for publishing to NuGet from GitHub Actions, since this repository seems to be abandoned.

I still don't see why use a Github action to push to nuget while you can achieve that by writing some lines? I abandoned the usage of this action and I'm using a native dotnet commands to push to nuget

VAllens commented 2 years ago

您可以使用此分叉 https://github.com/alirezanet/publish-nuget 版本3.0.1,其中包括针对此问题的修复程序

这个动作有一堆叉子。如果我们确定并确定一个作为从 GitHub Actions 发布到 NuGet 的新"事实源",那将非常棒,因为此存储库似乎已被放弃。

我仍然不明白为什么使用Github操作来推送到nuget,而您可以通过编写一些行来实现这一点?我放弃了使用此操作,并且我正在使用本机dotnet命令推送到nuget

I'm now also using dotnet command to push to nuget. The plugin, which has the advantage of Automatically git tag

Kurounin commented 2 years ago

You can use version 3.0.1 of this fork https://github.com/alirezanet/publish-nuget which among others includes a fix for this issue

There are a mountain of forks for this action. It would be really great if we identified and settled on one as the new "source of truth" for publishing to NuGet from GitHub Actions, since this repository seems to be abandoned.

I still don't see why use a Github action to push to nuget while you can achieve that by writing some lines? I abandoned the usage of this action and I'm using a native dotnet commands to push to nuget

The advantage is that it checks whether the version in .csproj was modified and only runs build, pack, publish and then git tag if necessary.

ThomasWillumsen commented 2 years ago

This is still an issue.

Kurpanik commented 2 years ago

This is still an issue.

There is a good fork of it. Simply replace this part in your workflow with alirezanet/publish-nuget@v3.0.4 and your are done

ThomasWillumsen commented 2 years ago

Yeah I'll either do that or just drop it and use dotnet nuget push. Thanks.

Kurpanik commented 2 years ago

If other functions of this workflow like tagging are not needed, using dotnet nuget push directly is of course a viable and probably a better option :)

KursatSonmez commented 2 years ago

Problem solved for me. Your dotnet-version of the job is must be same to dotnet version of your project. dotnet version of my project is 5.0 but dotnet version in my job is 6.0.x. I changed version 6.0.x to 5.0.x in the job.