serilog-contrib / serilog-ui

Simple Serilog log viewer UI for several sinks.
MIT License
219 stars 41 forks source link

BUG: processor architecture mismatch #19

Closed sommmen closed 2 years ago

sommmen commented 2 years ago

Hiya,

The MSSQL provider faults with a weird error:

warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "C:\Users\31611\.nuget\packages\serilog.ui.mssqlserverprovider\2.1.0\lib\netstandard2.0\Serilog.Ui.MsSqlServerProvider.dll", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.

Perhaps this is because of the following props in the .csproj?:

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
    <PlatformTarget>x64</PlatformTarget>
    <WarningLevel>0</WarningLevel>
  </PropertyGroup>

I'm running a net6 project that looks like this:

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

    <PropertyGroup>
        <TargetFramework>net6.0</TargetFramework>
        <UserSecretsId>0844be79-0a19-44df-845c-fdb74a50cfb0</UserSecretsId>
        <RootNamespace>Comp.WebApi</RootNamespace>
        <ImplicitUsings>enable</ImplicitUsings>
    </PropertyGroup>

    <PropertyGroup>
        <GenerateDocumentationFile>true</GenerateDocumentationFile>
        <NoWarn>$(NoWarn);1591</NoWarn>
    </PropertyGroup>

    <PropertyGroup>
        <!-- See: https://docs.microsoft.com/en-us/aspnet/core/web-api/advanced/analyzers?view=aspnetcore-5.0&tabs=visual-studio -->
        <IncludeOpenAPIAnalyzers>true</IncludeOpenAPIAnalyzers>
    </PropertyGroup>

    <ItemGroup>
        <PackageReference Include="AutoMapper" Version="11.0.0" />
        <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="11.0.0" />
        <PackageReference Include="Hangfire.AspNetCore" Version="1.7.28" />
        <PackageReference Include="Hangfire.Console" Version="1.4.2" />
        <PackageReference Include="Hangfire.SqlServer" Version="1.7.28" />
        <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.1" />
        <PackageReference Include="Microsoft.BingAds.SDK" Version="13.0.12" />
        <PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.1" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.1">
            <PrivateAssets>all</PrivateAssets>
            <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
        </PackageReference>
        <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.1" />
        <PackageReference Include="Microsoft.OData.Client" Version="7.9.4" />
        <PackageReference Include="Serilog.UI" Version="2.1.1" />
        <PackageReference Include="Serilog.UI.MsSqlServerProvider" Version="2.1.0" />
        <PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
        <PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
        <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.14.1" />
    </ItemGroup>

       ...

</Project>
sommmen commented 2 years ago

The project seems to build and run fine - but this scares me a bit to be honest. I'm not sure what'll happen if i push these changes to production. any clues?

mo-esmp commented 2 years ago

According to this answer, there should be no problem with that warning:

https://stackoverflow.com/a/43533764/1385614

sommmen commented 2 years ago

According to this answer, there should be no problem with that warning:

https://stackoverflow.com/a/43533764/1385614

True - but why have you chosen x64 over 'Any' as solution platform? Now this might not work on something like a raspberry pi which is ARM64 - or on a 32 bit machine.

The other providers don't have this and i feel like 'Any cpu' should work fine for the sql provider.

mo-esmp commented 2 years ago

I haven't chosen x64 architecture and I don't think this problem is related to the Serilog.UI project.

image

sommmen commented 2 years ago

I haven't chosen x64 architecture and I don't think this problem is related to the Serilog.UI project.

image

Master does contain x64 as platform target, see:

https://github.com/mo-esmp/serilog-ui/commit/ca2f6b3249139d6a8ca5c238fc7f0bca8dbf73c0

https://github.com/mo-esmp/serilog-ui/blob/dev/src/Serilog.Ui.MsSqlServerProvider/Serilog.Ui.MsSqlServerProvider.csproj

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

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <Version>2.1.0</Version>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
    <PlatformTarget>x64</PlatformTarget>
    <WarningLevel>0</WarningLevel>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Dapper" Version="2.0.35" />
    <PackageReference Include="Microsoft.Data.SqlClient" Version="2.1.1" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\Serilog.Ui.Core\Serilog.Ui.Core.csproj" />
  </ItemGroup>
</Project>

Change it to release mode and perhaps you'll see.

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
    <PlatformTarget>x64</PlatformTarget>
    <WarningLevel>0</WarningLevel>
  </PropertyGroup>

Just remove that part and we should be good.

mo-esmp commented 2 years ago

Please upgrade Serilog.UI.MsSqlServerProvider to version 2.1.1.

sommmen commented 2 years ago

Works - thanks for the effort!