Reputation: 25521
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.
Upvotes: 3
Views: 2108
Reputation: 1
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
Upvotes: 0
Reputation: 21
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
Upvotes: 1