I have AspNet.MVC application and want to build MVC views during the build (only in Release configuration).
I create this target
<Target Name="BuildViews" Condition="'$(configuration)'=='Release'" AfterTargets="Build">
<AspNetCompiler VirtualPath="/" PhysicalPath="$(ProjectDir)" />
</Target>
In Debug configuration it builds
In Release it fails with error
error MSB4062: The "Microsoft.Build.Tasks.AspNetCompiler" task could not be loaded from the assembly Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.
Installing Microsoft.Build.Tasks.Core, adding UsingTask and other manipulations doesnt help(
Maybe anyone knows the solution?
Target framework - new 4.8
C# version - 8
IDE - JetBrains Rider 2019.3.1
MSBuild Path - C:\Program Files\dotnet\sdk\3.1.101\MSBuild.dll
Project format - Microsoft.NET.Sdk (.net core format)
Also, i try to change MSBuild Path (in rider settings)
If i change it to exe-file in rider folder C:\Program Files\JetBrains\JetBrains Rider 2019.3.1\tools\MSBuild\Current\Bin\MSBuild.exe, it works
But this is not a solution, because it doesnt work on TeamCity agents, where rider is not installed
Just had the same issue with the BuildTools in Team City... Depending on what build tools you need there are different paths to it as some exist in
\Microsoft Visual Studio\2019\Professional\MSBuild\and some are inMSBuild\2019\<path>. For me this issue was resolved by updating my .config towards VS and not the build tools.