我使用的是Visual Studio 15.6.3,dotnet SDK 2.1.102。
最近,(也许是在更新之后)我追踪到了一个dotnet构建错误,这个错误显示在一个包含外语资源的项目上。错误信息如下。
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.
我可以提供重现这个错误的步骤。
DotNetBugTest
.Messages.resx
.A
,并给它配上文字 English
.Messages.fr-CA.resx
.A
,并给它配上文字 French
.现在在 Program
类,添加以下内容。
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();
}
}
这在Visual Studio中运行良好 输出。
en=English
fr=French
但如果你试图从命令行编译它..:
dotnet build --configuration Debug
你会得到错误信息
有人知道如何解决这个问题吗?甚至建议去哪里找?
看来,你必须使用MSBuild来构建这个项目。