Github 操作对 .net git Restore buld 使用存储库名称两次

发布于 2025-01-19 16:10:51 字数 1073 浏览 2 评论 0原文

鉴于此工作流程和代码目录

Repo:RepoName

.github/workflow/workflow.file
.git
Src/Demo/Demo.csproj
Test
Demo.Sln

此工作流程在执行 dotnet 恢复时使用两次 RepoName 的恢复命令失败

name: Demo
env:
  DOTNET_CLI_TELEMETRY_OPTOUT: 1
on:
  push:
    paths:
      - 'Src/**'
      - 'Tests/**'
      - 'Demo.sln'      
      - '**/demo-workflow.yml'  
  workflow_dispatch:
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Check out code
        uses: actions/checkout@v2   
      

      - name: Install .NET Core SDK
        uses: actions/setup-dotnet@v1
        with:
          dotnet-version: '5.0.x'
    
      - name: Restore NuGet packages
        run: dotnet restore

收到错误:/home/runner/.dotnet/sdk/5.0.406/NuGet.targets(290,5):错误 MSB3202:项目文件找不到“/home/runner/work/RepoName/RepoName/Src/WebApi/WebApi.csproj”。 [/home/runner/work/RepoName/RepoName/PaymentGateway.sln]

的变体

  • 尝试了dotnet Restore 'Demo.sln'
  • dotnet Restore '/Demo.sln'
  • dotnet Restore '**/Demo.sln'

Given this workflow and Code directory

Repo: RepoName

.github/workflow/workflow.file
.git
Src/Demo/Demo.csproj
Test
Demo.Sln

This workflow fails on the restore command with RepoName used twice when doing dotnet restore

name: Demo
env:
  DOTNET_CLI_TELEMETRY_OPTOUT: 1
on:
  push:
    paths:
      - 'Src/**'
      - 'Tests/**'
      - 'Demo.sln'      
      - '**/demo-workflow.yml'  
  workflow_dispatch:
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Check out code
        uses: actions/checkout@v2   
      

      - name: Install .NET Core SDK
        uses: actions/setup-dotnet@v1
        with:
          dotnet-version: '5.0.x'
    
      - name: Restore NuGet packages
        run: dotnet restore

Error received: /home/runner/.dotnet/sdk/5.0.406/NuGet.targets(290,5): error MSB3202: The project file "/home/runner/work/RepoName/RepoName/Src/WebApi/WebApi.csproj" was not found. [/home/runner/work/RepoName/RepoName/PaymentGateway.sln]

Tried variations of

  • dotnet restore 'Demo.sln'
  • dotnet restore '/Demo.sln'
  • dotnet restore '**/Demo.sln'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暗恋未遂 2025-01-26 16:10:51

这是正确的行为。

我做到了

run: |
    ls ${{github.workspace}}

,它揭示了某些代码不在该分支机构中

This is the correct behaviour.

I did

run: |
    ls ${{github.workspace}}

and it revealed that some code were not in that branch

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文