Build failure for a simple Hello World web application error MSB4019: The imported project was not found

I have a simple asp.net web application, which prints Hello world. I am not a developer, all I want to do is deploy a web application on Azure web app service. The source code is on github, when it tries to do a build (build with dotnet) via github actions I get the following errors.

Private
Add or update the Azure App Service build and deployment workflow config Build and deploy ASP.Net Core app to Azure Web App - webappra11 #5
Summary
Jobs
build
deploy
build
failed 3 hours ago in 1m 54s
Search logs
4s
9s
1m 12s
23s
Run dotnet build --configuration Release

Welcome to .NET 6.0!
---------------------
SDK Version: 6.0.202

Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.

Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry

----------------
Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only).
Learn about HTTPS: https://aka.ms/dotnet-https
----------------
Write your first app: https://aka.ms/dotnet-hello-world
Find out what's new: https://aka.ms/dotnet-whats-new
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
--------------------------------------------------------------------------------------
Microsoft (R) Build Engine version 17.1.1+a02f73656 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  Nothing to do. None of the projects specified contain packages to restore.
D:\a\udemy_demo\udemy_demo\demoapp\demoapp.vbproj(169,3): error MSB4019: The imported project "C:\Users\runneradmin\AppData\Local\Microsoft\dotnet\sdk\6.0.202\Microsoft\VisualStudio\v17.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the expression in the Import declaration "C:\Users\runneradmin\AppData\Local\Microsoft\dotnet\sdk\6.0.202\Microsoft\VisualStudio\v17.0\WebApplications\Microsoft.WebApplication.targets" is correct, and that the file exists on disk.

Build FAILED.

D:\a\udemy_demo\udemy_demo\demoapp\demoapp.vbproj(169,3): error MSB4019: The imported project "C:\Users\runneradmin\AppData\Local\Microsoft\dotnet\sdk\6.0.202\Microsoft\VisualStudio\v17.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the expression in the Import declaration "C:\Users\runneradmin\AppData\Local\Microsoft\dotnet\sdk\6.0.202\Microsoft\VisualStudio\v17.0\WebApplications\Microsoft.WebApplication.targets" is correct, and that the file exists on disk.
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:13.94
Error: Process completed with exit code 1.
0s
0s
5s
0s

I have done some research and a lot of users suggest changing the csproj file, which I dont have as the core technology is using visual basic.

I found the link https://alastaircrabtree.com/microsoft-webapplication-targets-was-not-found-again/ which is supposed to be a hack to resolve the issue, but before making any changes to the following lines, I wanted to check here if anyone knew what was going on here.

I changed the following lines

<!-- <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> -->
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildProgramFiles32)\MSBuild\Microsoft\VisualStudio\v14.0</VSToolsPath>

1 answer

  • answered 2022-05-04 17:00 JBatstone

    Essentially the Microsoft.WebApplication.targets path in your csproj can not be found on disk. Your fix looks like it would work.

    Or you can try to add:

    <Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != '' And Exists('$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets')" />
    

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum