Uh oh!
There was an error while loading. Please reload this page.
Updated version numbers to 9.0.0-pre02. + net 10 - #826
Conversation
DevTKSS
commented
Nov 26, 2025
@andrerav I can not use Mapster because its requiring net7: would you maybe check if you are able to merge this (hopefully fixing) PR ? |
DocSvartz
commented
Nov 27, 2025
@DevTKSS If you are using net 8.0 or net 9.0, you can try use Mapster 9.0.0-pre01. |
DevTKSS
commented
Nov 27, 2025
@DocSvartz I am using the latest pre release that's available for all nugets and tool too, but the tool keeps failing with telling me I would need to install the net7 runtime workload which shouldn't be required. |
stagep
commented
Nov 27, 2025
Are you using Mapster and/or Mapster.Tool? As @DocSvartz mentioned, older versions supported .Net 7. The worse case scenario is forking and adding back in .Net 7. We are here to help you find a solution / workaround. |
DevTKSS
commented
Nov 28, 2025
@stagep I figured it out, but the Wiki was not very helpfull in this 😅 Could you at least update this? A part of the problem was also that, while you "just" used the I additionally installed it globally, but more out of always typing -g for the other dotnet tool I am using 😄 {
"version": 1,
"isRoot": true,
"tools": {
"mapster.tool": {
"version": "9.0.0-pre01",
"commands": [
"dotnet-mapster"
],
"rollForward": true,
"allowPrerelease": true
}
}
}This is what I came up with using Directory.Packages.props <ItemGroupLabel="Mapping">
<PackageVersionInclude="Mapster"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.DependencyInjection"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.Async"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.Immutable"Version="9.0.0-pre01" />
<PackageVersionInclude="Mapster.EFCore"Version="9.0.0-pre01" />
</ItemGroup>
<Project>
<!-- Mapster integration targets. Mapster integration targets. Usage: 1) Run one-time setup (executes dotnet tool restore in repo root): msbuild -t:MapsterSetup 2) Enable per-project automatic Mapster generation by adding to the project's .csproj: <PropertyGroup> <MapsterEnabled>true</MapsterEnabled> </PropertyGroup> 3) Optionally, specify the Mapster generated files path pattern e.g. if you want to see the files in the project directory: <ProjectProperties> <MapsterPath>$(ProjectDir)**\mapster\**\*.g.cs</MapsterPath> </ProjectProperties> And include the following ItemGroup to expose the generated files in the project: <ItemGroup Label="Include Mapster Generated Files" Condition="'$(MapsterEnabled)' == 'true' and Exists('$(BaseIntermediateOutputPath)mapster')"> <Compile Remove="$(MapsterPath)" /> <None Include="$(MapsterPath)"> <Link>mapster-generated/$(RecursiveDir)%(Filename)%(Extension)</Link> <Visible>true</Visible> </None> </ItemGroup> 4) Build the project. If MapsterEnabled is true and the project includes a net9.0 target framework, Mapster code generation will run after build. as the code generated is not runtime-specific, it will be generated once per project, not per TFM. This way you can also use the generated files in multiple TFMs e.g. net10.0 while dotnet-mapster only supports up to net9.0 currently.-->
<TargetName="MapsterSetup">
<!-- Run tool restore in repository root (parent of /src). Only report on failure to avoid noise. -->
<ExecWorkingDirectory="$(MSBuildThisFileDirectory).."Command="dotnet tool restore"Condition="Exists('$(MSBuildThisFileDirectory)..\.config\dotnet-tools.json')"ContinueOnError="true">
<OutputTaskParameter="ExitCode"PropertyName="MapsterSetupExitCode" />
</Exec>
<ErrorText="MapsterSetup: dotnet tool restore failed (exit code $(MapsterSetupExitCode))."Condition="Exists('$(MSBuildThisFileDirectory)..\.config\dotnet-tools.json') and '$(MapsterSetupExitCode)' != '' and '$(MapsterSetupExitCode)' != '0'" />
</Target>
<!-- Run Mapster only when project targets net9.0 (either current TFM or TargetFrameworks contains net9.0). -->
<TargetName="Mapster"AfterTargets="AfterBuild"Condition="'$(MapsterEnabled)' == 'true' and ( '$(TargetFramework)' == 'net9.0' or $([System.String]::Copy('$(TargetFrameworks)').Contains('net9.0')) == 'True' )" >
<MessageImportance="high"Text="Mapster: starting code generation for $(MSBuildProjectName)..." />
<!-- Generate into a non-runtime-specific obj/mapster folder to allow reuse across TFMs -->
<ExecWorkingDirectory="$(MSBuildProjectDirectory)"Command="dotnet mapster model -a "$(TargetPath)" -o "$(BaseIntermediateOutputPath)mapster" -r -N"ContinueOnError="false" />
<ExecWorkingDirectory="$(MSBuildProjectDirectory)"Command="dotnet mapster extension -a "$(TargetPath)" -o "$(BaseIntermediateOutputPath)mapster" -N"ContinueOnError="false" />
<ExecWorkingDirectory="$(MSBuildProjectDirectory)"Command="dotnet mapster mapper -a "$(TargetPath)" -o "$(BaseIntermediateOutputPath)mapster" -N"ContinueOnError="false" />
<MessageImportance="high"Text="Mapster: finished generation for $(MSBuildProjectName)." />
</Target>
<ItemGroup>
<GeneratedMappingsInclude="**\\mapster\\*.g.cs" />
</ItemGroup>
<TargetName="CleanGenerated"BeforeTargets="Clean">
<MessageImportance="low"Text="CleanGenerated: removing mapster generated files..."Condition="Exists('$(BaseIntermediateOutputPath)mapster')" />
<DeleteFiles="@(GeneratedMappings)"ContinueOnError="false"Condition="Exists('$(BaseIntermediateOutputPath)mapster')" />
</Target>
</Project>the Project file .csproj: <ProjectSdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>DevTKSS.MyProject.DataContracts</RootNamespace>
<AssemblyName>DevTKSS.MyProject.DataContracts</AssemblyName>
<!-- The Dependending Projects are already migrated to .net10.0 so the net9.0 is only to enable dotnet-mapster -->
<TargetFrameworks>net9.0;net10.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<MapsterEnabled>true</MapsterEnabled>
<MapsterPath>$(ProjectDir)**\mapster\**\*.g.cs</MapsterPath>
</PropertyGroup>
<ItemGroup>
<PackageReferenceInclude="Mapster" />
<PackageReferenceInclude="Mapster.DependencyInjection" />
<PackageReferenceInclude="Mapster.Async" />
<PackageReferenceInclude="Mapster.Immutable" />
<PackageReferenceInclude="Mapster.EFCore" />
</ItemGroup>
<!-- Mapster generated files: expose as visible None items and set DependentUpon to the source file when possible -->
<ItemGroupLabel="Include Mapster Generated Files"Condition="'$(MapsterEnabled)' == 'true' and Exists('$(BaseIntermediateOutputPath)mapster')">
<CompileRemove="$(MapsterPath)" />
<NoneInclude="$(MapsterPath)">
<Link>mapster-generated/$(RecursiveDir)%(Filename)%(Extension)</Link>
<Visible>true</Visible>
</None>
</ItemGroup>
</Project>By the way, refering to your ![]() The actual but I am not sure from the Attribute docs of mapster, if there might be one of the arguments that I am missing but cases like this: while expected would be the summary to actually optional (missing /// <summary>/// A Weather Forecast for a specific date/// </summary>/// <param name="Date">Gets the Date of the Forecast.</param>/// <param name="TemperatureC">Gets the Forecast Temperature in Celsius.</param>/// <param name="Summary">Get a description of how the weather will feel.</param>publicrecordWeatherForecastQuery(DateOnlyDate,doubleTemperatureC,string?Summary=null){/// <summary>/// Gets the Forecast Temperature in Fahrenheit/// </summary>publicdoubleTemperatureF=>32+(TemperatureC*9/5);}Maybe you could check on this and add it to any kind of back log? |
DocSvartz
commented
Nov 28, 2025
I'm very glad that you managed to solve this 🤩 If i understand correctly, it is Business logic:
Dtos shouldn't contain Business logic, but simply serve to transfer data.
Yes, there is a problem with that. Also keep in mind that the record types in the Mapster Wiki are not actually equal Records in C# . Records mapping has already been added in Mapster, but there is no generation with MapsterTool yet. |
DevTKSS
commented
Nov 28, 2025
@DocSvartz 🤔😅 assumed they are the same! |
DevTKSS
commented
Nov 28, 2025
@DocSvartz and one question to the PR here:
|
DocSvartz
commented
Nov 28, 2025
@DevTKSS I and @stagep recently joined the Mapster. See this discussion and contact @andrerav if you want to become one of maintainers Mapster. In fact, quite a lot of changes have accumulated since version 7.4.0, There was one big problem and a lot of changes associated with it :). |
DocSvartz
commented
Dec 22, 2025
update to #841 |



No description provided.