I am using Visual Studio 15.6.3, dotnet SDK 2.1.102.
Recently, (maybe after an update) I tracked down a dotnet build bug that is showing up to a project that includes foreign language resources. The error message is as follows:
C:\Program Files\dotnet\sdk\2.1.102\Microsoft.Common.CurrentVersion.targets(3570,5): error MSB4062: The "Microsoft.Build.Tasks.AL" 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.
I can provide steps to reproduce this error:
DotNetBugTest
.Messages.resx
.A
, and give it the text English
.Messages.fr-CA.resx
.A
, and give it the text French
.Now in the Program
class, add the following:
class Program
{
static void Main(string[] args)
{
var rm = new ResourceManager("DotNetBugTest.Messages", typeof(Program).Assembly);
var en = CultureInfo.CreateSpecificCulture("en-US");
var fr = CultureInfo.CreateSpecificCulture("fr-CA");
Console.WriteLine($@"en={rm.GetString("A", en)}");
Console.WriteLine($@"fr={rm.GetString("A", fr)}");
Console.ReadKey();
}
}
This runs fine in Visual Studio. Outputs:
en=English
fr=French
But if you try to compile it from the command line:
dotnet build --configuration Debug
You get the error.
Does anybody have an idea how to fix this? Or even suggestions of where to look?
It seems that you have to use MSBuild to build this project.
See also this article: https://blog.codeinside.eu/2019/11/30/build-dotnetcore-apps-with-msbuild-to-avoid-strange-netframeworkbased-errors/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With