.NET 6.0 预览版、dotnet 包、Github 操作失败

Posted

技术标签:

【中文标题】.NET 6.0 预览版、dotnet 包、Github 操作失败【英文标题】:.NET 6.0 Preview, dotnet bundle, Github action fails 【发布时间】:2021-06-07 14:27:28 【问题描述】:

鉴于此(缩写)Github 工作流程

   steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-node@v2    
    - uses: actions/setup-dotnet@v1
      with:
        dotnet-version: '6.0.100-preview.4.21255.9'
        include-prerelease: true
    - uses: darenm/Setup-VSTest@v1

    - name: Build
      run: dotnet publish SendExplorerPlus.sln /p:Configuration=Release /p:PublishProfile=local /verbosity:minimal

当它尝试运行dotnet bundle时出现错误

Run dotnet publish SendExplorerPlus.sln /p:Configuration=Release /p:PublishProfile=local /verbosity:minimal

...
  Determining projects to restore...
  Restored D:\a\sendexplorer\sendexplorer\Portal2\Portal2.csproj (in 10.21 sec).
  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
  Portal2 -> D:\a\sendexplorer\sendexplorer\Portal2\bin\Release\net6.0\Portal2.dll
  It was not possible to find any compatible framework version
  The framework 'Microsoft.NETCore.App', version '2.0.0' was not found.
    - The following frameworks were found:
        6.0.0-preview.4.21253.7 at [C:\Users\runneradmin\AppData\Local\Microsoft\dotnet\shared\Microsoft.NETCore.App]
  
  You can resolve the problem by installing the specified framework and/or SDK.
  
  The specified framework can be found at:
     - https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=2.0.0&arch=x64&rid=win10-x64
D:\a\sendexplorer\sendexplorer\Portal2\Portal2.csproj(148,5): error MSB3073: The command "dotnet bundle" exited with code -2147450730.
Error: Process completed with exit code 1.

在过去的几个小时里,我一直在玩弄工作流程,但找不到解决方法。有什么想法吗?

【问题讨论】:

【参考方案1】:

我通过添加特定版本的 .NET SDK 解决了这个问题。即2.2.106。尝试了其他版本的 SDK,但我发现只有这个版本可以工作。

    - uses: actions/setup-dotnet@v1
      with:
        dotnet-version: '2.2.106'
    - uses: actions/setup-dotnet@v1
      with:
        dotnet-version: '6.0.100-preview.4.21255.9'
        include-prerelease: true

【讨论】:

以上是关于.NET 6.0 预览版、dotnet 包、Github 操作失败的主要内容,如果未能解决你的问题,请参考以下文章

找到 .NET SDK,但没有找到 dotnet.dll

NET 8 预览版 2 亮点是Blazor

dotnet core 6.0 配置使用log4net

dotnet core 6.0 配置使用log4net

.NET 7 预览版2 的亮点之 NativeAOT 回顾

.NET 7 预览版来啦,我升级体验了