如何使用 azure 管道为我的 aspnetcore 3.0 项目(发布到 IIS)启用 CI/CD

How do I enable CI/CD for my aspnetcore 3.0 project (publish to IIS) using azure pipelines

我正在尝试为我的 aspnetcore 3.0 项目构建一个 'build pipeline'。 我已经有一个 IIS 服务 运行 并将其添加到部署组。

关于该应用程序的一些信息: - ASP.NET 核心 3.0.0-preview8 - 多个web项目,一个DAL项目和一个Core项目 - 一个 git 多个网站项目的回购

我需要什么? - 构建项目 - 测试项目 - 将项目发布到 IIS - 确保绑定项目以正确的 IIS 绑定(例如 api 项目应该绑定到 API IIS 网站)

我试过使用一些模板,但没有用。 我已经尝试过手动操作。 我尝试了多种配置。

# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core

trigger:
- master

pool:
  vmImage: 'windows-latest'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: UseDotNet@2
  inputs:
    packageType: 'sdk'
    version: '3.x'
    includePreviewVersions: true
- task: DotNetCoreCLI@2
  inputs:
    command: 'restore'
    projects: '**/*.csproj'
    feedsToUse: 'select'
    vstsFeed: '5739229b-68fa-4856-aa1c-1b52808407ae'
    noCache: true
- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'


- task: DotNetCoreCLI@2
  inputs:
    command: publish
    publishWebProjects: True
    arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
    zipAfterPublish: True
- task: IISWebAppDeploymentOnMachineGroup@0
  inputs:
    WebSiteName: 'teachers.dapperdino.co.uk'
    VirtualApplication: 'teachers.dapperdino.co.uk'
    Package: '$(System.DefaultWorkingDirectory)\**\*.zip'

我希望网站能够发布,但没有发布。 输出为:

##[section]Starting: DotNetCoreCLI
==============================================================================
Task         : .NET Core
Description  : Build, test, package, or publish a dotnet application, or run a custom dotnet command
Version      : 2.156.1
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli
==============================================================================
[command]C:\windows\system32\chcp.com 65001
Active code page: 65001
[command]C:\hostedtoolcache\windows\dotnet\dotnet.exe publish d:\a\s\DapperDino.Web.Ideas\DapperDino.Web.Ideas.csproj --configuration Release --output d:\a\a\DapperDino.Web.Ideas
Microsoft (R) Build Engine version 16.3.0-preview-19377-01+dd8019d9e for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 197.49 ms for d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj.
  Restore completed in 296.18 ms for d:\a\s\DapperDino.Core\DapperDino.Core.csproj.
  Restore completed in 124.99 ms for d:\a\s\DapperDino.Jobs\DapperDino.Jobs.csproj.
  Restore completed in 133.69 ms for d:\a\s\DapperDino.Web.Ideas\DapperDino.Web.Ideas.csproj.
  You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview
  You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview
C:\hostedtoolcache\windows\dotnet\sdk.0.100-preview8-013656\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.AspNetCore.Identity.EntityFrameworkCore". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj]
C:\hostedtoolcache\windows\dotnet\sdk.0.100-preview8-013656\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.Extensions.Identity.Stores". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj]
ApplicationDbContext.cs(2,17): error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj]
Models\ApplicationUser.cs(3,17): error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj]
Roles.cs(4,17): error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj]
Roles.cs(13,30): error CS0246: The type or namespace name 'IdentityRole' could not be found (are you missing a using directive or an assembly reference?) [d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj]
ApplicationDbContext.cs(9,41): error CS0246: The type or namespace name 'IdentityDbContext<>' could not be found (are you missing a using directive or an assembly reference?) [d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj]
Models\ApplicationUser.cs(9,36): error CS0246: The type or namespace name 'IdentityUser' could not be found (are you missing a using directive or an assembly reference?) [d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj]
ApplicationDbContext.cs(21,33): error CS0115: 'ApplicationDbContext.OnModelCreating(ModelBuilder)': no suitable method found to override [d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj]
ApplicationDbContext.cs(11,76): error CS0311: The type 'DapperDino.DAL.ApplicationDbContext' cannot be used as type parameter 'TContext' in the generic type or method 'DbContextOptions<TContext>'. There is no implicit reference conversion from 'DapperDino.DAL.ApplicationDbContext' to 'Microsoft.EntityFrameworkCore.DbContext'. [d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj]
Roles.cs(8,35): error CS0246: The type or namespace name 'IdentityRole' could not be found (are you missing a using directive or an assembly reference?) [d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj]
##[error]Error: The process 'C:\hostedtoolcache\windows\dotnet\dotnet.exe' failed with exit code 1
[command]C:\hostedtoolcache\windows\dotnet\dotnet.exe publish d:\a\s\DapperDino.Web.RoleManager\DapperDino.Web.RoleManager.csproj --configuration Release --output d:\a\a\DapperDino.Web.RoleManager
Microsoft (R) Build Engine version 16.3.0-preview-19377-01+dd8019d9e for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 26.28 ms for d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj.
  Restore completed in 28.19 ms for d:\a\s\DapperDino.Core\DapperDino.Core.csproj.
  Restore completed in 304.79 ms for d:\a\s\DapperDino.Web.RoleManager\DapperDino.Web.RoleManager.csproj.
  You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview
  You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview
C:\hostedtoolcache\windows\dotnet\sdk.0.100-preview8-013656\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.AspNetCore.Identity.EntityFrameworkCore". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj]
C:\hostedtoolcache\windows\dotnet\sdk.0.100-preview8-013656\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.Extensions.Identity.Stores". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj]
ApplicationDbContext.cs(2,17): error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj]
Models\ApplicationUser.cs(3,17): error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj]
Roles.cs(4,17): error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj]
ApplicationDbContext.cs(9,41): error CS0246: The type or namespace name 'IdentityDbContext<>' could not be found (are you missing a using directive or an assembly reference?) [d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj]
ApplicationDbContext.cs(21,33): error CS0115: 'ApplicationDbContext.OnModelCreating(ModelBuilder)': no suitable method found to override [d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj]
ApplicationDbContext.cs(11,76): error CS0311: The type 'DapperDino.DAL.ApplicationDbContext' cannot be used as type parameter 'TContext' in the generic type or method 'DbContextOptions<TContext>'. There is no implicit reference conversion from 'DapperDino.DAL.ApplicationDbContext' to 'Microsoft.EntityFrameworkCore.DbContext'. [d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj]
Roles.cs(13,30): error CS0246: The type or namespace name 'IdentityRole' could not be found (are you missing a using directive or an assembly reference?) [d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj]
Models\ApplicationUser.cs(9,36): error CS0246: The type or namespace name 'IdentityUser' could not be found (are you missing a using directive or an assembly reference?) [d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj]
Roles.cs(8,35): error CS0246: The type or namespace name 'IdentityRole' could not be found (are you missing a using directive or an assembly reference?) [d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj]
##[error]Error: The process 'C:\hostedtoolcache\windows\dotnet\dotnet.exe' failed with exit code 1
[command]C:\hostedtoolcache\windows\dotnet\dotnet.exe publish d:\a\s\DapperDino.Web.Teacher\DapperDino.Web.Teacher.csproj --configuration Release --output d:\a\a\DapperDino.Web.Teacher
Microsoft (R) Build Engine version 16.3.0-preview-19377-01+dd8019d9e for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 24.95 ms for d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj.
  Restore completed in 30.07 ms for d:\a\s\DapperDino.Core\DapperDino.Core.csproj.
  Restore completed in 2.06 ms for d:\a\s\DapperDino.Jobs\DapperDino.Jobs.csproj.
  Restore completed in 414.17 ms for d:\a\s\DapperDino.Web.Teacher\DapperDino.Web.Teacher.csproj.
  You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview
  You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview
C:\hostedtoolcache\windows\dotnet\sdk.0.100-preview8-013656\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.AspNetCore.Identity.EntityFrameworkCore". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj]
C:\hostedtoolcache\windows\dotnet\sdk.0.100-preview8-013656\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.Extensions.Identity.Stores". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj]
ApplicationDbContext.cs(2,17): error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj]
Models\ApplicationUser.cs(3,17): error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj]
Roles.cs(4,17): error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj]
ApplicationDbContext.cs(9,41): error CS0246: The type or namespace name 'IdentityDbContext<>' could not be found (are you missing a using directive or an assembly reference?) [d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj]
ApplicationDbContext.cs(21,33): error CS0115: 'ApplicationDbContext.OnModelCreating(ModelBuilder)': no suitable method found to override [d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj]
ApplicationDbContext.cs(11,76): error CS0311: The type 'DapperDino.DAL.ApplicationDbContext' cannot be used as type parameter 'TContext' in the generic type or method 'DbContextOptions<TContext>'. There is no implicit reference conversion from 'DapperDino.DAL.ApplicationDbContext' to 'Microsoft.EntityFrameworkCore.DbContext'. [d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj]
Roles.cs(13,30): error CS0246: The type or namespace name 'IdentityRole' could not be found (are you missing a using directive or an assembly reference?) [d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj]
Models\ApplicationUser.cs(9,36): error CS0246: The type or namespace name 'IdentityUser' could not be found (are you missing a using directive or an assembly reference?) [d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj]
Roles.cs(8,35): error CS0246: The type or namespace name 'IdentityRole' could not be found (are you missing a using directive or an assembly reference?) [d:\a\s\DapperDino.DAL\DapperDino.DAL.csproj]
##[error]Error: The process 'C:\hostedtoolcache\windows\dotnet\dotnet.exe' failed with exit code 1
##[error]Dotnet command failed with non-zero exit code on the following projects : d:\a\s\DapperDino.Web.Ideas\DapperDino.Web.Ideas.csproj,d:\a\s\DapperDino.Web.RoleManager\DapperDino.Web.RoleManager.csproj,d:\a\s\DapperDino.Web.Teacher\DapperDino.Web.Teacher.csproj
##[section]Finishing: DotNetCoreCLI

csproj 文件: 达尔:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Compile Remove="Migrations181223043623_test.cs" />
    <Compile Remove="Migrations190103040438_orders.cs" />
    <Compile Remove="Migrations190602225729_test-migration.cs" />
    <Compile Remove="Migrations190602225729_test-migration.Designer.cs" />
    <Compile Remove="Migrations190622040133_product-download-link.cs" />
    <Compile Remove="Migrations190622040133_product-download-link.Designer.cs" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.0.0-preview8.19405.7" />
    <PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.0.0-preview8.19405.7" />
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.0.0-preview8.19405.11" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.0.0-preview8.19405.11">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0-preview8.19405.11" />
  </ItemGroup>


  <ItemGroup>
    <Folder Include="Policies\" />
  </ItemGroup>

</Project>

核心:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="..\DapperDino.DAL\DapperDino.DAL.csproj" />
  </ItemGroup>

  <ItemGroup>
    <Folder Include="Services\" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="DSharpPlus" Version="3.2.3" />
  </ItemGroup>

</Project>

职位:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Hangfire" Version="1.7.6" />
    <PackageReference Include="Microsoft.AspNetCore.SignalR" Version="1.1.0" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\DapperDino.DAL\DapperDino.DAL.csproj" />
  </ItemGroup>

</Project>

想法

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <LangVersion>7.3</LangVersion>
    <UserSecretsId>aspnet-DapperDino.Web.Ideas-D02C48DF-E6AA-418E-B7D1-0F9B0601AF20</UserSecretsId>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.0.0-preview8.19405.7" />
    <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.0.0-preview8.19405.7" />
    <PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.0.0-preview8.19405.7" />
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.0.0-preview8.19405.11" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0-preview8.19405.11" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.0-preview8.19405.11">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\DapperDino.Core\DapperDino.Core.csproj" />
    <ProjectReference Include="..\DapperDino.DAL\DapperDino.DAL.csproj" />
    <ProjectReference Include="..\DapperDino.Jobs\DapperDino.Jobs.csproj" />
  </ItemGroup>

</Project>

角色经理:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <LangVersion>7.3</LangVersion>
    <UserSecretsId>aspnet-DapperDino.Web.RoleManager-DECFF1C6-FEE3-483B-9C80-C0D6BF8579BD</UserSecretsId>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.0.0-preview8.19405.7" />
    <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.0.0-preview8.19405.7" />
    <PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.0.0-preview8.19405.7" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0-preview8.19405.11" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.0-preview8.19405.11">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\DapperDino.Core\DapperDino.Core.csproj" />
    <ProjectReference Include="..\DapperDino.DAL\DapperDino.DAL.csproj" />
  </ItemGroup>

  <ItemGroup>
    <Folder Include="Data\" />
  </ItemGroup>

</Project>

学生:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <LangVersion>7.3</LangVersion>
    <UserSecretsId>aspnet-DapperDino.Web.Student-BFD60CA3-10A3-4BAA-B5CE-9B284B72E3EC</UserSecretsId>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.0.0-preview8.19405.7" />
    <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.0.0-preview8.19405.7" />
    <PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.0.0-preview8.19405.7" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0-preview8.19405.11" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.0-preview8.19405.11">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>

  <ItemGroup>
    <Folder Include="Data\" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\DapperDino.DAL\DapperDino.DAL.csproj" />
  </ItemGroup>

</Project>

老师:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <LangVersion>7.3</LangVersion>
    <UserSecretsId>aspnet-DapperDino.Web.Teacher-CEB46A90-EAD8-4B53-974D-70B4CED675C7</UserSecretsId>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Blazor.Extensions.SignalR" Version="0.2.0" />
    <PackageReference Include="DSharpPlus" Version="3.2.3" />
    <PackageReference Include="Markdig" Version="0.17.1" />
    <PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.0.0-preview8.19405.7" />
    <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.0.0-preview8.19405.7" />
    <PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.0.0-preview8.19405.7" />
    <PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="3.0.0-preview8.19405.7" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.0.0-preview8.19405.11">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0-preview8.19405.11" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.0-preview8.19405.11">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\DapperDino.Core\DapperDino.Core.csproj" />
    <ProjectReference Include="..\DapperDino.DAL\DapperDino.DAL.csproj" />
    <ProjectReference Include="..\DapperDino.Jobs\DapperDino.Jobs.csproj" />
  </ItemGroup>

</Project>

我相信发生的情况是您的任务不会为后续步骤保留其状态,即您在一个任务中安装 .NET Core 3,但在尝试 运行 下一个任务时它丢失了,因此它找不到任何依赖项。

我们可以使用包含所有步骤(任务)的作业来解决这个问题。如果您在这个职位下面添加另一个职位,它会重新开始。

trigger:
- master

jobs:
- job: Build
  displayName: 'Install, Test, Publish'
  timeoutInMinutes: 15
  pool:
    vmImage: 'windows-latest'
  variables:
    solution: '**/*.sln'
    buildPlatform: 'Any CPU'
    buildConfiguration: 'Release'

  steps:
  # 1. Install .NET SDK 3.x
  - task: UseDotNet@2
    displayName: 'Install .NET SDK 3.x'
    inputs:
      version: 3.x
      includePreviewVersions: true

  # 2. Restore
  - task: DotNetCoreCLI@2
    inputs:
      command: 'restore'
      projects: '**/*.csproj'
      feedsToUse: 'select'
      vstsFeed: '5739229b-68fa-4856-aa1c-1b52808407ae'
      noCache: true

  # 3. Run Tests
  - task: VSTest@2
    inputs:
      platform: '$(buildPlatform)'
      configuration: '$(buildConfiguration)'

  # 4. Publish
  - task: DotNetCoreCLI@2
    inputs:
      command: publish
      publishWebProjects: True
      arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
      zipAfterPublish: True

  # 5. Deploy
  - task: IISWebAppDeploymentOnMachineGroup@0
    inputs:
      WebSiteName: 'teachers.dapperdino.co.uk'
      VirtualApplication: 'teachers.dapperdino.co.uk'
      Package: '$(System.DefaultWorkingDirectory)\**\*.zip'`enter code here`

注意:您也可以通过以下方式 运行 测试任务(您可能需要对其进行一些修改):

  # 3. Run Tests
  - task: DotNetCoreCLI@2
    displayName: 'Execute Tests'
    inputs:
      command: 'test'
      projects: '**/*.csproj'
      arguments: '--configuration release'

并不是说这是首选方式,但如果 VSTest@2 由于某种原因不兼容,它可能会指导您朝着正确的方向前进。

愚蠢的我忘记签入,将包版本从预览 7 切换到 8....