3

We have a mixture of ASP.NET Core and .NET Framework ASP.NET apps. We use a mixture of msbuild and dotnet to build the apps.

I'm trying to go all in on dotnet, but the build always throws an error of:

error MSB4019: The imported project "C:\Program Files\dotnet\sdk\3.0.100-preview5-011568\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

Right now I'm just trying with a very simple command of dotnet msbuild foo.sln. No flags or anything being used for now.

I've tried this on multiple ASP.NET (not Core) apps and they all give the same error.

2
  • dotnet is the .NET Core-specific tool, MSBuild is the overall build framework that can handle any type of project. Use msbuild in the command line instead to build both types of projects, ie msbuild foo.sln Commented Nov 1, 2019 at 11:51
  • 1
    Using "dotnet msbuild" command does not fix the issue for me. Commented Apr 19, 2022 at 18:55

2 Answers 2

1

For ASP.NET Web applications, you need to compile using the following code.

C:\'Program Files (x86)'\'Microsoft Visual Studio'\[year]\[edition]\MSBuild\Current\Bin\msbuild.exe [project.csproj] /p:VisualStudioVersion=[version] /p:DeployOnBuild=true /p:PublishProfile=[profileName]

You can run in cmd or PowerShell. Replace tags according to the version of Visual Studio installed on your machine and solution version.

For Example:

C:\'Program Files (x86)'\'Microsoft Visual Studio'\2019\Community\MSBuild\Current\Bin\msbuild.exe HelloWorld.csproj /p:VisualStudioVersion=16.0 /p:DeployOnBuild=true /p:PublishProfile=Release
Sign up to request clarification or add additional context in comments.

Comments

0

We've solved the Microsoft.WebApplication.targets missing reference by adding it as a NuGet dependency, however the dotnet msbuild command still can't compile all related framework and asp.net projects.

We've also stood up our build server inside a docker container on an ubuntu image, as we were hoping to improve our infra with containerization etc.

However we've hit a wall in building all possible projects using the dotnet executable, even though it has the msbuild command built in.

Anyone had any luck with this? This answer indicates this is not possible though https://stackoverflow.com/a/66366638/6578823

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.