2

My web API project builds fine from Visual Studio. I was trying to setup the CI in the github workflows using below yml.

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}}

But, in the build step I am getting below error:

D:\a\CELT2\CELT2\celt2\API\CELTAPI\CELTAPI.csproj(153,3): error MSB4019: The imported project "C:\Users\runneradmin\AppData\Local\Microsoft\dotnet\sdk\5.0.401\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the expression in the Import declaration "C:\Users\runneradmin\AppData\Local\Microsoft\dotnet\sdk\5.0.401\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" is correct, and that the file exists on disk.

enter image description here

CELTAPI.csproj:

enter image description here

Can anyone please point me out what am I doing wrong?

Setu Kumar Basak
  • 11,460
  • 9
  • 53
  • 85
  • hm, I could remember this...long time ago, I think I had a similar problem, which could be solved to check the visual studio build tools correct configured on the build-server. I suggest you check them. – DotNetDev Sep 23 '21 at 19:55

1 Answers1

1

It looks like you are building one of the branches that contain a classic ASP.NET (not ASP.NET Core) project, which is unsupported by the .NET SDK.

If you need to build classic ASP.NET Applications, I recommend using the setup-msbuild action instead of setup-dotnethttps://github.com/marketplace/actions/setup-msbuild and run msbuild -p:Configuration=Release -restore ${{env.SOLUTIONPATH}} instead

Martin Ullrich
  • 94,744
  • 25
  • 252
  • 217