我已经创建了一个战略/矩阵,在那里我试图在不同的环境中建立这个项目。
请在工作流yml文件下面找到:
jobs:
job_name_is_build:
runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: ["3.0", "3.1.x", "5.0.x"]
steps:
- name: checkout
uses: actions/checkout@v2
- name: Set up .Net Core SDK ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v1.7.2
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Display .net verion
run: dotnet --version
- name: Install Newtonsoft package
run: dotnet add WebApplication1/WebApplication1.csproj package Newtonsoft.Json --version 12.0.1
- name: Install dependencies
run: dotnet restore
- name: Build Solution
run: dotnet build --configuration Release --no-restore
- name: Run Unit Tests
run: dotnet test --no-restore --verbosity normal我已经创建了一个.Net核心5.0项目模板。
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>现在,当工作流程在Github操作中运行时,我在构建步骤中出现了错误:
没有找到".NETFramework,Version=v5.0“的引用程序集。您可能正在使用旧的.NET SDK来针对.NET 5.0或更高版本。更新和/或.NET SDK。
现在,我的查询是是否可以使用不同的SDK运行应用程序。对于Ex:我的项目在.Net核心5中,所以我不能使用.Net Core3.1使用策略/矩阵构建相同的项目?
发布于 2021-07-05 11:15:12
.NET 5.0了解DOTNetCore3.1,但不了解其他方式。因此,如果在您的计算机上安装了.NET 5.0,您应该能够构建针对3.1的应用程序,而不是另一种方式。
但是,这不仅仅是这个<TargetFramework>net5.0</TargetFramework>的问题,因为在.net 5中,您的依赖项也可能被编译成一个固定的版本。在您的示例中,不可能根据这些sdk的"3.0“、"3.1.x”编译.NET 5.0应用程序。
请也检查一下this。
发布于 2021-07-06 02:37:46
您可以使用dotnet restore/build/test的--framework参数来覆盖TargetFramework
dotnet build --configuration Release --no-restore --framework netcoreapp3.0
dotnet build --configuration Release --no-restore --framework netcoreapp3.1
dotnet build --configuration Release --no-restore --framework net5.0您可以将这些添加到矩阵声明中。
https://stackoverflow.com/questions/68247568
复制相似问题