msbuild icon indicating copy to clipboard operation
msbuild copied to clipboard

SDK 7 does not generate MSB3270 "mismatch between architectures" while SDK 6 does

Open ArturDorochowicz opened this issue 2 years ago • 5 comments

Describe the bug

There's a possible regression in SDK 7 with regard to generating MSB3270 warning (mismatch between the processor architecture of the project being built and the processor architecture of the reference). SDK 7 does not produce the warning while SDK 6 does.

To Reproduce

Using SDK 6:

dotnet new globaljson --sdk-version 6.0.400
dotnet new classlib
dotnet add package Magick.Net-Q8-x64
dotnet build

Produces MSB3270 warning:

MSBuild version 17.3.2+561848881 for .NET
  Determining projects to restore...
  All projects are up-to-date for restore.
C:\Program Files\dotnet\sdk\6.0.403\Microsoft.Common.CurrentVersion.targets(2302,5): warning MSB3270:
 There was a mismatch between the processor architecture of the project being built "MSIL"
 and the processor architecture of the reference
 "[...]\.nuget\packages\magick.net-q8-x64\12.2.1\lib\netstandard21\Magick.NET-Q8-x64.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.
[...]
Build succeeded.
    1 Warning(s)
    0 Error(s)

Same thing with SDK7:

dotnet new globaljson --sdk-version 7.0.101
dotnet new classlib
dotnet add package Magick.Net-Q8-x64
dotnet build

Builds without any warnings:

MSBuild version 17.4.0+18d5aef85 for .NET
  Determining projects to restore...
  All projects are up-to-date for restore.

  [...]
 
Build succeeded.
    0 Warning(s)
    0 Error(s)
 
Time Elapsed 00:00:03.05

The Magick.Net-Q8-x64 package contains an x64 assembly (and some native libs as well).

Exceptions (if any)

Further technical details

  • Include the output of dotnet --info
  • The IDE (VS / VS Code/ VS4Mac) you're running on, and its version

ArturDorochowicz avatar Dec 15 '22 15:12 ArturDorochowicz

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

ghost avatar Dec 15 '22 15:12 ghost

Error comes from msbuild so transferring over though I can't reproduce it.

marcpopMSFT avatar Dec 15 '22 23:12 marcpopMSFT

@Forgind do you think this is related to https://github.com/dotnet/msbuild/issues/7902?

rainersigwald avatar Dec 16 '22 15:12 rainersigwald

#7902 is about a warning that we're using obsolete members, but we haven't actually changed away from using those members. This error message seems to be saying there's an actual mismatch, in which case it may actually fail, no matter what runtime they use, so I think it's separate.

Since marcpopMSFT couldn't reproduce it, I'm curious if it requires having some preview version of one or the other SDK installed, but I haven't tried to prove or disprove that by looking at commit hashes.

Forgind avatar Dec 17 '22 01:12 Forgind

It does reproduce trivially and with release sdks. Here with Docker:

SDK 7:

docker run -it mcr.microsoft.com/dotnet/sdk:7.0.101
root@4bddc135707a:/# mkdir src
root@4bddc135707a:/# cd src
root@4bddc135707a:/src# dotnet new classlib
The template "Class Library" was created successfully.

Processing post-creation actions...
Restoring /src/src.csproj:
  Determining projects to restore...
  Restored /src/src.csproj (in 77 ms).
Restore succeeded.


root@4bddc135707a:/src# dotnet add package Magick.Net-Q8-x64
  Determining projects to restore...
  Writing /tmp/tmpZ2KQw0.tmp
info : X.509 certificate chain validation will use the fallback certificate bundle at '/usr/share/dotnet/sdk/7.0.101/trustedroots/codesignctl.pem'.
info : X.509 certificate chain validation will use the fallback certificate bundle at '/usr/share/dotnet/sdk/7.0.101/trustedroots/timestampctl.pem'.
info : Adding PackageReference for package 'Magick.Net-Q8-x64' into project '/src/src.csproj'.
info :   GET https://api.nuget.org/v3/registration5-gz-semver2/magick.net-q8-x64/index.json
info :   OK https://api.nuget.org/v3/registration5-gz-semver2/magick.net-q8-x64/index.json 627ms
info :   GET https://api.nuget.org/v3/registration5-gz-semver2/magick.net-q8-x64/page/6.8.5.401/7.0.3.501.json
info :   OK https://api.nuget.org/v3/registration5-gz-semver2/magick.net-q8-x64/page/6.8.5.401/7.0.3.501.json 517ms
info :   GET https://api.nuget.org/v3/registration5-gz-semver2/magick.net-q8-x64/page/7.0.3.502/7.14.5.json
info :   OK https://api.nuget.org/v3/registration5-gz-semver2/magick.net-q8-x64/page/7.0.3.502/7.14.5.json 520ms
info :   GET https://api.nuget.org/v3/registration5-gz-semver2/magick.net-q8-x64/page/7.15.0/12.2.2.json
info :   OK https://api.nuget.org/v3/registration5-gz-semver2/magick.net-q8-x64/page/7.15.0/12.2.2.json 645ms
info : Restoring packages for /src/src.csproj...
info :   GET https://api.nuget.org/v3-flatcontainer/magick.net-q8-x64/index.json
info :   OK https://api.nuget.org/v3-flatcontainer/magick.net-q8-x64/index.json 551ms
info :   GET https://api.nuget.org/v3-flatcontainer/magick.net-q8-x64/12.2.2/magick.net-q8-x64.12.2.2.nupkg
info :   OK https://api.nuget.org/v3-flatcontainer/magick.net-q8-x64/12.2.2/magick.net-q8-x64.12.2.2.nupkg 578ms
info :   GET https://api.nuget.org/v3-flatcontainer/magick.net.core/index.json
info :   OK https://api.nuget.org/v3-flatcontainer/magick.net.core/index.json 560ms
info :   GET https://api.nuget.org/v3-flatcontainer/magick.net.core/12.2.2/magick.net.core.12.2.2.nupkg
info :   OK https://api.nuget.org/v3-flatcontainer/magick.net.core/12.2.2/magick.net.core.12.2.2.nupkg 47ms
info : Installed Magick.NET.Core 12.2.2 from https://api.nuget.org/v3/index.json with content hash U4aPbh0BRlwSeP/5waebv8oVTrp66gRHxVj1o6dRpZk5kD5SPz4i8asdaClL5B2oqWNVNrGHD3Uc5Bz4Ao5G8g==.
info : Installed Magick.NET-Q8-x64 12.2.2 from https://api.nuget.org/v3/index.json with content hash o563eR2+42IryyLhNMmcwQKyT0zdGHlv5iXLuzKHEsCWU043TcxM4iFY0roxdtPRAXqjHhUi6e9RPWO0qC/WdA==.
info : Package 'Magick.Net-Q8-x64' is compatible with all the specified frameworks in project '/src/src.csproj'.
info : PackageReference for package 'Magick.Net-Q8-x64' version '12.2.2' added to file '/src/src.csproj'.
info : Generating MSBuild file /src/obj/src.csproj.nuget.g.targets.
info : Writing assets file to disk. Path: /src/obj/project.assets.json
log  : Restored /src/src.csproj (in 13.17 sec).
root@4bddc135707a:/src# dotnet build
MSBuild version 17.4.0+18d5aef85 for .NET
  Determining projects to restore...
  All projects are up-to-date for restore.
  src -> /src/bin/Debug/net7.0/src.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:02.84

SDK 6:

docker run -it mcr.microsoft.com/dotnet/sdk:6.0.404
Unable to find image 'mcr.microsoft.com/dotnet/sdk:6.0.404' locally
6.0.404: Pulling from dotnet/sdk
025c56f98b67: Pull complete 
6afacb7d1b96: Pull complete 
f960150eb0dd: Pull complete 
e872d1dca3eb: Pull complete 
af3ffbb2228b: Pull complete 
9bbd76ff182d: Pull complete 
dc0e68ad9d69: Pull complete 
2f2ed1ba8f71: Pull complete 
Digest: sha256:619aa0300bfc99599984cadd7d53bb4091f0a59bc16ed3092ed073a2325f77d0
Status: Downloaded newer image for mcr.microsoft.com/dotnet/sdk:6.0.404
root@de331dd1a429:/# mkdir src          
root@de331dd1a429:/# cd src
root@de331dd1a429:/src# dotnet new classlib
The template "Class Library" was created successfully.

Processing post-creation actions...
Running 'dotnet restore' on /src/src.csproj...
  Determining projects to restore...
  Restored /src/src.csproj (in 121 ms).
Restore succeeded.


root@de331dd1a429:/src# dotnet add package Magick.Net-Q8-x64
  Determining projects to restore...
  Writing /tmp/tmplzD8TR.tmp
info : X.509 certificate chain validation will use the fallback certificate bundle at '/usr/share/dotnet/sdk/6.0.404/trustedroots/codesignctl.pem'.
info : Adding PackageReference for package 'Magick.Net-Q8-x64' into project '/src/src.csproj'.
info :   GET https://api.nuget.org/v3/registration5-gz-semver2/magick.net-q8-x64/index.json
info :   OK https://api.nuget.org/v3/registration5-gz-semver2/magick.net-q8-x64/index.json 535ms
info :   GET https://api.nuget.org/v3/registration5-gz-semver2/magick.net-q8-x64/page/6.8.5.401/7.0.3.501.json
info :   OK https://api.nuget.org/v3/registration5-gz-semver2/magick.net-q8-x64/page/6.8.5.401/7.0.3.501.json 520ms
info :   GET https://api.nuget.org/v3/registration5-gz-semver2/magick.net-q8-x64/page/7.0.3.502/7.14.5.json
info :   OK https://api.nuget.org/v3/registration5-gz-semver2/magick.net-q8-x64/page/7.0.3.502/7.14.5.json 682ms
info :   GET https://api.nuget.org/v3/registration5-gz-semver2/magick.net-q8-x64/page/7.15.0/12.2.2.json
info :   OK https://api.nuget.org/v3/registration5-gz-semver2/magick.net-q8-x64/page/7.15.0/12.2.2.json 595ms
info : Restoring packages for /src/src.csproj...
info :   GET https://api.nuget.org/v3-flatcontainer/magick.net-q8-x64/index.json
info :   OK https://api.nuget.org/v3-flatcontainer/magick.net-q8-x64/index.json 563ms
info :   GET https://api.nuget.org/v3-flatcontainer/magick.net-q8-x64/12.2.2/magick.net-q8-x64.12.2.2.nupkg
info :   OK https://api.nuget.org/v3-flatcontainer/magick.net-q8-x64/12.2.2/magick.net-q8-x64.12.2.2.nupkg 546ms
info :   GET https://api.nuget.org/v3-flatcontainer/magick.net.core/index.json
info :   OK https://api.nuget.org/v3-flatcontainer/magick.net.core/index.json 653ms
info :   GET https://api.nuget.org/v3-flatcontainer/magick.net.core/12.2.2/magick.net.core.12.2.2.nupkg
info :   OK https://api.nuget.org/v3-flatcontainer/magick.net.core/12.2.2/magick.net.core.12.2.2.nupkg 34ms
info : Installed Magick.NET.Core 12.2.2 from https://api.nuget.org/v3/index.json with content hash U4aPbh0BRlwSeP/5waebv8oVTrp66gRHxVj1o6dRpZk5kD5SPz4i8asdaClL5B2oqWNVNrGHD3Uc5Bz4Ao5G8g==.
info : Installed Magick.NET-Q8-x64 12.2.2 from https://api.nuget.org/v3/index.json with content hash o563eR2+42IryyLhNMmcwQKyT0zdGHlv5iXLuzKHEsCWU043TcxM4iFY0roxdtPRAXqjHhUi6e9RPWO0qC/WdA==.
info : Package 'Magick.Net-Q8-x64' is compatible with all the specified frameworks in project '/src/src.csproj'.
info : PackageReference for package 'Magick.Net-Q8-x64' version '12.2.2' added to file '/src/src.csproj'.
info : Generating MSBuild file /src/obj/src.csproj.nuget.g.targets.
info : Writing assets file to disk. Path: /src/obj/project.assets.json
log  : Restored /src/src.csproj (in 3.2 min).
root@de331dd1a429:/src# dotnet build
MSBuild version 17.3.2+561848881 for .NET
  Determining projects to restore...
  All projects are up-to-date for restore.
/usr/share/dotnet/sdk/6.0.404/Microsoft.Common.CurrentVersion.targets(2302,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "/root/.nuget/packages/magick.net-q8-x64/12.2.2/lib/netstandard21/Magick.NET-Q8-x64.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. [/src/src.csproj]
  src -> /src/bin/Debug/net6.0/src.dll

Build succeeded.

/usr/share/dotnet/sdk/6.0.404/Microsoft.Common.CurrentVersion.targets(2302,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "/root/.nuget/packages/magick.net-q8-x64/12.2.2/lib/netstandard21/Magick.NET-Q8-x64.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. [/src/src.csproj]
    1 Warning(s)
    0 Error(s)

Time Elapsed 00:00:02.78

ArturDorochowicz avatar Dec 17 '22 08:12 ArturDorochowicz

Due to the low engagement rate it seems to be a minor issue that didn't meet that bar. Feel free to report it in a fresh ticket if it remains a problem.

YuliiaKovalova avatar Jun 11 '25 10:06 YuliiaKovalova