Mapster.Tool 特定项目的代码生成

Mapster.Tool Code Generation for Specific Project

我有一个 Visual Studio 解决方案,其中包含各种示例控制台应用程序项目。其中之一是 MapsterSample,我正在其中试用 Mapster 并按照 GitHub https://github.com/MapsterMapper/Mapster/wiki/Mapster.Tool 中描述的步骤生成映射代码。

除了我发出命令的部分外,一切似乎都很好:

dotnet msbuild -t:Mapster

即使在包管理器控制台中选择 MapsterSample 作为默认项目,这也会导致为解决方案中的每个项目执行命令:

SampleSolution\FirstSample\FirstSample.csproj : error MSB4057: The target "Mapster" does not exist in the project.
SampleSolution\SecondSample\SecondSample.csproj : error MSB4057: The target "Mapster" does not exist in the project.
... and so on

有没有办法只执行 MapsterSample 项目的命令?

确保该项目存在于您的解决方案中。

确保名称 Mapster 拼写正确。

确保您的终端位于正确的目录中。 (理想情况下,您应该位于 .csproj for Mapster 所在的目录中。