【问题标题】:error MSB4019: The imported project "..../WebApplications\Microsoft.WebApplication.targets" was not found错误 MSB4019:未找到导入的项目“..../WebApplications\Microsoft.WebApplication.targets”
【发布时间】:2021-11-15 23:22:10
【问题描述】:

我的 Web API project 在 Visual Studio 中构建良好。我试图使用下面的 yml 在 github 工作流中设置 CI。

name: web-api-ci-pipeline

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  build-and-test:
    runs-on: windows-latest
    env:
      SOLUTIONPATH: celt2/API/CELTAPI.sln

    steps:
    - uses: actions/checkout@v2
    - name: Setup .NET
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: 5.0.x
    - name: Build code
      run: dotnet build ${{env.SOLUTIONPATH}}

但是,在构建步骤中,我遇到了以下错误:

D:\a\CELT2\CELT2\celt2\API\CELTAPI\CELTAPI.csproj(153,3): 错误 MSB4019:导入的项目 “C:\Users\runneradmin\AppData\Local\Microsoft\dotnet\sdk\5.0.401\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets” 没有找到。确认 Import 声明中的表达式 “C:\Users\runneradmin\AppData\Local\Microsoft\dotnet\sdk\5.0.401\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets” 是正确的,并且该文件存在于磁盘上。

CELTAPI.csproj:

谁能指出我做错了什么?

【问题讨论】:

  • hm,我记得这个...很久以前,我想我有一个类似的问题,可以通过检查构建服务器上配置的 Visual Studio 构建工具是否正确来解决。我建议你检查一下。

标签: asp.net-web-api msbuild continuous-integration build-server


【解决方案1】:

看起来您正在构建包含经典 ASP.NET(不是 ASP.NET Core)项目的分支之一,该项目不受 .NET SDK 支持。

如果您需要构建经典的 ASP.NET 应用程序,我建议使用 setup-msbuild 操作而不是 setup-dotnethttps://github.com/marketplace/actions/setup-msbuild 并运行 msbuild -p:Configuration=Release -restore ${{env.SOLUTIONPATH}} 代替

【讨论】:

    猜你喜欢
    • 2014-09-13
    • 2015-10-25
    • 1970-01-01
    • 1970-01-01
    • 2018-12-03
    • 2013-11-12
    • 2015-02-07
    • 2019-04-12
    • 1970-01-01
    相关资源
    最近更新 更多