Skip to content

Cannot find assembly path when building on Linux(Debian) #368

Closed

Description

@JoaoRuani

Hello, I have a asp.net core 5 api using Mapster and Mapster.Tool, that's the csproj where mapster is referenced

Domain.csproj

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="FluentValidation.AspNetCore" Version="10.3.0" />
    <PackageReference Include="Mapster" Version="7.2.0" />
  </ItemGroup>

  <ItemGroup>
    <Generated Include="**\*.g.cs" />
  </ItemGroup>

  <Target Name="Mapster" AfterTargets="AfterBuild">
    <Exec WorkingDirectory="$(ProjectDir)" Command="dotnet tool restore" />
    <Exec WorkingDirectory="$(ProjectDir)" Command="dotnet mapster model -a &quot;$(TargetDir)$(ProjectName).dll&quot;" />
    <Exec WorkingDirectory="$(ProjectDir)" Command="dotnet mapster extension -a &quot;$(TargetDir)$(ProjectName).dll&quot;" />
    <Exec WorkingDirectory="$(ProjectDir)" Command="dotnet mapster mapper -a &quot;$(TargetDir)$(ProjectName).dll&quot;" />
  </Target>

  <Target Name="CleanGenerated">
    <Delete Files="@(Generated)" />
  </Target>

</Project>

I'am using Mapster.Tool 8.2.

Inside Domain's project the files are organized like below

Entities Folder:

  • Users
    • User.cs -> with [AdaptTo("[name]CodeGenDto"),GenerateMapper]
    • UserValidator.cs -> FluentValidation validator

Build on windows runs as expected and the dtos are generated.

When trying to build on debian the following error occurs at the step dotnet mapster model -a &quot;$(TargetDir)$(ProjectName).dll&quot;":

Microsoft (R) Build Engine version 16.11.0+0538acc04 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  Restored /home/joao/dpOfficer.digital.backend/dpOfficer.Api.BusinessLogic/dpOfficerApi.BusinessLogic.csproj (in 239 ms).
  Restored /home/joao/dpOfficer.digital.backend/dpOfficerApi.Infrastructure/dpOfficerApi.Infrastructure.csproj (in 239 ms).
  Restored /home/joao/dpOfficer.digital.backend/dpOfficerApi.Domain/dpOfficerApi.Domain.csproj (in 239 ms).
  Restored /home/joao/dpOfficer.digital.backend/dpOfficerApi.Api/dpOfficerApi.Api.csproj (in 247 ms).
  dpOfficerApi.Domain -> /home/joao/dpOfficer.digital.backend/dpOfficerApi.Domain/bin/Debug/net5.0/dpOfficerApi.Domain.dll
  Tool 'mapster.tool' (version '8.2.1') was restored. Available commands: dotnet-mapster

  Restore was successful.
  Cannot find assembly path: FluentValidation (type=package, version=10.3.0)
  Cannot find assembly path: FluentValidation (type=package, version=10.3.0)
  Cannot find assembly path: FluentValidation (type=package, version=10.3.0)
  Cannot find assembly path: FluentValidation (type=package, version=10.3.0)
  Unhandled exception. System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.  Could not load file or assembly 'FluentValidation, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7de548da2fbae0f0'. The system cannot find the file specified.

  Could not load file or assembly 'FluentValidation, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7de548da2fbae0f0'. The system cannot find the file specified.

  Could not load file or assembly 'FluentValidation, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7de548da2fbae0f0'. The system cannot find the file specified.

  Could not load file or assembly 'FluentValidation, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7de548da2fbae0f0'. The system cannot find the file specified.

     at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
     at System.Reflection.RuntimeModule.GetTypes()
     at System.Reflection.Assembly.GetTypes()
     at Mapster.Tool.Extensions.Scan(CodeGenerationConfig config, Assembly assembly) in D:\git\Mapster\src\Mapster.Tool\Extensions.cs:line 177
     at Mapster.Tool.Program.GenerateModels(ModelOptions opt) in D:\git\Mapster\src\Mapster.Tool\Program.cs:line 146
     at CommandLine.ParserResultExtensions.WithParsed[T](ParserResult`1 result, Action`1 action)
     at Mapster.Tool.Program.Main(String[] args) in D:\git\Mapster\src\Mapster.Tool\Program.cs:line 17
  System.IO.FileNotFoundException: Could not load file or assembly 'FluentValidation, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7de548da2fbae0f0'. The system cannot find the file specified.

  File name: 'FluentValidation, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7de548da2fbae0f0'
  System.IO.FileNotFoundException: Could not load file or assembly 'FluentValidation, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7de548da2fbae0f0'. The system cannot find the file specified.

  File name: 'FluentValidation, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7de548da2fbae0f0'
  System.IO.FileNotFoundException: Could not load file or assembly 'FluentValidation, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7de548da2fbae0f0'. The system cannot find the file specified.

  File name: 'FluentValidation, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7de548da2fbae0f0'
  System.IO.FileNotFoundException: Could not load file or assembly 'FluentValidation, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7de548da2fbae0f0'. The system cannot find the file specified.

  File name: 'FluentValidation, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7de548da2fbae0f0'
/home/joao/dpOfficer.digital.backend/dpOfficerApi.Domain/dpOfficerApi.Domain.csproj(19,5): error MSB3073: The command "dotnet mapster model -a "/home/joao/dpOfficer.digital.backend/dpOfficerApi.Domain/bin/Debug/net5.0/dpOfficerApi.Domain.dll"" exited with code 134.

Build FAILED.

/home/joao/dpOfficer.digital.backend/dpOfficerApi.Domain/dpOfficerApi.Domain.csproj(19,5): error MSB3073: The command "dotnet mapster model -a "/home/joao/dpOfficer.digital.backend/dpOfficerApi.Domain/bin/Debug/net5.0/dpOfficerApi.Domain.dll"" exited with code 134.
    0 Warning(s)
    1 Error(s)

If i remove all Validators, the project builds fine.

Any Idea of what i might be doing wrong?

Please tell me if more info is needed.

Activity

  1. andrerav commented on Feb 19, 2022

    @andrerav
    Member

    @JoaoRuani Do you have an update on this issue? Did you figure it out on your end?

  2. self-assigned this
    on Feb 19, 2022
  3. Melethainiel commented on May 10, 2022

    @Melethainiel

    @JoaoRuani Any news on this ?

  4. GuimoBear commented on May 24, 2022

    @GuimoBear
    Contributor

    I believe the problem may be in the GetOutput method, in the Program class, in the Mapster.Tool

    The character that separates the directory levels is informed directly in the code

            private static string GetOutput(string baseOutput, string? segment, string typeName)
            {
                var fullBasePath = Path.GetFullPath(baseOutput);
                return segment == null 
                    ? Path.Combine(fullBasePath, typeName + ".g.cs") 
                    : Path.Combine(fullBasePath, segment.Replace('.', '/'), typeName + ".g.cs");
            }

    Replacing '/' to Path.DirectorySeparatorChar the problem should be solved and the Mapster.Tool works again for any platform

  5. EniacMlezi commented on Feb 14, 2023

    @EniacMlezi
    Contributor

    I just ran into the same problem. Mapster.Tool on linux is failing.

  6. stagep commented on Jan 7, 2025

    @stagep

    In order to identify issues that are still active, we are closing issues that we believe are either resolved or are dormant. If your issue is still active then please reopen. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions